-->
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: hbm2JavaTask in Hibernate 3 can't find mapped class
PostPosted: Wed May 25, 2005 11:57 am 
Newbie

Joined: Wed May 25, 2005 11:32 am
Posts: 14
I am converting hibernate 2.1.8 to Hibernate 3.0.4. I am using Hbm2javaTask from hibernate-tools-3.0alpha1 to generate java from hbm files. But Hbm2JavaTask could not find any mapped classes. I have generated class in the same directory as hbm files, and I even add java file to the class path and add config attribute to specify the all hbm files. But Hbm2javaTask from hibernate-extensions-2.1.3 work fine at same senerio. Could anyone shine some light on my problem. Thanks!


Here is my ant target:

<target name="generate-hibernate-classes" depends="init"
description="Generating Hibernate Java Sources from Hibernate Mapping files">
<taskdef name="hbm2java" classname="org.hibernate.tool.hbm2java.Hbm2JavaTask">
<classpath refid="hibernate.lib.path"/>
<classpath refid="hibernate-tools.lib.path"/>
<classpath refid="vo.path"/>
</taskdef>
<echo message="hibernate.dialect=${hibernate.dialect}" file="${cm.lib.dir}/hibernate.properties"/>
<hbm2java config="${dev.dir}/manager/descriptors/manager/unittest-esm-config.xml" output="${dev.src.dir}">
<fileset dir="${dev.src.dir}">
<!--include name="**/*.hbm.xml"/-->
<include name="**/UserPreferenceVO.hbm.xml"/>
<include name="**/AccountVO.hbm.xml"/>
</fileset>
</hbm2java>
</target>


Here are the two hbm files:

<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping
PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">

<hibernate-mapping>

<class name="com.symantec.esm.common.vo.AccountVO" table="ESM_ACCOUNT">

<id name="id" type="int" column="ACCOUNT_ID">
<generator class="native"/>
</id>

<property name="username" type="string" not-null="true" length="50"/>
<property name="createDate" type="date" not-null="true"/>
<property name="status" type="int" not-null="true" length="25"/>
<property name="lastSuccessfulLogin" type="date" not-null="false"/>
<property name="lastUnsuccessfulLogin" type="date" not-null="false"/>
<property name="failedLoginAttempts" type="int" not-null="false"/>
<property name="password" type="string" not-null="false"/>
<property name="passwordExpiration" type="date" not-null="false"/>
<property name="passwordHistoryDelimited" type="string" not-null="false"/>


<set name="preferences" lazy="true">
<key column="accountID"/>
<one-to-many class="com.symantec.esm.common.vo.UserPreferenceVO"/>
</set>

</class>

</hibernate-mapping>



<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping
PUBLIC "-//Hibernate/Hibernate Mapping DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">

<hibernate-mapping>

<class name="com.symantec.esm.common.vo.UserPreferenceVO" table="ESM_USERPREFERENCE">

<id name="id" type="int" column="USERPREFERENCE_ID">
<generator class="native"/>
</id>

<property name="accountID" type="int" not-null="true"/>
<property name="value" type="text" not-null="true"/>
<property name="createDate" type="date" not-null="true"/>


</class>

</hibernate-mapping>

Here is the exception I got.

generate-hibernate-classes:
[hbm2java] Processing 2 files.
[hbm2java] Building hibernate objects
[hbm2java] May 25, 2005 9:44:03 AM org.hibernate.cfg.Environment <clinit>
[hbm2java] INFO: Hibernate 3.0.4
[hbm2java] May 25, 2005 9:44:03 AM org.hibernate.cfg.Environment <clinit>
[hbm2java] INFO: hibernate.properties not found
[hbm2java] May 25, 2005 9:44:03 AM org.hibernate.cfg.Environment <clinit>
[hbm2java] INFO: using CGLIB reflection optimizer
[hbm2java] May 25, 2005 9:44:03 AM org.hibernate.cfg.Environment <clinit>
[hbm2java] INFO: using JDK 1.4 java.sql.Timestamp handling
[hbm2java] May 25, 2005 9:44:03 AM org.hibernate.cfg.Configuration addFile
[hbm2java] INFO: Mapping file: D:\p4\Enterprise_Security_Manager\core\SnowBasin
\dev\common\java\src\com\symantec\esm\common\vo\AccountVO.hbm.xml
[hbm2java] May 25, 2005 9:44:03 AM org.hibernate.cfg.HbmBinder bindRootPersiste
ntClassCommonValues
[hbm2java] INFO: Mapping class: com.symantec.esm.common.vo.AccountVO -> ESM_ACC
OUNT
[hbm2java] May 25, 2005 9:44:03 AM org.hibernate.cfg.Configuration secondPassCo
mpile
[hbm2java] INFO: processing extends queue
[hbm2java] May 25, 2005 9:44:03 AM org.hibernate.cfg.Configuration secondPassCo
mpile
[hbm2java] INFO: processing collection mappings
[hbm2java] org.hibernate.MappingException: Association references unmapped clas
s: com.symantec.esm.common.vo.UserPreferenceVO
[hbm2java] at org.hibernate.cfg.HbmBinder.bindCollectionSecondPass(HbmBinde
r.java:2009)
[hbm2java] at org.hibernate.cfg.HbmBinder$CollectionSecondPass.secondPass(H
bmBinder.java:2470)
[hbm2java] at org.hibernate.cfg.HbmBinder$SecondPass.doSecondPass(HbmBinder
.java:2441)
[hbm2java] at org.hibernate.cfg.Configuration.secondPassCompile(Configurati
on.java:884)
[hbm2java] at org.hibernate.cfg.Configuration.buildMappings(Configuration.j
ava:849)
[hbm2java] at org.hibernate.tool.hbm2java.CodeGenerator.parseFiles(CodeGene
rator.java:115)
[hbm2java] at org.hibernate.tool.hbm2java.CodeGenerator.main(CodeGenerator.
java:95)
[hbm2java] at org.hibernate.tool.hbm2java.Hbm2JavaTask.processFile(Hbm2Java
Task.java:145)
[hbm2java] at org.hibernate.tool.hbm2java.Hbm2JavaTask.execute(Hbm2JavaTask
.java:95)
[hbm2java] at org.apache.tools.ant.UnknownElement.execute(UnknownElement.ja
va:275)
[hbm2java] at org.apache.tools.ant.Task.perform(Task.java:364)
[hbm2java] at org.apache.tools.ant.Target.execute(Target.java:341)
[hbm2java] at org.apache.tools.ant.Target.performTasks(Target.java:369)
[hbm2java] at org.apache.tools.ant.Project.executeTarget(Project.java:1214)

[hbm2java] at org.apache.tools.ant.Project.executeTargets(Project.java:1062
)
[hbm2java] at org.apache.tools.ant.Main.runBuild(Main.java:673)
[hbm2java] at org.apache.tools.ant.Main.startAnt(Main.java:188)
[hbm2java] at org.apache.tools.ant.launch.Launcher.run(Launcher.java:196)
[hbm2java] at org.apache.tools.ant.launch.Launcher.main(Launcher.java:55)
[hbm2java] May 25, 2005 9:44:04 AM org.hibernate.cfg.Configuration addFile
[hbm2java] INFO: Mapping file: D:\p4\Enterprise_Security_Manager\core\SnowBasin
\dev\common\java\src\com\symantec\esm\common\vo\UserPreferenceVO.hbm.xml
[hbm2java] May 25, 2005 9:44:04 AM org.hibernate.cfg.HbmBinder bindRootPersiste
ntClassCommonValues
[hbm2java] INFO: Mapping class: com.symantec.esm.common.vo.UserPreferenceVO ->
ESM_USERPREFERENCE
[hbm2java] May 25, 2005 9:44:04 AM org.hibernate.cfg.Configuration secondPassCo
mpile
[hbm2java] INFO: processing extends queue
[hbm2java] May 25, 2005 9:44:04 AM org.hibernate.cfg.Configuration secondPassCo
mpile
[hbm2java] INFO: processing collection mappings
[hbm2java] May 25, 2005 9:44:04 AM org.hibernate.cfg.Configuration secondPassCo
mpile
[hbm2java] INFO: processing association property references
[hbm2java] May 25, 2005 9:44:04 AM org.hibernate.cfg.Configuration secondPassCo
mpile
[hbm2java] INFO: processing foreign key constraints
[hbm2java] May 25, 2005 9:44:04 AM org.hibernate.tool.hbm2java.FieldProperty in
itWith
[hbm2java] INFO: fieldname = accountID
[hbm2java] May 25, 2005 9:44:04 AM org.hibernate.tool.hbm2java.FieldProperty in
itWith
[hbm2java] INFO: fieldname = value
[hbm2java] May 25, 2005 9:44:04 AM org.hibernate.tool.hbm2java.FieldProperty in
itWith
[hbm2java] INFO: fieldname = createDate
[hbm2java] May 25, 2005 9:44:04 AM org.hibernate.tool.hbm2java.Generator genera
te
[hbm2java] INFO: Generating 1 in D:\p4\Enterprise_Security_Manager\core\SnowBas
in\dev\common\java\src


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 25, 2005 2:15 pm 
Beginner
Beginner

Joined: Thu Jan 29, 2004 6:51 pm
Posts: 24
Location: Boulder, CO USA
Use the hibernatetool task instead. There is an Ant tasks doco for tools in CVS. I forget where.

<taskdef name="hibernatetool" classname="org.hibernate.tool.ant.HibernateToolTask">
<classpath>
<path refid="hibernate-tools.classpath"/>
</classpath>
</taskdef>

<hibernatetool destdir="${gen.dir}">
<configuration>
<fileset dir="${src.dir}>
<include name="**/*.hbm.xml" />
</fileset>
</configuration>
<hbm2java/>
</hibernatetool>


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 25, 2005 3:42 pm 
Newbie

Joined: Wed May 25, 2005 11:32 am
Posts: 14
Thanks for the reply.

But I could not fine org.hibernate.tool.ant.HibernateToolTask in hibernate-tools-3.0alpha1. Does any one knows what jar file should I download to get this tool.

Thanks!


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 25, 2005 4:28 pm 
Beginner
Beginner

Joined: Thu Jan 29, 2004 6:51 pm
Posts: 24
Location: Boulder, CO USA
I've been building from CVS, which is alpha3. You should probably do that. It's still alpha software, so a released jar isn't any better than a CVS jar at this point.


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.