-->
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.  [ 4 posts ] 
Author Message
 Post subject: hbm2java doesn't generate <component> class
PostPosted: Thu Nov 16, 2006 6:14 pm 
Newbie

Joined: Fri Apr 07, 2006 7:23 pm
Posts: 9
Hibernate version: 3.2.0
HibernateTools version: 3.2.0.beta8

hbm2java is complaining that it cannot find a class it is supposed to be generating. I originally got this to work using eclipse and I didn't have any notable problems there. But when I try to use the same mapping file from ant using the ant hbm2java tool, it fails.

Here is the pertinent portion of my mapping file:

Code:
  <hibernate-mapping>
    <class name="com.work.dbstor.Transaction" table="TRANSACTIONS">
      <id name="id" type="long" column="txn_id" unsaved-value="-1">
        <meta attribute="scope-set">protected</meta>
        <meta attribute="default-value">-1</meta>
        <generator class="native"/>
      </id>

      <natural-id>
        <component name="txnId" class="com.work.dbstor.TransactionID">
          <property name="seconds" not-null="true" column="txn_secs">
            <meta attribute="use-in-equals">true</meta>
            <meta attribute="use-in-tostring">true</meta>
          </property>
          <property name="microSeconds" not-null="true" column="txn_usecs">
            <meta attribute="use-in-equals">true</meta>
            <meta attribute="use-in-tostring">true</meta>
          </property>
       </component>
       <many-to-one name="fromShare"
                    class="com.work.dbstor.txnShare"
                    column="share_id"
                    not-null="true">
       </many-to-one>
    </natural-id>

    <!-- more properties follow -->
  </class>
</hibernate-mapping>


When I use this mapping in eclispe it generates a class called "com.work.dbstor.TransactionID" just like any other POJO that it generates and everything is happy. When I use ant and the hbm2java task I get the following error:

Code:
[hibernatetool] An exception occurred while running exporter #2:hbm2java (Generates a set of .java files)
[hibernatetool] To get the full stack trace run ant with -verbose
[hibernatetool] org.hibernate.InvalidMappingException: Could not parse mapping document from resource com/work/dbstor/Transaction.hbm.xml
[hibernatetool] org.hibernate.MappingException: class com.work.dbstor.TransactionID not found while looking for property: seconds
[hibernatetool] java.lang.ClassNotFoundException: com.work.dbstor.TransactionID
[hibernatetool] A class were not found in the classpath of the Ant task.
[hibernatetool] Ensure that the classpath contains the classes needed for Hibernate and your code are in the classpath.


I don't know how it could be a problem with the classpath since this class doesn't exist and won't exist until hbm2java completes successfully.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Nov 17, 2006 11:59 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
you don't specify the types for the TransactionID component thus hbm2java (of course) can't know what type to generate.

if it worked from within eclipse i'm quite sure you somehow already had that class in some form in the classpath - otherwise you would get the same error.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Fri Nov 17, 2006 12:12 pm 
Newbie

Joined: Fri Apr 07, 2006 7:23 pm
Posts: 9
Thank you! That was the problem. You responded just as I had figured that out. I almost wish the DTD made the "type" attribute required.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Nov 17, 2006 12:17 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
well then our xml would be overly redundant for users not doing codegen ;)

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