Hi all,
In our application Joda Time must be used. To map between JDBC types representing Date and DateTime I use Hibernate converters. To make the Code Generation in Hibernate Tools work I ensured that the Joda Time jar and the jars containing the converters are on the classpath. This all works fine, except for the JDBC type DATETIME. When I specify this type in the Table Mappings in the reveng.xml file and execute Hibernate Tools a MappingException is thrown. See the picture below.
I figured that it might have to do with the database dialect. I use a MySQL database so i investigated the MySQLDialect class in the hibernate3.jar. The DATETIME type appears to be registered in this file though in lowercase. Changing the JDBC Type in the reveng.xml file into lowercase did not make any diffrence. However, replacing it with the numerical key found in the MySQLDialect class made Hibernate Tools work without throwing a MappingException. I got to this because the error message refers to an invalid number. My Type Mapping looks like this now:
Code:
<type-mapping>
<sql-type jdbc-type="BIGINT" hibernate-type="java.lang.Long"></sql-type>
<sql-type jdbc-type="DECIMAL"
hibernate-type="java.math.BigDecimal">
</sql-type>
<sql-type jdbc-type="DATE"
hibernate-type="org.joda.time.contrib.hibernate.PersistentLocalDate">
</sql-type>
<sql-type jdbc-type="93" hibernate-type="com.infor.persist.hibernate.PersistentDateTimeUTC"></sql-type>
</type-mapping>
So, it works now, but having to specify the registration key for the JDBC type instead of the type name is awkward. Has anyone else ever encountered this problem? Did I overlook something?
Some additional info: I used the latest driver from MySQL, version 5.1.10 and uodated the Hibernate Tools plugin today. My hibernate.cfg.xml looks like:
Code:
<hibernate-configuration>
<session-factory name="InforFactory">
<property name="hibernate.connection.driver_class">org.gjt.mm.mysql.Driver</property>
<property name="hibernate.connection.password">secret</property>
<property name="hibernate.connection.url">jdbc:mysql://localhost/cbs_dta</property>
<property name="hibernate.connection.username">root</property>
<property name="hibernate.default_schema">cbs_dta</property>
<property name="hibernate.dialect">org.hibernate.dialect.MySQL5Dialect</property>
</session-factory>
</hibernate-configuration>