-->
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.  [ 13 posts ] 
Author Message
 Post subject: hbm2java with ant - ignore dependencies
PostPosted: Tue Jun 21, 2005 4:48 pm 
Newbie

Joined: Mon May 16, 2005 4:23 pm
Posts: 1
In my hibernate 3.0 integration with our product, I would like to use hbm2java (with ant) to generate our java code from hbm.xml files at build time. For one of my classes, I need to specify a custom persister class (so we can do encryption/compression on blobs). This persister class makes reference to the class that is generated from the hbm.xml, so I have a circular reference. When I run the hbm2java ant task to generate the DAO java, I get an exception that the persister class cannot be found, which makes sense because it hasn't been compiled yet...because it needs the DAO to be generated first. So, my question is...is there any way to turn off validation that the persister class exists when I run hbm2java? It seems like it wouldn't really need it for anything (except to make sure I'm not an idiot and referenced a non-existent class). I can probably get around it some other way, but if there's a nice clean way to just ignore this dependency, that would be best for my case.

Mapping documents:
<?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
package="com.foo.woodstock.util.frame.persistence">

<class name="BlobData" table="DATA_TABLE" persister="com.foo.woodstock.util.frame.persistence.BlobDataPersister">
<id name="id" column="DATA_ID" type="string">
<generator class="uuid"/>
</id>

<property name="data" column="DATA_OBJECT" type="blob" />

</class>

</hibernate-mapping>


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jun 27, 2005 3:21 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
i assume you are running with the new ant toolset ?

You should just include the mapping files and if you have specified all types/classes then hbm2java will not fallback to attempt reflection.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject: hbm2java requires my Id Class
PostPosted: Wed Jun 29, 2005 3:23 pm 
Newbie

Joined: Wed Jun 08, 2005 12:33 pm
Posts: 9
I have a problem relationed to that (I think).

I've used the hbm2java to generate the .java files, there´s no problem.

After that, I've tried hbm2ddl, so I receive:

org.hibernate.MappingException: component class not found: xxx.hibernate.map.ClientId

The Client class have a composite Id that references the ClientId class. ClientId don´t have a mapping file.


Did I found a bug ?


P.S.: I know, composite-id's are evil ! But it´s a legacy application. :)

P.S.2: Sorry, my english is terrible, I know :)


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jun 29, 2005 3:33 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
did you remember to compile the classes before calling hbm2dll ?

/max

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jun 29, 2005 3:38 pm 
Newbie

Joined: Wed Jun 08, 2005 12:33 pm
Posts: 9
Yep....

The .class is in the rigth directory.

Note: I've used hbm2ddl before. But it´s the first time that I use with a class that contains a composite-id.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jun 29, 2005 3:40 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
is the class ClientId in the src and class dir ?

is the class dir on the classpath of the hibernate tool ?

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jun 29, 2005 4:01 pm 
Newbie

Joined: Wed Jun 08, 2005 12:33 pm
Posts: 9
Quote:
is the class ClientId in the src and class dir ?

Yes.

Quote:
is the class dir on the classpath of the hibernate tool ?


Yes.

If I exclude the Client class from the list of mappings to be processed. Everything runs ok.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jun 29, 2005 4:05 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
show me how you call the ant task and in which classpath you have the class directory (*all* paths as you might have the class dir listed redundantly)

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jun 29, 2005 4:53 pm 
Newbie

Joined: Wed Jun 08, 2005 12:33 pm
Posts: 9
I added the .class dir redundantly where the task as called and works.

Point for you ! :)

But, so appears another error:

java.lang.UnsupportedClassVersionError: xxx/hibernate/map/AddressId (Unsupported major.minor version 49.0)

I found this post that seens to be the same problem:

http://forum.hibernate.org/viewtopic.php?t=938305

I've installed java 1.5 on monday, I've recompiled all my project and the problem persists..

How must I proceed ? Recompile my Hibernate ?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jun 29, 2005 5:25 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
my guess is you are running ant with jdk 1.4 and thus hibernate tool task cannot load jdk 1.5 classes

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 30, 2005 9:59 am 
Newbie

Joined: Wed Jun 08, 2005 12:33 pm
Posts: 9
Bingo :)

I've updated the path and Classpath enviroment variables. But JAVA_HOME was pointing to jdk 1.4. Fixed.

Now ant runs without problems.

Thanks !


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 17, 2005 10:32 pm 
Newbie

Joined: Mon Oct 17, 2005 10:30 pm
Posts: 6
I have the same problem. How did you resolve it.

My build.xml is attached below:

<?xml version="1.0"?>
<project name="newsletter" default="db" basedir=".">

<!-- Set up properties containing important project directories -->
<property name="source.root" value="src"/>
<property name="class.root" value="web/WEB-INF/classes"/>
<property name="lib.dir" value="lib"/>
<property name="data.dir" value="db"/>
<property name="output.dir" value="${source.root}/com/guidance/hibernate"/>

<!-- Set up the class path for compilation and execution -->
<path id="project.class.path">
<!-- Include our own classes, of course -->
<pathelement location="${class.root}" />
<!-- Include jars in the project library directory -->
<fileset dir="${lib.dir}">
<include name="*.jar"/>
</fileset>
</path>

<!-- Create our runtime subdirectories and copy resources into them -->
<target name="prepare" description="Sets up build structures">
<mkdir dir="${class.root}"/>

<!-- Copy our property files and O/R mappings for use at runtime -->
<copy todir="${class.root}" >
<fileset dir="${source.root}" >
<include name="**/*.properties"/>
<include name="**/*.hbm.xml"/>
</fileset>
</copy>
</target>

<!-- Compile the java source of the project -->
<target name="compile" depends="prepare"
description="Compiles all Java classes">
<javac srcdir="${source.root}"
destdir="${class.root}"
debug="on"
optimize="off"
deprecation="on">
<classpath refid="project.class.path"/>
</javac>
</target>

<target name="db" description="Runs HSQLDB database management UI against the database file--use when application is not running">
<java classname="org.hsqldb.util.DatabaseManager"
fork="yes">
<classpath refid="project.class.path"/>
<arg value="-driver"/>
<arg value="org.hsqldb.jdbcDriver"/>
<arg value="-url"/>
<arg value="jdbc:hsqldb:${data.dir}/newsletter"/>
<arg value="-user"/>
<arg value="sa"/>
</java>
</target>

<target name="hibernate" description="reverse engineer data hibernate">
<taskdef name="hibernatetool" classname="org.hibernate.tool.ant.HibernateToolTask"
classpathref="project.class.path"/>

<!-- hibernate tool task -->
<hibernatetool destdir="${output.dir}">
<classpath>
<path location="${class.root}"/>
</classpath>
<jdbcconfiguration configurationfile="conf/hibernate.cfg.xml"/>
<hbm2java/>
<cfg2hbm/>
</hibernatetool>
</target>
<target name="hibernateSchema" description="create schema hibernate">
<taskdef name="hibernatetool" classname="org.hibernate.tool.ant.HibernateToolTask"
classpathref="project.class.path"/>

<!-- hibernate tool task -->

<hibernatetool destdir="${output.dir}">
<configuration configurationfile="conf/hibernate.cfg.xml" >
<fileset dir="${output.dir}" id="id"> <!-- A configuration can take a configurationfile and/or a fileset of hbm.xml's -->
<include name="**/*.xml"/>
<exclude name="**/*TblContentHierarchy.hbm.xml"/>
<exclude name="**/*Md5index.hbm.xml"/>
<exclude name="**/*TblArticle.hbm.xml"/>
<exclude name="**/*Skinsindextemp.hbm.xml"/>
<exclude name="**/*VwSlotView.hbm.xml"/>
<exclude name="**/*Substring.hbm.xml"/>
<exclude name="**/*VwRelatedContentSearch.hbm.xml"/>
<exclude name="**/*TblContentRelated.hbm.xml"/>

</fileset>
</configuration>
<!-- export schema to database. If outputfilename is provided a text file is generated instead. -->
<hbm2ddl export="false" drop="false"/>
</hibernatetool>
</target>

</project>


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 17, 2005 10:39 pm 
Newbie

Joined: Mon Oct 17, 2005 10:30 pm
Posts: 6
i am callin the hibernateSchema task and getting the following error:

:80: org.hibernate.MappingException: component class not found: TblContentTypeId

component id issue


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 13 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.