-->
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.  [ 9 posts ] 
Author Message
 Post subject: what to change for middlegen to work for hibernate 3?
PostPosted: Mon Mar 20, 2006 8:02 pm 
Beginner
Beginner

Joined: Mon Aug 15, 2005 9:00 pm
Posts: 37
Hi

I've download Middlegen-Hibernate-r5.zip, which works with Hibernate 2.x (referring net.sf.... in build.xml). Has anyone got middlegen working with hibernate 3? What do I need to do to get this pair working together?

(Since I had no luck with the new hibernate tools - only beta available, I come back to try middlegen).

Thx
Chuck


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 21, 2006 2:11 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
I should get around to releasing a new version. In anycase, the CVS version of Middlegen works with Hibername 3. All you need to do is the set the version attribute of the HIbernate plugin sub Ant Task to "3.0". Otherwise its the same to use.


Top
 Profile  
 
 Post subject:
PostPosted: Fri May 19, 2006 12:01 am 
Newbie

Joined: Thu May 18, 2006 11:30 pm
Posts: 9
The CVS version (just checked out) seems to have problems. Here is the log when I try the samples.

===============================================
Buildfile: build.xml

init:

fail-if-no-xdoclet-1.2:

check-driver-present:

panic-if-driver-not-present:

middlegen:
[middlegen] Database URL:jdbc:hsqldb:C:\tools\middlegen\samples/build/hsqldb/air
line
[middlegen] No <table> elements specified. Reading all tables. This might take a
while...
[middlegen] 2006-05-18 23:56:29,843 WARN [middlegen.plugins.entitybean.JBoss] W
ARNING (cmp20): JBoss 3.0 doesn't support fields that are part of CMR to be CMP
at the same time. You might want to set fkcmp="false" in the cmp20 plugin.
[middlegen] -- reservations-has-flights
[middlegen] -- reservations-has-persons
[middlegen] 2006-05-18 23:56:31,765 ERROR [middlegen.FileProducer] Invocation of
method 'getGetterName' in class middlegen.plugins.entitybean.Entity20Table thr
ew exception class java.lang.IllegalArgumentException : The relationshipRole's o
rigin must be reservations , but was reservations
[middlegen] org.apache.velocity.exception.MethodInvocationException: Invocation
of method 'getGetterName' in class middlegen.plugins.entitybean.Entity20Table t
hrew exception class java.lang.IllegalArgumentException : The relationshipRole's
origin must be reservations , but was reservations
[middlegen] at org.apache.velocity.runtime.parser.node.ASTMethod.execute(AST
Method.java:246)
[middlegen] at org.apache.velocity.runtime.parser.node.ASTReference.execute(
ASTReference.java:175)
[middlegen] at org.apache.velocity.runtime.parser.node.ASTReference.render(A
STReference.java:220)
[middlegen] at org.apache.velocity.runtime.parser.node.SimpleNode.render(Sim
pleNode.java:230)
[middlegen] at org.apache.velocity.runtime.directive.Parse.render(Parse.java
:181)
[middlegen] at org.apache.velocity.runtime.parser.node.ASTDirective.render(A
STDirective.java:114)
[middlegen] at org.apache.velocity.runtime.parser.node.ASTBlock.render(ASTBl
ock.java:55)
[middlegen] at org.apache.velocity.runtime.directive.Foreach.render(Foreach.
java:166)
[middlegen] at org.apache.velocity.runtime.parser.node.ASTDirective.render(A
STDirective.java:114)
[middlegen] at org.apache.velocity.runtime.parser.node.SimpleNode.render(Sim
pleNode.java:230)
[middlegen] at org.apache.velocity.app.VelocityEngine.evaluate(VelocityEngin
e.java:316)
[middlegen] at middlegen.FileProducer.generate(FileProducer.java:328)
[middlegen] at middlegen.FileProducer.generateForTable(FileProducer.java:246
)
[middlegen] at middlegen.Plugin.doIt(Plugin.java:587)
[middlegen] at middlegen.Plugin.generate(Plugin.java:445)
[middlegen] at middlegen.Middlegen.writeSource(Middlegen.java:355)
[middlegen] at middlegen.MiddlegenTask.execute(MiddlegenTask.java:446)
[middlegen] at org.apache.tools.ant.UnknownElement.execute(UnknownElement.ja
va:275)
[middlegen] at org.apache.tools.ant.Task.perform(Task.java:364)
[middlegen] at org.apache.tools.ant.Target.execute(Target.java:341)
[middlegen] at org.apache.tools.ant.Target.performTasks(Target.java:369)
[middlegen] at org.apache.tools.ant.Project.executeSortedTargets(Project.jav
a:1216)
[middlegen] at org.apache.tools.ant.Project.executeTarget(Project.java:1185)

[middlegen] at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(De
faultExecutor.java:40)
[middlegen] at org.apache.tools.ant.Project.executeTargets(Project.java:1068
)
[middlegen] at org.apache.tools.ant.Main.runBuild(Main.java:668)
[middlegen] at org.apache.tools.ant.Main.startAnt(Main.java:187)
[middlegen] at org.apache.tools.ant.launch.Launcher.run(Launcher.java:246)
[middlegen] at org.apache.tools.ant.launch.Launcher.main(Launcher.java:67)

BUILD FAILED
C:\tools\middlegen\samples\build.xml:228: middlegen.MiddlegenException: Invocati
on of method 'getGetterName' in class middlegen.plugins.entitybean.Entity20Tabl
e threw exception class java.lang.IllegalArgumentException : The relationshipRol
e's origin must be reservations , but was reservations

Total time: 7 seconds


Top
 Profile  
 
 Post subject:
PostPosted: Fri May 19, 2006 11:10 am 
Regular
Regular

Joined: Wed Mar 15, 2006 1:48 pm
Posts: 91
I am pretty happy with MiddleGen. I downloaded MiddleGen 2.1 and it works with Hibernate 3(both Hibernate 3.0.5 and 3.1.3 work, not tried other versions). I have tried both MiddleGen and Hibernate tool for generating HBM file from DB and I feel MiddleGen is superior to Hibernate Tool for this simple task. I modified some source code in MiddleGen so it can handle multiple tables once to establish the PK/FK relationship in their HBM files respectively. Also I improved the data return types in HBM file(not using BigDecimal for Float, Double types etc). From the generated HBM file there is no much difference betweeen MiddleGen and Hibernate Tool, but with my improvement I feel HBM file generated from MiddleGen is more powerful and accurate.

All these source code changes have been submitted to David and I am expecting a new release of MiddleGen too.

David, I changed hibernate.vm for using DTD 3.0 instead of DTD 2.0 in MiddleGen plugin. It is pretty straightforward. Not sure if you need my change for your next release. Just let me know.

Here are some code samples,

1) generate HBM from DB in MiddleGen(it can dynamically handle mutiple tables delimited by comma)

<target name="gen-hbm" depends="init">
<middlegen
appname="whatever"
prefsdir="."
gui="${middlegen.gui}"
databaseurl="${database.url}"
driver="${database.driver_class}"
username="${database.username}"
password="${database.password}"
schema="${database.schema}"
>
<hibernate
destination="${middlegen.dest.dir}"
package="${class.package}"
extends="${class.extends}"
equalsHashcode="${gen.base.methods}"
columnsIncToString="${gen.base.methods}"
columnsIncEquals="${gen.base.methods}"
genXDocletTags="${gen.xdoclet-tag}"
standardCascade="${hibernate.cascade}"
javaTypeMapper="middlegen.plugins.hibernate.HibernateJavaTypeMapper"
/>

<table name="${table.name}"/>
</middlegen>
</target>

2) generate HBM from DB in Hibernate Tool(it can statically handle single or fixed tables defined in reveng.xml file)

<target name="gen-hbm" depends="init">
<copy file="template.reveng.xml" todir="tmp" overwrite="true">
<filterset>
<filter token="table.name" value="${table.name}"/>
</filterset>
</copy>
<hibernatetool destdir="${middlegen.dest.dir}">
<jdbcconfiguration revengfile="tmp/template.reveng.xml" propertyfile="hibernate.properties" />
<hbm2hbmxml/>
</hibernatetool>
<delete dir="tmp"/>
</target>


Top
 Profile  
 
 Post subject:
PostPosted: Fri May 19, 2006 12:24 pm 
Newbie

Joined: Thu May 18, 2006 11:30 pm
Posts: 9
I wasn't negative about middlegen by any means. In fact, 2.1 works great. I was just following the previous thread on generating 3.0 DTD files and gave it a try and reported the problem.


Top
 Profile  
 
 Post subject:
PostPosted: Fri May 19, 2006 2:01 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
does "superior" just mean "hibernate tools cannot take a list of table names" or is there more ?

I would like to know so i can target it...

Just to have something AFAIK Middlegen can't do then here they are:

Support multiple schemas
Have a readable and extendable "reverse eng strategy" format
Unified configuration (uses hibernate.properties/hibernate/cfg.xml)

The only thing I know we don't have is:

many-to-many support
(and we are a more strict about the casing of identifiers, but that will be changed/improved)

If there is something else then please let me know. The jira is also for feature requests.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Sat May 20, 2006 1:31 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
kkus,

Anything you wish to send me please do. I will (I promise) look at it and include / commit it as appropriate.

Max,

I think you have done a great job with the tools and I am sure they will get better and better. You don't have to worry about Middlegen - sure get ideas and replicate them in tools and improve away. There will always be users that have personal preferences. It in no way deminishes the work you have been doing.

Because you asked there are a few things that Middlegen does better and visa vesa. Like: Middlegen has Many-to-many and One-to-one. Middlegen allows the users to select using the graphical view the cardinality in addition can make the direction uni or bi directional. Filling in and customising the default values and preferences all through selection within the GUI (while also supporting headless code generation via Ant). It can generate for Hibernate 2 and Hibernate 3 (note: there is also an EJB3 module). Its a good tool and I put a lot of work into it. Thats why it is the official tool for Hibernate 2. I did not want to just dump the users so Hibernate 3 support was include as a smoother transition option to allow the users to move to Hibernate Tools platform (but I have not done an offical release for some time).

Hibernate tools has many great features. Its had the benefit of learning from Middlegen's lessons and its become a mature code base that users can rely on. It is the main tool and will continue to be that way. I feel, in a away, guilty for not implementing more Middlegen features into the HTools code base but I don't work for JBoss thus personnal time is limited. It will get there and I hope to continue to be a part of it.


Top
 Profile  
 
 Post subject:
PostPosted: Sat May 20, 2006 4:04 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
Hi David,

I appreciate your work and have no problems in you improving them; I'm just curious on what features that users feel that is missing ?

Is it the graphical UI (opposed to the more form based one in HTools) ? (have not focused on that since it does not scale very well IMO; but everything is or will be controllable from there....)

Is it the many-to-many ? (not done since it is almost always the first thing one go remove when the system gets larger - that said I have code that handles this now just a matter of me getting it completed; one-to-one I actually should get done)

Hibernate 2 generation is not a target for Hibernate Tools (it is completely doable; I actually think it currently is a matter of changing the DTD and possibly toggle the default for lazyiness - but again noone asked for it)

My point is just that I keep getting these comments that "something" is missing, but noone really reports what it is (besides you David ;)...

so in short: I know there is stuff that can be improved and is working on
them, but if someone thinks something can be improved and it is not happening then I ask
them to vote for it, report it or even submit a patch for it (I appreciate all three types of contributions)

btw. directionallity is controllable now (since b4 ;)

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Sat May 20, 2006 9:19 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
I agree if the users are not asking for improvements or documenting suggestions then it is hard for you to workout priorities for future/further features. I do agree that the GUI in Middlegen is not that scaleable in its current form. I also don't see it improving as the demand is not there since Hibernate Tools has (rightly) become the main tool. I think thats great and its a credit to the work that has been done. I do think a GUI interface would add alot of value. Obviously, it is difficult to do right (and right is subjective).

So its time to hand this discussion back over to the users - document your ideas for Hibernate tools. Your views will shape the feature set and we are listening.


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