• 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
  • Liutauras Vilda
  • Paul Clapham
  • Bear Bibeault
  • Jeanne Boyarsky
Sheriffs:
  • Ron McLeod
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Jj Roberts
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • salvin francis
  • Scott Selikoff
  • fred rosenberger

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

 
Rancher
Posts: 180
7
Mac OS X IntelliJ IDE
  • 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?

 
Master Rancher
Posts: 4694
49
  • 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: 180
7
Mac OS X IntelliJ IDE
  • 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
Master Rancher
Posts: 4694
49
  • 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.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic