Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
Win a copy of Event Streams in Action this week in the Java in General forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Knute Snortum
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Ron McLeod
  • Piet Souris
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • Ganesh Patekar

LocalDateTime and Hibernate, not sure if I'm doing it the right way

 
Rancher
Posts: 92
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm persisting some data using Hibernate and I'm not sure if that's the correct way of doing things. I have a class called SensorDataObject, one of the fields is of type LocalDateTime. When it's saved in mysql its type is DATETIME which I assume is correct.
Now when I wrote code to retrieve data my IDE (Intelij) marks it as an error but the code compiles and seems to be working fine:



Intelij complains about "sdo.localDateTime" and says: "Type mismatch: number, date or string expected."

Am I doing something wrong or is Intelij just confused?

 
Rancher
Posts: 4177
47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What version of IntelliJ is it?

Is it a plugin that is doing the code checking for the query?

Whichever it is, does that version handle Hibernate 5?
 
Adrian Grabowski
Rancher
Posts: 92
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You are correct, I assumed it was Intelij's built in function but it is actually a plugin bundled with Intelij Ultimate. It checks your query and highlights the keywords. It doesn't say if it works with Hibernate 5 to be honest but it looks like it doesn't understand LocalDateTime.

Am I correct to assume that it is ok to use Java 8 Date api with Hibernate 5 without any tricks and mapping from LocalDateTime to MySQL's DATETIME is ok? It seems to be working straight out of the box...

Thanks
 
Dave Tolls
Rancher
Posts: 4177
47
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hibernate 5 was built to work with Java 8 and it's new structures, including the new Date/Time classes, so you don't have to do anything extra.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!