-->
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.  [ 15 posts ] 
Author Message
 Post subject: Hibernate 3 alpha and generating mappings
PostPosted: Thu Nov 04, 2004 8:58 pm 
Newbie

Joined: Tue Nov 02, 2004 11:44 am
Posts: 8
Hi,

If I'm using hibernate 3.0 alpha, what should be the value of my version attribute in the following excerpt from Ant file? Is there specific version of XDoclet and Ant I should be using with 3 alpha?

Code:
<hibernatedoclet
           destdir="${classes.dir}"
            excludedtags="@version,@author,@todo"
            force="true"
            verbose="true"
            mergedir="${classes.dir}">
               <fileset dir="${prototype.home}\src">              
                  <include name="**/*.java"/>
               </fileset>

            <hibernate version="[color=red]??[/color]"/>

         <hibernatecfg .................


Up till now I was using 2.0, and I was successful in generating db schema, etc. But now all of sudden I am getting DocumentException because hibernate-mapping-2.0.dtd couldnot be found.

I have another questions:
Does Hibernate really look for DTDs over the Internet and if yes, how do I change the DOCTYPE in *.hbm.xml files without having to alter them manually. Ideally, I will like to accomplish this as part of build process.

Hibernate version:
3.0 alpha

Mapping documents:
<?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.sonus.sdm.model.Bugs"
table="Bugs"
dynamic-update="false"
dynamic-insert="false"
>

<id
name="projectName"
column="projectName"
type="java.lang.String"
>
<generator class="foreign">
<param name="property">project</param>
</generator>
</id>

<one-to-one
name="project"
class="com.sonus.sdm.model.Project"
cascade="none"
outer-join="auto"
constrained="true"
/>
</class>
</hibernate-mapping>


Full stack trace of any exception that occurs:
[schemaexport] 19:29:00,875 INFO - loaded properties from resource hibernate.properties: {hibernate.connection.usernam
e=sdmuser, hibernate.connection.password=sdmuser, hibernate.cglib.use_reflection_optimizer=true, hibernate.dialect=org.h
ibernate.dialect.MySQLDialect, hibernate.connection.url=jdbc:mysql:///sdmdb, hibernate.connection.driver_class=com.mysql
.jdbc.Driver}
[schemaexport]
[schemaexport] 19:29:00,890 INFO - using CGLIB reflection optimizer
[schemaexport]
[schemaexport] 19:29:00,890 INFO - using JDK 1.4 java.sql.Timestamp handling
[schemaexport]
[schemaexport] 19:29:00,984 INFO - Mapping file: C:\Testing\classes\com\sonus\sdm\model\Bugs.hbm.xml
[schemaexport]
[schemaexport] 19:29:01,359 ERROR - Could not configure datastore from file: C:\Testing\classes\com\sonus\sdm\model\Bug
s.hbm.xml
[schemaexport] org.dom4j.DocumentException: http://hibernate.sourceforge.net/hibern ... ng-2.0.dtd Nested exception
: http://hibernate.sourceforge.net/hibern ... ng-2.0.dtd
[schemaexport] at org.dom4j.io.SAXReader.read(SAXReader.java:358)
[schemaexport] at org.dom4j.io.SAXReader.read(SAXReader.java:219)
[schemaexport] at org.hibernate.cfg.Configuration.addFile(Configuration.java:202)
[schemaexport] at org.hibernate.tool.hbm2ddl.SchemaExportTask.getConfiguration(SchemaExportTask.java:195)
[schemaexport] at org.hibernate.tool.hbm2ddl.SchemaExportTask.execute(SchemaExportTask.java:135)
[schemaexport] at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275)
[schemaexport] at org.apache.tools.ant.Task.perform(Task.java:364)
[schemaexport] at org.apache.tools.ant.Target.execute(Target.java:341)
[schemaexport] at org.apache.tools.ant.Target.performTasks(Target.java:369)
[schemaexport] at org.apache.tools.ant.Project.executeTarget(Project.java:1214)
[schemaexport] at org.apache.tools.ant.Project.executeTargets(Project.java:1062)
[schemaexport] at org.apache.tools.ant.Main.runBuild(Main.java:673)
[schemaexport] at org.apache.tools.ant.Main.startAnt(Main.java:188)
[schemaexport] at org.apache.tools.ant.launch.Launcher.run(Launcher.java:196)
[schemaexport] at org.apache.tools.ant.launch.Launcher.main(Launcher.java:55)
[schemaexport] Nested exception:
[schemaexport] java.io.FileNotFoundException: http://hibernate.sourceforge.net/hibern ... ng-2.0.dtd
[schemaexport] at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:798)
[schemaexport] at org.apache.xerces.impl.XMLEntityManager.setupCurrentEntity(Unknown Source)
[schemaexport] at org.apache.xerces.impl.XMLEntityManager.startEntity(Unknown Source)
[schemaexport] at org.apache.xerces.impl.XMLEntityManager.startDTDEntity(Unknown Source)
[schemaexport] at org.apache.xerces.impl.XMLDTDScannerImpl.setInputSource(Unknown Source)
[schemaexport] at org.apache.xerces.impl.XMLDocumentScannerImpl$DTDDispatcher.dispatch(Unknown Source)
[schemaexport] at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
[schemaexport] at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
[schemaexport] at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
[schemaexport] at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
[schemaexport] at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
[schemaexport] at org.dom4j.io.SAXReader.read(SAXReader.java:339)
[schemaexport] at org.dom4j.io.SAXReader.read(SAXReader.java:219)
[schemaexport] at org.hibernate.cfg.Configuration.addFile(Configuration.java:202)
[schemaexport] at org.hibernate.tool.hbm2ddl.SchemaExportTask.getConfiguration(SchemaExportTask.java:195)
[schemaexport] at org.hibernate.tool.hbm2ddl.SchemaExportTask.execute(SchemaExportTask.java:135)
[schemaexport] at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275)
[schemaexport] at org.apache.tools.ant.Task.perform(Task.java:364)
[schemaexport] at org.apache.tools.ant.Target.execute(Target.java:341)
[schemaexport] at org.apache.tools.ant.Target.performTasks(Target.java:369)
[schemaexport] at org.apache.tools.ant.Project.executeTarget(Project.java:1214)
[schemaexport] at org.apache.tools.ant.Project.executeTargets(Project.java:1062)
[schemaexport] at org.apache.tools.ant.Main.runBuild(Main.java:673)
[schemaexport] at org.apache.tools.ant.Main.startAnt(Main.java:188)
[schemaexport] at org.apache.tools.ant.launch.Launcher.run(Launcher.java:196)
[schemaexport] at org.apache.tools.ant.launch.Launcher.main(Launcher.java:55)

BUILD FAILED
C:\Testing\Hibernate\build.xml:93: Schema text failed: org.dom4j.DocumentException: http://hibernate.sourceforge.net/hib
ernate-mapping-2.0.dtd Nested exception: http://hibernate.sourceforge.net/hibern ... ng-2.0.dtd

Name and version of the database you are using:
MySql


Top
 Profile  
 
 Post subject:
PostPosted: Fri Nov 05, 2004 7:14 am 
Senior
Senior

Joined: Wed Aug 27, 2003 4:08 am
Posts: 178
Location: Wiesbaden, Germany
I affraid hibernate-3 is not yet supported by xdoclet
( certainly not by xdoclet-2 plugin - I would know as project admin )

DTD is contained in hibernate jar and is looked up locally by
specific resolver ( this is true for HB-2 )

AFAIK hibernate 3 tries to go for java 1.4 annotations
( correct me if I'm wrong )

regards,

_________________
Got new hibernate xdoclet plugin? http://www.sourceforge.net/projects/xdoclet-plugins/
... Momentan auf der Suche nach neuen Projekt ode Festanstellung....


Top
 Profile  
 
 Post subject:
PostPosted: Fri Nov 05, 2004 7:41 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
H3 will have support for JDK 1.5 annotations.

But please remember that hbm.xml will still be around - H3 will still work fine on JDK 1.3, 1.4 and maybe even also 1.2 (to a certain extent, but i havent tried that my self ;)

Support for XDoclet is something that should/will come from the community...

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Fri Nov 05, 2004 7:56 am 
Senior
Senior

Joined: Wed Aug 27, 2003 4:08 am
Posts: 178
Location: Wiesbaden, Germany
max wrote:
Support for XDoclet is something that should/will come from the community...


It seems that this community will be me :)

_________________
Got new hibernate xdoclet plugin? http://www.sourceforge.net/projects/xdoclet-plugins/
... Momentan auf der Suche nach neuen Projekt ode Festanstellung....


Top
 Profile  
 
 Post subject:
PostPosted: Fri Nov 05, 2004 11:06 am 
Newbie

Joined: Tue Nov 02, 2004 11:44 am
Posts: 8
ko5tik wrote:

DTD is contained in hibernate jar and is looked up locally by
specific resolver ( this is true for HB-2 )



So , if I update hibernate3.jar to contain "hibernate mapping 2.0.dtd", (and continue to use currently available XDoclet version), I don't think my ant target would fail in case of unavailability of DTD over the Internet. Am I right? (what a hack)


Top
 Profile  
 
 Post subject:
PostPosted: Fri Nov 05, 2004 11:18 am 
Senior
Senior

Joined: Wed Aug 27, 2003 4:08 am
Posts: 178
Location: Wiesbaden, Germany
pb74 wrote:

So , if I update hibernate3.jar to contain "hibernate mapping 2.0.dtd", (and continue to use currently available XDoclet version), I don't think my ant target would fail in case of unavailability of DTD over the Internet. Am I right? (what a hack)


This is in deed a hack. And pretty ugly one. But it could work
( provided that HB3 will eat mapping from HB2 - I have just no idea. )

If you were using xdoclet-2 hibernate plugin I could write special template ( and plugin ) to produce correct dtd reference thie evening.
( you will have to compile it yourself though, as I do not plan another release this weeked )

The only question is, how compatible those mappings are?

And speaking of DTD availability over internet - it just does not matter because hibernate ues local resolver and pulls dtd from own jar.

_________________
Got new hibernate xdoclet plugin? http://www.sourceforge.net/projects/xdoclet-plugins/
... Momentan auf der Suche nach neuen Projekt ode Festanstellung....


Top
 Profile  
 
 Post subject:
PostPosted: Fri Nov 05, 2004 12:56 pm 
Newbie

Joined: Tue Nov 02, 2004 11:44 am
Posts: 8
ko5tik wrote:
If you were using xdoclet-2 hibernate plugin I could write special template ( and plugin ) to produce correct dtd reference thie evening.
( you will have to compile it yourself though, as I do not plan another release this weeked )


Will you please point me to this plug-in download page? Currently I am using xdoclet-1.2.1, but I am ready to go for the plugin if you are taking efforts to make it compatible with 3 alpha.

ko5tik wrote:
And speaking of DTD availability over internet - it just does not matter because hibernate ues local resolver and pulls dtd from own jar.


That is interesting because as you can see from my bugs.hbm.xml, it has DOCTYPE reference to mapping 2.0.dtd. I don't have 2.0.dtd in classpath or any jar, but schemaexport was working fine neverthless. At one point, I started getting DocumentException, and at the same time the url http://hibernate.sourceforge.net/hibern ... ng-2.0.dtd wasn't working. When the url started working, schemaexport started working too. So either i have to put 2.0.dtd in jar , or point to 3.0.dtd which is already in jar.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Nov 05, 2004 1:10 pm 
Senior
Senior

Joined: Wed Aug 27, 2003 4:08 am
Posts: 178
Location: Wiesbaden, Germany
pb74 wrote:

Will you please point me to this plug-in download page? Currently I am using xdoclet-1.2.1, but I am ready to go for the plugin if you are taking efforts to make it compatible with 3 alpha.


I'm just wondering, why I put this url into my signature if nobody reads it :)

It's xdoclet-plugins on sourceforge.

_________________
Got new hibernate xdoclet plugin? http://www.sourceforge.net/projects/xdoclet-plugins/
... Momentan auf der Suche nach neuen Projekt ode Festanstellung....


Top
 Profile  
 
 Post subject: using xdoclet in hib3 results in wrong dtd-reference
PostPosted: Tue Dec 28, 2004 6:34 am 
Newbie

Joined: Sat Aug 21, 2004 7:53 am
Posts: 4
Location: Hofheim, Germany
I followed your thread, however I am not sure, if it solves my problem with the mapping in hibernate 3. Actually it does perfectly generate the hibernate.cfg.xml. However, the dtd reference in the head is wrong:


It results into
<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 2.0//EN" "http://hibernate.sourceforge.net/hibernate-configuration-2.0.dtd">

whereas it should have been:

<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">

when I change the 2.0 manually into 3.0 it works perfectly - however not very convenient ;-)

Where does xdoclet take the DTD-text exactly from? Can I somehow patch to make it work with hib3?

Stefan


Top
 Profile  
 
 Post subject:
PostPosted: Tue Dec 28, 2004 1:03 pm 
Newbie

Joined: Wed Jul 28, 2004 3:20 pm
Posts: 16
It also looks like the xdoclet 2 tags don't include the new join tag... true?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 03, 2005 4:06 pm 
Newbie

Joined: Tue Nov 02, 2004 11:44 am
Posts: 8
Apparently I continued development using 2.0 DTD reference, but with hibernate3.jar

It means I am using advanced features of hibernate3, but my xdoclet is 2.0 compatible. I am not generating any of the new mappings/elements/attributes that 3.0 is offering.

This also means my application fetches 2.0 DTD over Intenet if I do not put it in any of the jars.

One point to note is that I am using Xdoclet 1.2.1. I'm not sure if 1.2.2 will allow you to use hibernate3. Please keep me posted if there is hibernate3 compatible version of xdoclet is available.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 15, 2005 6:17 am 
Regular
Regular

Joined: Tue Sep 28, 2004 5:18 pm
Posts: 55
Location: Switzerland
Just chiming in to note that our team is observing problems using xdoclet-1.2.2 with hibernate3. These problems can be resolved by manually editing generated mapping files to reference the hibernate 3.0 dtd files.

Unfortunately, due to issues on the Mac platform, we can't migrate to Java5 yet, so I'm still searching for a way to make xdoclet generate hibernate 3.0 mappings correctly without manual intervention.

Anyone solve this yet?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 13, 2005 12:12 pm 
Newbie

Joined: Wed Apr 13, 2005 9:33 am
Posts: 1
If u are using ant in your building process(as u should if not using maven or other similar build tool), you can avoid manually replacing the DTD definitions by adding something like this after u have generated the mapping files with xdoclet.


<replace dir="${build.dir}" >
<include name="**/*.hbm.xml"/>
<replacetoken><![CDATA[Hibernate Mapping DTD 2.0]]</replacetoken>
<replacevalue><![CDATA[Hibernate Mapping DTD 3.0]]></replacevalue>
</replace>
<replace dir="${build.dir}" >
<include name="**/*.hbm.xml"/>
<replacetoken><![CDATA[hibernate-mapping-2.0]]></replacetoken>
<replacevalue><![CDATA[hibernate-mapping-3.0]]></replacevalue>
</replace>

I know this is not an elegant solution, but may solve ur problem if the only thing that is stopping u is the dtd definition ;) .

Regards, Rodrigo.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 13, 2005 5:55 pm 
Regular
Regular

Joined: Tue Sep 28, 2004 5:18 pm
Posts: 55
Location: Switzerland
Thanks, that worked well.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 13, 2005 9:38 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
CVS version of XDoclet 1.x.x has started to support H3. (1.3 snapshot - CVS HEAD)


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