-->
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.  [ 61 posts ]  Go to page 1, 2, 3, 4, 5  Next
Author Message
 Post subject: Why doesn't Middlegen create POJOs for Hibernate?
PostPosted: Tue May 11, 2004 12:42 pm 
Newbie

Joined: Tue May 11, 2004 12:38 pm
Posts: 2
Location: london
Perhaps I am missing something, but it seems to me that if you're pointing Middlegen to your database then you're going to want the Pojos as well as the O/R mappings. But it only generates the latter. Can someone please explain this to my feeble mind?

Thanks


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 11, 2004 12:56 pm 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
You can use hbm2java for the next step.


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 11, 2004 6:41 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
Michael is correct - the idea is to setup the environment to use hbm2java to create the POJOs. This allowed hbm2java (thus Max) to keep working on doing its job well and Middlegen pluggin to create the mapping files. Reduced some overlap between the tools. There was a basic prototype added to JIRA early on but it does not work very well.

I have my own POJO generation for Middlegen that I have kept for my own private use that I have not released. At some point in the near future I will include it with the distribution. The reason is that in the future Annotations are "going to be aggressively supported [Gavin]" and hence Middlegen will (optionally) generate the POJOs with Annotation. The future is that no xml mapping documents will be required (though Java 1.5 will be).


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 12, 2004 5:15 am 
Newbie

Joined: Tue May 11, 2004 12:38 pm
Posts: 2
Location: london
I see! Thanks very much indeed.


Top
 Profile  
 
 Post subject:
PostPosted: Fri May 05, 2006 3:21 pm 
Regular
Regular

Joined: Tue Nov 09, 2004 5:15 pm
Posts: 100
As of today, we were successfully able to generate .hbm.xml mapping files and POJOs using Middlegen 2.2 CVS version. But it would be nice if it could generate hibernate annotations in POJOs instead.

Does someone know of a way to do it?

Thanks a lot for any input!


Top
 Profile  
 
 Post subject:
PostPosted: Fri May 05, 2006 5:02 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
tools.hibernate.org supports it directly.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Fri May 05, 2006 5:27 pm 
Regular
Regular

Joined: Tue Nov 09, 2004 5:15 pm
Posts: 100
Thanks Max.

Are you saying that we don't need to use Middlegen, but Hibernate Tools through eclipse?

Thanks again.


Top
 Profile  
 
 Post subject:
PostPosted: Fri May 05, 2006 6:32 pm 
Regular
Regular

Joined: Wed Mar 15, 2006 1:48 pm
Posts: 91
We are pretty happy with MiddleGen to generate hbm and POJO automatically from DB tables. Then with them we can generate model, controller, web code(jsp) automatically. This has reduced a lot of dev time and can keep newbie's work in the same framework (Spring+Hibernate).

Problem with current MiddleGen is it uses an old hibernate template file. So it stucks with Hibernate 2 attributes and its old package path. Also I have fixed some minor issues in MiddleGen so it can take multiple tables once to proceed, return exact Java data type (current code returns BidDecimal for all float, double types in hbm and POJO files), generate proper package path with slash seperation. I am contacting MiddelGen guys to see if they need my contribution if they want to keep MiddleGen alive.


Top
 Profile  
 
 Post subject:
PostPosted: Fri May 05, 2006 8:51 pm 
Regular
Regular

Joined: Tue Nov 09, 2004 5:15 pm
Posts: 100
Thanks kkus.

We've just downloaded JBoss Eclipse IDE 1.5.x which supports Hibernate tools.

We are still figuring out how to generate hibernate annotations using hibernate tools using this JBoss Eclipse IDE.

One other important requirement for us is to be able to use the existing stored procedures. If we are successfully able to reverse engineer the existing tables to POJOs which has hibernate annotations (not .hbm.xml files), the next step is to figure out how to continue to use the existing stored procedures which has most of the biz logic in it. We've around 400+ stored procedures. Does anyone know how to continue to use these stored procedures through hibernate 3.x??? For the new features, we'll make sure that we don't use stored procedures but because of the large number of existing stored procedures, we should definitely find a way to use them through hibernate.

Could someone please advice me on this requirement?

Thanks for any input in advance!


Top
 Profile  
 
 Post subject:
PostPosted: Sat May 06, 2006 2:56 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
kkus - hibernate tools can do the same (at lesat if someone submits/produce some templates for doing it ;)

ssa1 - h3.x supports using stored procedures but you will need to customize the templates since there is no standard way for how stored procedures are named/mapped. Or simply just write them by hand
which is recommended approach anyway for doing legacy mappings.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Sat May 06, 2006 3:23 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
ssa1 wrote:
Thanks Max.

Are you saying that we don't need to use Middlegen, but Hibernate Tools through eclipse?

Thanks again.


One of Hibernate Tools goals is to be a replacement for most of what middlegen could do in respect with hibernate mappings - so yes.

And no, you don't *need* to use the eclipse version it can also be fully controlled via ant.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Sat May 06, 2006 3:24 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
btw. the pojo generation in middlegen is actually done via hibernate tools ;)

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Sat May 06, 2006 2:48 pm 
Regular
Regular

Joined: Tue Nov 09, 2004 5:15 pm
Posts: 100
Thanks max for your replies.

I've installed JBoss Eclipse IDE 1.5.x on eclipse and tried to generate the java annotations (not the hibernate mapping files).

When i choose the options "JDK 1.5 constructs" OR "EJB3/JSR-220 annotations" under "Exporters" tab, i am getting the following exception:

org.hibernate.tool.hbm2x.ExporterException: MethodInvocationException while processing template pojo. Invocation of method 'get' in class org.hibernate.tool.hbm2x.TemplateHelper$Templates threw exception class org.hibernate.tool.hbm2x.ExporterException: MethodInvocationException while processing template pojo/PojoTypeDeclaration.vm. Invocation of method 'get' in class org.hibernate.tool.hbm2x.TemplateHelper$Templates threw exception class org.hibernate.tool.hbm2x.ExporterException: MethodInvocationException while processing template pojo/Ejb3TypeDeclaration.vm. Invocation of method 'generateAnnTableUniqueConstraint' in class org.hibernate.tool.hbm2x.pojo.EntityPOJOClass threw exception class java.lang.NullPointerException: null


Could someone please help me figure out what it is?

As i mentioned before, i would like to generate hibernate annotations in POJOs NOT .hbm.xml mapping files.

Regarding the templates to customize how the stored procedures are mapped, could you please explain me which templates are you referring to? I will be happy to do more reading if you could point me to some documentation.

One more thing is the direct use of Ant instead of eclipse plug-in. Are you saying that if we could use hibernate tools directly through Ant instead of through eclipse plug-in we've more control?

Thanks very much for your help!


Top
 Profile  
 
 Post subject:
PostPosted: Sat May 06, 2006 3:05 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
you are not using the latest version of hibernate tools - do that; then we can get a proper error message via freemarker instead of dum velocity ;)

And yes (as stated in the docs and *every* announcement) the code generation tools are not dependent on eclipse.

/max

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Sun May 07, 2006 12:50 am 
Regular
Regular

Joined: Tue Nov 09, 2004 5:15 pm
Posts: 100
Thanks Max. When i used the latest hibernate tools 3.1 beta 5, i could get rid of all the other exceptions but the following one:

org.hibernate.tool.hbm2x.ExporterException: Error while processing template Pojo
freemarker.template.TemplateModelException: Method public java.lang.String org.hibernate.tool.hbm2x.pojo.EntityPOJOClass.generateAnnTableUniqueConstraint() threw an exception when invoked on org.hibernate.tool.hbm2x.pojo.EntityPOJOClass(com.apple.ist.espresso.Dr01201Sqr)
freemarker.template.TemplateModelException: Method public java.lang.String org.hibernate.tool.hbm2x.pojo.EntityPOJOClass.generateAnnTableUniqueConstraint() threw an exception when invoked on org.hibernate.tool.hbm2x.pojo.EntityPOJOClass(com.apple.ist.espresso.Dr01201Sqr)
java.lang.NullPointerException: <no message>


Could you please let me know what's that i am still missing?


Also, regarding the use of existing stored procedures, we've 400+ stored procedures. Do we really need to manually write the mapping for all these stored procedures? Any other automated ways???

Could someone please share with me what did you do when migrating your existing applications with large number of stored procs to Hibernate?

Thanks again!


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 61 posts ]  Go to page 1, 2, 3, 4, 5  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.