-->
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.  [ 6 posts ] 
Author Message
 Post subject: Reverse engineer XDoclet tags for Hibernate 3
PostPosted: Fri Jan 05, 2007 12:03 pm 
Newbie

Joined: Fri Jan 05, 2007 11:48 am
Posts: 4
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version:
Hibernate 3.1.1
Mapping documents:

Code between sessionFactory.openSession() and session.close():

Full stack trace of any exception that occurs:

Name and version of the database you are using:
MySQL
The generated SQL (show_sql=true):

Debug level Hibernate log excerpt:


Problems with Session and transaction handling?

Read this: http://hibernate.org/42.html

I have legacy schema that I want to reverse enginner into Hibernate POJO classes. And I'd like to use XDoclet tags in the POJO's to describe the O/R mappings. Is there a tool that can generate the xdoclet tags for me, from the schema?

Hibernate Tools 3.2 Beta 8 doesn't do that. I read that Middlegen2 can generate xdoclet, but wonder if it works for Hibernate 3?

Another way is to potentially generate xdoclet from the mapping files (that I generated with Hibernate Tools 3.2). Anybody knows such tools exist?

thanks,
Jia


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jan 07, 2007 5:49 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
Middlegen does work for Hibernate 3 and yes it will generate the XDoclet tags. Use the version attribute to tell it you want the hibernate 3 target.
Best to build Middlegen from the CVS Source.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 08, 2007 10:32 am 
Newbie

Joined: Fri Jan 05, 2007 11:48 am
Posts: 4
Thanks!

I tried Middlegen-2.1 but it doesn't recognize the version attribute on the hibernate target. Which Middlegen version should I use?
Also, we use XDoclet 1.2.2. Are you aware of any limitation to use this for Hibernate 3? I read somewhere that entity associations with composite keys is not supported in XDoclet 1.2.2. Wonder if that's true and if there's more limitations.

Jia


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 08, 2007 11:05 am 
Newbie

Joined: Fri Jan 05, 2007 11:48 am
Posts: 4
I found answer to my first question from another post:

http://forum.hibernate.org/viewtopic.ph ... a6dfccbc6a

That must be why David suggested compiling from CVS instead of using 2.1 binaries.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 08, 2007 5:23 pm 
Newbie

Joined: Fri Jan 05, 2007 11:48 am
Posts: 4
I tried build middlegen 2.1 with code from CVS. Then I set the version attribute in the hibernate target. I was able to generate the DAO and hbm.xml files. However when I tried to run "hbm2java" target (see below ant script) to generate the POJOs with xdoclet tags, I got a connection error (see the end) which we think it's because of not being able to find hibernate 3 dtd. We have included in our classpath hibernate3.jar and verified that hibernate-mapping-3.0.dtd is in this jar. We suspect Hbm2JavaTask is looking at hibernate2.jar which only contains hibernate2 dtd. I used hibernate-tools-2.1.3.jar from the CVS distribution (For some reason, the hibernate2.jar has to be included in the classpath, otherwise we encounter a ClassNotFoundException.) Should I use a newer hibernate-tools jar? The hibernate tool jars from hibernate 3 tools suite no longer support the Hibernate2JavaTask.

build.xml:

<taskdef
name="hbm2java"
classname="net.sf.hibernate.tool.hbm2java.Hbm2JavaTask"
classpathref="hbm2java.classpath"
/>

ant execution log:

hbm2java:
[hbm2java] Processing 2 mapping files.
[hbm2java] java.net.ConnectException: Connection refused: connect
[hbm2java] at java.net.PlainSocketImpl.socketConnect(Native Method)
[hbm2java] at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:305)
[hbm2java] at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.ja
a:171)
[hbm2java] at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:158)
[hbm2java] at java.net.Socket.connect(Socket.java:452)
[hbm2java] at java.net.Socket.connect(Socket.java:402)
[hbm2java] at sun.net.NetworkClient.doConnect(NetworkClient.java:139)
[hbm2java] at sun.net.www.http.HttpClient.openServer(HttpClient.java:402)
[hbm2java] at sun.net.www.http.HttpClient.openServer(HttpClient.java:618)
[hbm2java] at sun.net.www.http.HttpClient.<init>(HttpClient.java:306)
[hbm2java] at sun.net.www.http.HttpClient.<init>(HttpClient.java:267)
[hbm2java] at sun.net.www.http.HttpClient.New(HttpClient.java:339)
[hbm2java] at sun.net.www.http.HttpClient.New(HttpClient.java:320)
[hbm2java] at sun.net.www.http.HttpClient.New(HttpClient.java:315)
[hbm2java] at sun.net.www.protocol.http.HttpURLConnection.plainConnect(Htt
URLConnection.java:521)
[hbm2java] at sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLC
nnection.java:498)
[hbm2java] at sun.net.www.protocol.http.HttpURLConnection.getInputStream(H
tpURLConnection.java:626)
[hbm2java] at org.apache.xerces.impl.XMLEntityManager.setupCurrentEntity(U
known Source)
[hbm2java] at org.apache.xerces.impl.XMLEntityManager.startEntity(Unknown
ource)
[hbm2java] at org.apache.xerces.impl.XMLEntityManager.startDTDEntity(Unkno
n Source)
[hbm2java] at org.apache.xerces.impl.XMLDTDScannerImpl.setInputSource(Unkn
wn Source)
[hbm2java] at org.apache.xerces.impl.XMLDocumentScannerImpl$DTDDispatcher.
ispatch(Unknown Source)
[hbm2java] at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDo
ument(Unknown Source)
[hbm2java] at org.apache.xerces.parsers.XML11Configuration.parse(Unknown S
urce)
[hbm2java] at org.apache.xerces.parsers.XML11Configuration.parse(Unknown S
urce)
[hbm2java] at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
[hbm2java] at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown So
rce)
[hbm2java] at org.jdom.input.SAXBuilder.build(SAXBuilder.java:370)
[hbm2java] at org.jdom.input.SAXBuilder.build(SAXBuilder.java:724)
[hbm2java] at org.jdom.input.SAXBuilder.build(SAXBuilder.java:703)
[hbm2java] at net.sf.hibernate.tool.hbm2java.CodeGenerator.main(CodeGenera
or.java:100)
[hbm2java] at net.sf.hibernate.tool.hbm2java.Hbm2JavaTask.processFile(Hbm2
avaTask.java:145)
[hbm2java] at net.sf.hibernate.tool.hbm2java.Hbm2JavaTask.execute(Hbm2Java
ask.java:93)
[hbm2java] at org.apache.tools.ant.UnknownElement.execute(UnknownElement.j
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:106
)
[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)


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 09, 2007 5:16 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
When you are using the hibernate tools - you will need to use the dependencies that comes with the tools - that includes the hibernate.jar . This is because the internal non-public structures are used by the tools for internal processing. Once the output is created it will work fine with the version you plan to deploy with.


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