Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[eclipselink-users] java.util.Date with JPA/native queries

Hi,

I noticed an interesting anomaly with java.util.Date. I made a simple JPA app running in JBoss 7.2 with postgres DB. JBoss in turn serializes data to clients in various formats. I use both hibernate and eclipselink persistence.xml files and interchange them to compare the two side by side. I noticed that all dates in JSON data response show up as long (offset from Jan 1, 19070) rather than original date format from postgres as long as JPA queries are used. At first I thought this might be related to JSON provider configuration but then I noticed that If I use native queries dates show up as strings in original DB format. Only JPA queries somehow end up fetching and representing dates as longs. When I use Hibernate all dates show up as strings regardless of query type. 

I tried eclipselink 2.4.1 and 2.4.2. All java.util.Date fields are annotated with @Temporal(javax.persistence.TemporalType.DATE)

What could be going on here and is there a way to somehow configure eclipselink to consistently treat dates regardless of query type?

Regards,
Vladimir 

Back to the top