1

I got issue about hibernate pojo annotation. One column in database is varchar with date pattern yyyy-MM (such as 2015-07, 2015-06), I CAN NOT change this varchar date pattern in database.

When I use @DateTimeFormat(pattern="yyyy-MM"), I got exception as

 ERROR: org.hibernate.engine.jdbc.spi.SqlExceptionHelper - Bad format for DATE '2015-05'

How can I get around this issue without changing varchar date pattern in database.

I made test in DB, with varchar pattern as (2015-07-01) and @DateTimeFormat(pattern="yyyy-MM-dd"), no exception throwed. And I test pattern like (2015-May) with @DateTimeFormat(pattern="yyyy-MMM"), no exception throwed. Just when the pattern is in "yyyy-MM", it throws this exception. Unfortunately, I must use this '2015-06' varchar pattern in database, how can I get around this issue, seems hibernate annotation not recognize this pattern as 'yyyy-MM'

I hope not using AttributeConverter, because I don't want build a new class for this problem, it might make my system even more messy.

0 Answers0