-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: MappingException thrown using DATETIME type in reveng.xml
PostPosted: Thu Oct 15, 2009 8:56 am 
Newbie

Joined: Tue Nov 11, 2008 5:55 am
Posts: 9
Location: Barneveld, Netherlands
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.

Image

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>


Top
 Profile  
 
 Post subject: Re: MappingException thrown using DATETIME type in reveng.xml
PostPosted: Wed Oct 21, 2009 8:02 am 
Newbie

Joined: Tue Nov 11, 2008 5:55 am
Posts: 9
Location: Barneveld, Netherlands
Hi vyemialyanchyk,

This is the rquested stacktrace, not very long, so i post it here.

Code:
org.hibernate.MappingException: Could not configure overrides from file: C:\dev\Workspaces\CBS\com.infor.cbs.fortress.tools\conf\hibernate.reveng.xml
at org.hibernate.cfg.reveng.OverrideRepository.addFile(OverrideRepository.java:119)
at org.hibernate.eclipse.launch.CodeGenerationLaunchDelegate$2.execute(CodeGenerationLaunchDelegate.java:296)
at org.hibernate.console.execution.DefaultExecutionContext.execute(DefaultExecutionContext.java:64)
at org.hibernate.console.ConsoleConfiguration.execute(ConsoleConfiguration.java:94)
at org.hibernate.eclipse.launch.CodeGenerationLaunchDelegate.buildConfiguration(CodeGenerationLaunchDelegate.java:285)
at org.hibernate.eclipse.launch.CodeGenerationLaunchDelegate.runExporters(CodeGenerationLaunchDelegate.java:218)
at org.hibernate.eclipse.launch.CodeGenerationLaunchDelegate.launch(CodeGenerationLaunchDelegate.java:138)
at org.eclipse.debug.internal.core.LaunchConfiguration.launch(LaunchConfiguration.java:764)
at org.eclipse.debug.internal.core.LaunchConfiguration.launch(LaunchConfiguration.java:614)
at org.eclipse.debug.internal.ui.DebugUIPlugin.buildAndLaunch(DebugUIPlugin.java:865)
at org.eclipse.debug.internal.ui.DebugUIPlugin$8.run(DebugUIPlugin.java:1068)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55)
Caused by: org.hibernate.MappingException: jdbc-type: DATETIME is not a known JDBC Type nor a valid number
at org.hibernate.cfg.reveng.JDBCToHibernateTypeHelper.getJDBCType(JDBCToHibernateTypeHelper.java:120)
at org.hibernate.cfg.reveng.OverrideBinder.bindTypeMappings(OverrideBinder.java:402)
at org.hibernate.cfg.reveng.OverrideBinder.bindRoot(OverrideBinder.java:38)
at org.hibernate.cfg.reveng.OverrideRepository.add(OverrideRepository.java:170)
at org.hibernate.cfg.reveng.OverrideRepository.addInputStream(OverrideRepository.java:149)
at org.hibernate.cfg.reveng.OverrideRepository.addFile(OverrideRepository.java:115)
... 11 more


Top
 Profile  
 
 Post subject: Re: MappingException thrown using DATETIME type in reveng.xml
PostPosted: Tue Nov 17, 2009 9:46 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
as the error says, DATETIME is not a valid JDBC type.

_________________
Max
Don't forget to rate


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.