-->
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.  [ 2 posts ] 
Author Message
 Post subject: Ant Task and UserTypes
PostPosted: Fri Jul 08, 2005 4:27 am 
Newbie

Joined: Sun Jan 23, 2005 1:39 am
Posts: 2
I am having an unusual problem with hibernate-tools-3.0.0.0alpha4a and UserType generation.

I set up the hbm2java task in my ant file as follows:

Code:
    <target name="hbm2java"
       description="Creates model POJOs in build from hbm.xml files" depends="compile-src">
          <taskdef
           name="hibernatetool"
           classname="org.hibernate.tool.ant.HibernateToolTask"
           classpathref="hibernatetools.path"/>
       
           <hibernatetool destdir="./build">
               <classpath>
                  <path location="./bin"/>-->
              </classpath>
             <configuration>
              <fileset dir="./mappings">  <!-- A configuration can take a configurationfile and/or a fileset of hbm.xml's -->
                <include name="**/*.hbm.xml"/>
              </fileset>
             </configuration>

             <hbm2java generics="false"/> <!-- generate default .java files -->
            </hibernatetool>
    </target>


Note that the task calls compile-src, which compiles the UserType files into the directory bin before attempting to do any generation. Also note that I have explicitly turned off generics mode.

Somehow, I get the following exception:

Code:
[hibernatetool] (hbm2x.Cfg2JavaTool                  574 )
Could not resolve type without exception for org.hibernate.mapping.Property(country) Value: org.hibernate.mapping.SimpleValue
([org.hibernate.mapping.Column(countryid)]) Type: null.
Falling back to typename: com.acme.persistence.model.CountryCodeUserType
Finding class com.acme.persistence.model.CountryCodeUserType
Finding class com.acme.persistence.model.CountryCodeUserType


If I'm correct, the exception is being thrown from line 574 (commented) in org.hibernate.tool.hbm2x.Cfg2JavaTool, which is actually within a block of code that seems like it should only be executed when
generics mode is on:

Code:

if (useGenerics) {
             if (value instanceof Collection) {
                Collection collection = (Collection) value;
                OneToMany oneToMany = (OneToMany) collection.getElement();
                String entityType = oneToMany.getAssociatedClass().getClassName(); //!! Line 574
                
                return toName(p.getType().getReturnedClass() ) + "<" + entityType + ">";
             }
           }



Maybe my investigation has missed something. Anyhow, any help is deeply appreciated.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jul 08, 2005 5:01 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
i think you would get this no matter if you had generics or not.

Anyhow, the issue is due to a classloader issue which should be fixed in the latest cvs.

but anyhow, it should all work if you put the classpath of the usertype in the hibernatetool classpath. (which is a workaround)

_________________
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.  [ 2 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.