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.