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?
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...
posted 1 year ago
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.