Hibernate Exceptions

1.Association references unmapped class

< class name="package+class name" table="xxx">

2.[Exception] org.hibernate.MappingException: Unknown entity: annotations.Users

Using resource mapping files - The Hibernate configuration file must define the entity classes: < mapping class="annotations.Users"/>

Using annotations - You must explicitly add the class to the configuration using configuration.addClass(annotations.Users.class)

3.Cannot convert value '0000-00-00 00:00:00' from column to TIMESTAMP

You can use this JDBC URL directly in your datasource configuration: jdbc:mysql://yourserver:3306/yourdatabase?zeroDateTimeBehavior=convertToNull

Datetimes with all-zero components (0000-00-00 ...) — These values can not be represented reliably in Java. Connector/J 3.0.x always converted them to NULL when being read from a ResultSet. Connector/J 3.1 throws an exception by default when these values are encountered as this is the most correct behavior according to the JDBC and SQL standards. This behavior can be modified using the zeroDateTimeBehavior configuration property. The allowable values are:

  • exception (the default), which throws an SQLException with an SQLState of S1009.
  • convertToNull, which returns NULL instead of the date.
  • round, which rounds the date to the nearest closest value which is 0001-01-01.