-->
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.  [ 18 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: Hibernate Extension 2.1 generating 0 size java files ?
PostPosted: Mon Apr 12, 2004 11:32 am 
Beginner
Beginner

Joined: Fri Mar 05, 2004 11:14 am
Posts: 38
Location: Houston, Texas
I have just upgrated my hibernate-tools.jar from 2.0.3 to Hibernate Extensions 2.1 and it generates now 0 kb sized Java files. Using the old 2.0.3 hibernate-tools.jar instead wokrs fine ..... any had the same ? Any new stuff I am missing here ?

Thanx
B-)


Top
 Profile  
 
 Post subject:
PostPosted: Mon Apr 12, 2004 11:41 am 
Beginner
Beginner

Joined: Fri Mar 05, 2004 11:14 am
Posts: 38
Location: Houston, Texas
The error I get using the new hibernate-tools.jar via the ant build

<target name="gen-src" depends="splash" unless="gen-src.not.required">
<taskdef
name="hbm2java"
classname="net.sf.hibernate.tool.hbm2java.Hbm2JavaTask"
classpathref="gen-src.class.path"
/>

<hbm2java output="${src.dir}" classpathref="gen-src.class.path">
<fileset dir="${src.dir}/com/xyz/hibernate/model">
<include name="**/*.hbm.xml"/>
</fileset>
</hbm2java>

</target>



is

gen-src:
[hbm2java] Processing 15 files.
[hbm2java] Building hibernate objects
[hbm2java] Apr 12, 2004 10:36:43 AM net.sf.hibernate.tool.hbm2java.Generator generate
[hbm2java] INFO: Generating 1 in C:\job\perforce\project\main\java\xyz\src
[hbm2java] java.lang.NullPointerException
[hbm2java] at net.sf.hibernate.tool.hbm2java.BasicRenderer.isPropertySet(BasicRenderer.java:611)
[hbm2java] at net.sf.hibernate.tool.hbm2java.BasicRenderer.generateConcreteEmptyClasses(BasicRenderer.java:332)
[hbm2java] at net.sf.hibernate.tool.hbm2java.BasicRenderer.render(BasicRenderer.java:59)
[hbm2java] at net.sf.hibernate.tool.hbm2java.Generator.write(Generator.java:138)
[hbm2java] at net.sf.hibernate.tool.hbm2java.Generator.writeRecur(Generator.java:115)
[hbm2java] at net.sf.hibernate.tool.hbm2java.Generator.generate(Generator.java:104)
[hbm2java] at net.sf.hibernate.tool.hbm2java.CodeGenerator.main(CodeGenerator.java:125)
[hbm2java] at net.sf.hibernate.tool.hbm2java.Hbm2JavaTask.processFile(Hbm2JavaTask.java:145)
[hbm2java] at net.sf.hibernate.tool.hbm2java.Hbm2JavaTask.execute(Hbm2JavaTask.java:95)
[hbm2java] at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:269)
[hbm2java] at org.apache.tools.ant.Task.perform(Task.java:364)
[hbm2java] at org.apache.tools.ant.Target.execute(Target.java:301)
[hbm2java] at org.apache.tools.ant.Target.performTasks(Target.java:328)
[hbm2java] at org.apache.tools.ant.Project.executeTarget(Project.java:1215)
[hbm2java] at org.apache.tools.ant.taskdefs.Ant.execute(Ant.java:383)
[hbm2java] at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:269)
[hbm2java] at org.apache.tools.ant.Task.perform(Task.java:364)
[hbm2java] at org.apache.tools.ant.Target.execute(Target.java:301)
[hbm2java] at org.apache.tools.ant.Target.performTasks(Target.java:328)
[hbm2java] at org.apache.tools.ant.Project.executeTarget(Project.java:1215)
[hbm2java] at org.apache.tools.ant.taskdefs.Ant.execute(Ant.java:383)
[hbm2java] at org.apache.tools.ant.taskdefs.CallTarget.execute(CallTarget.java:107)
[hbm2java] at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:269)
[hbm2java] at org.apache.tools.ant.Task.perform(Task.java:364)
[hbm2java] at org.apache.tools.ant.Target.execute(Target.java:301)
[hbm2java] at org.apache.tools.ant.Target.performTasks(Target.java:328)
[hbm2java] at org.apache.tools.ant.Project.executeTarget(Project.java:1215)
[hbm2java] at org.apache.tools.ant.Project.executeTargets(Project.java:1063)
[hbm2java] at org.apache.tools.ant.Main.runBuild(Main.java:632)
[hbm2java] at org.apache.tools.ant.Main.startAnt(Main.java:183)
[hbm2java] at org.apache.tools.ant.launch.Launcher.run(Launcher.java:197)
[hbm2java] at org.apache.tools.ant.launch.Launcher.main(Launcher.java:56)
[hbm2java] Apr 12, 2004 10:36:43 AM net.sf.hibernate.tool.hbm2java.Generator generate
[hbm2java] INFO: Generating 1 in C:\job\perforce\project\main\java\xyz\src


Top
 Profile  
 
 Post subject:
PostPosted: Mon Apr 12, 2004 2:22 pm 
Beginner
Beginner

Joined: Fri Mar 05, 2004 11:14 am
Posts: 38
Location: Houston, Texas
And it did not change when adding the meta tags for "implement-equals" and "use-in-equals" as described in the release notes

<class
name="com.xyz.hibernate.model.Company"
table="COMPANY"
>
<meta attribute="implement-equals"/>

<id
name="companyS"
column="COMPANY_S"
type="java.lang.String"
length="19">
<meta attribute="use-in-equals"/>
<generator class="comxyz.hibernate.SurrogateKeyGenerator"/>
</id>

<property
name="companyCode"
column="COMPANY_CODE"
type="java.lang.String"
length="40"
/>
... etc

Hope somebody can explain what I am doing wrong ?
B-)


Top
 Profile  
 
 Post subject:
PostPosted: Mon Apr 12, 2004 4:16 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
either make a simple example and add it as a jira issue or try to follow the code and see why it happens..

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Mon Apr 12, 2004 4:44 pm 
Beginner
Beginner

Joined: Fri Mar 05, 2004 11:14 am
Posts: 38
Location: Houston, Texas
Thanx, until I find some time to debug the code I sent this info in case somebody has similar problems ....

Here a simple example. Initially generated with Middlegen and edited to add the new meta tags
From the error it seam slike ant is having problems. Using exaqct same ant file and Hbm mapping file
it works file with the 2.0.3 hibernate-tools.jar ...



<?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 default-cascade="save-update">
<!--
Created by the Middlegen Hibernate plugin

http://boss.bekk.no/boss/middlegen/
http://hibernate.sourceforge.net/
-->

<class
name="com.xyz.hibernate.model.TestCountry"
table="TEST_COUNTRY"
>
<meta attribute="implement-equals"/>

<id
name="countryS"
type="java.lang.String"
column="COUNTRY_S"
>
<meta attribute="use-in-equals"/>
<generator class="assigned" />
</id>

<property
name="name"
type="java.lang.String"
column="NAME"
not-null="true"
length="40"
/>

</class>
</hibernate-mapping>



And the ant parts of intrests are where the hibernate/tools contains the new hibernate-tools.jar file

<path id="gen-src.class.path">
<pathelement path="${classes.dir}"/>
<fileset dir="${dev.home}/hibernate">
<include name="hibernate2.jar"/>
</fileset>
<fileset dir="${dev.home}/hibernate/lib">
<include name="*.jar"/>
</fileset>
<fileset dir="${dev.home}/hibernate/tools">
<include name="*.jar"/>
</fileset>
<fileset dir="${dev.home}/hibernate/tools/lib">
<include name="*.jar"/>
</fileset>
</path>


<target name="gen-src" unless="gen-src.not.required">
<taskdef
name="hbm2java"
classname="net.sf.hibernate.tool.hbm2java.Hbm2JavaTask"
classpathref="gen-src.class.path"
/>

<hbm2java output="${src.dir}" classpathref="gen-src.class.path">
<fileset dir="${src.dir}/com/xyz/hibernate/model">
<include name="**/*.hbm.xml"/>
</fileset>
</hbm2java>

</target>



Best
B-)


Top
 Profile  
 
 Post subject:
PostPosted: Mon Apr 12, 2004 5:42 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
arh darn - i've found the bug in the default configuration of hbmj2ava ;(

if you use the --config option then there should be no problems.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Mon Apr 12, 2004 6:26 pm 
Beginner
Beginner

Joined: Fri Mar 05, 2004 11:14 am
Posts: 38
Location: Houston, Texas
GREAT !! -- I just have to edit my ant build file than and add an argument to the hbm2java - thanx so much ! Don't yet know howto do that - but that I can figure out myselfe ... thanx again

B-)


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 13, 2004 10:28 am 
Beginner
Beginner

Joined: Fri Mar 05, 2004 11:14 am
Posts: 38
Location: Houston, Texas
Hmm - have tried to look around on apache.org but could not find a way to add the "--config" option to hbm2java when using in a TaskDef with ant like
<target name="gen-src" unless="gen-src.not.required">

<taskdef
name="hbm2java"
classname="net.sf.hibernate.tool.hbm2java.Hbm2JavaTask"
classpathref="gen-src.class.path"
/>

<hbm2java output="${src.dir}" classpathref="gen-src.class.path">
<fileset dir="${src.dir}/com/xyz/hibernate/model">
<include name="**/*.hbm.xml"/>
</fileset>
</hbm2java>

</target>

anybody has an idea here how we can add the "--config" ?!?! Of course we could use a <java> block but then how to tell the hbm2java to take all files as example above in a given directory using <fileset> ??!?!

any comments appreaciated ...
B-)


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 13, 2004 11:52 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
how about just adding config="someconfig.xml" as an attribute ?

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 13, 2004 12:21 pm 
Beginner
Beginner

Joined: Fri Mar 05, 2004 11:14 am
Posts: 38
Location: Houston, Texas
Cool ! .. You mean something like

<target name="gen-src" unless="gen-src.not.required">
<taskdef
name="hbm2java"
classname="net.sf.hibernate.tool.hbm2java.Hbm2JavaTask"
classpathref="gen-src.class.path"
/>

<hbm2java output="${src.dir}" classpathref="gen-src.class.path" config="${dev.home}/conf/hbm2java.xml">
<fileset dir="${src.dir}/com/xyz/hibernate/model">
<include name="**/*.hbm.xml"/>
</fileset>
</hbm2java>

</target>

What should the hbm2java.xml than contain to trigger the --config ?

.. sorry my dum question but I am not a ant/xml star ... hope you can give me a hint
The stuff above at least is OLK - now I just need to know how the hbm2java.xml should look like...

thanx
B-)


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 13, 2004 12:55 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
how about reading about it in the manual about the config.xml file ? ;)

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 14, 2004 4:04 pm 
Newbie

Joined: Wed Apr 14, 2004 4:01 pm
Posts: 2
Did anyone figure out how to do this?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 14, 2004 5:21 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
read the docs in section 19.1.2

It explains what a config.xml can contain.

But for the lazy ones here is the contents for the default handling in hbm2java:

Code:
<codegen>
    <generate renderer="net.sf.hibernate.tool.hbm2java.BasicRenderer"/>
</codegen>



and that can be used by either by --config in a cmd line or config= attribute in ant

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 15, 2004 9:55 am 
Beginner
Beginner

Joined: Fri Mar 05, 2004 11:14 am
Posts: 38
Location: Houston, Texas
Jeg takker og bukker !

Finally I got it to work here the Hbm mapping file with the new meta attributes needed and the ant build file and the config file (hbm2java.xml) containing what Max just posted.

Max: Is there an option to turn on by default that the system should generate the hashcode and equals without having to give every file the new 2 meta tags ? I see that for one of my mapping files where I used the composite-id the hashcode and equals where created even without specifying the new Meta attributes ....

<?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 default-cascade="save-update">

<class
name="com.xyz.hibernate.model.Company"
table="COMPANY"
>

<meta attribute="implement-equals">true</meta>

<id
name="companyS"
column="COMPANY_S"
type="java.lang.String"
length="19">
<meta attribute="use-in-equals">true</meta>
<generator class="com.xyz.hibernate.SurrogateKeyGenerator" />
</id>

<property
name="companyCode"
column="COMPANY_CODE"
type="java.lang.String"
length="40"
/>

</class>
</hibernate-mapping>

The ant file to generate code I use is like where the hbm2java.xml file contains exact what Max has posted.



<target name="gen-src" unless="gen-src.not.required">
<taskdef
name="hbm2java"
classname="net.sf.hibernate.tool.hbm2java.Hbm2JavaTask"
classpathref="gen-src.class.path"
/>

<hbm2java output="${src.dir}" classpathref="gen-src.class.path" config="${dev.home}/conf/hbm2java.xml">
<fileset dir="${src.dir}/com/xyz/hibernate/model">
<include name="**/*.hbm.xml"/>
</fileset>
</hbm2java>

</target>


Thanx Max !


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 15, 2004 10:03 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
"Jeg takker og bukker !" - hvilen Houston, Texas i Danmark er det lige du kommer fra ? ;)

back to ya' question:

meta tags are per default inheritable (as you can read in the docs...)
so if you want something to work for all things - simply put the <meta> at a higher level! Like in the config.xml !


;)

_________________
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.  [ 18 posts ]  Go to page 1, 2  Next

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.