-->
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.  [ 5 posts ] 
Author Message
 Post subject: Converting from CMP to Hibernate questions
PostPosted: Mon Aug 22, 2005 1:35 am 
Beginner
Beginner

Joined: Mon Aug 22, 2005 1:22 am
Posts: 36
I have a system that is currently using over 100 local cmp entities (2.1) and would like to convert to hibernate. The EJBs were deployed on Weblogic 8.1.

1) are there any quick reference quides that would help streamline this process?

2) cascading deletes were handled by the EJB associations and not the DB. what is the equivalent in Hibernate, if any? do i need to create triggers on the DB to handle cascading deletes? Note: all data will be accessed via this one application.

3) there are cases where the associated data had a "reference_id" column that pointed back to the "parent" data. the reference manual examples are a little confusing since the "associated" key is the same in the parent and child.

4) any tools that read the *ejb-jar.xml files for weblogic and create the necessary mapping files? or any other useful tools to help in this manner?

Thanks in advance...

- Doug


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 22, 2005 10:35 am 
Newbie

Joined: Tue Aug 02, 2005 1:40 pm
Posts: 16
Location: US
You may refer this URL which talks about migration from EJB to hibernate. But dun expect any automated process in this link. I belive you need to logical map things on your own. You can use middlegen in anycase to generate automated mapping files and POJO's but again you need to do some hand coding to set the mapping etc.

http://www.devx.com/Java/Article/27954/0/page/1


Top
 Profile  
 
 Post subject: Re: Converting from CMP to Hibernate questions
PostPosted: Mon Aug 22, 2005 11:40 am 
Senior
Senior

Joined: Tue Aug 03, 2004 2:11 pm
Posts: 142
Location: Somerset
rdleeper wrote:
2) cascading deletes were handled by the EJB associations and not the DB. what is the equivalent in Hibernate, if any? do i need to create triggers on the DB to handle cascading deletes? Note: all data will be accessed via this one application.


If you map your associations correctly in hibernate and specific the correct cascade option on the association, then hibernate will handle it all for you.

rdleeper wrote:
4) any tools that read the *ejb-jar.xml files for weblogic and create the necessary mapping files? or any other useful tools to help in this manner?


Middlegen will help you out a lot in that you can point it at your DB and generate a bottom up hibernate mapping that you can use as a starting point. Be prepared for a reasonable amount (in fact the bulk of your work) hand crafting these mapping files to fit in with your existing domain model (not sure if you have one if you are ditching hte CMP layer).

I don't know of any tool that will read the ejb deployment descriptors, that's not to say there aren't any.

As an approach I suggest your start around the periphery of your database and work towards the centre, so you get more experience using hibernate on simpler files before tackling the meatier associations.

_________________
On the information super B road


Top
 Profile  
 
 Post subject: Additional info
PostPosted: Mon Aug 22, 2005 12:26 pm 
Beginner
Beginner

Joined: Mon Aug 22, 2005 1:22 am
Posts: 36
I forgot to mention that I already have a complete POJO domain model. The CMP Entity Beans were only for persistence to/from DB. Access to these EJB were accessed only via Session beans.

Based on my research(reference, forums, examples), I believe I have a very good head start (on code that is)...but the configuration is what I am struggling with...mainly the associations.

It doesn't look like that there any tools that I can find that would help out with the mapping (at least those that I can find).


Top
 Profile  
 
 Post subject: Re: Additional info
PostPosted: Mon Aug 22, 2005 3:19 pm 
Senior
Senior

Joined: Tue Aug 03, 2004 2:11 pm
Posts: 142
Location: Somerset
rdleeper wrote:
I forgot to mention that I already have a complete POJO domain model. The CMP Entity Beans were only for persistence to/from DB. Access to these EJB were accessed only via Session beans.


You are in exactly the same situation our project was in when we started. We had an OK domain model, and an OK database, not ideal, with some "strange" bits of design in parts, but essentially what we did was:

Use middlegen to create all the mapping files from the domain model. This will give you in reality a set up stub files that you will have to edit as follows:

put in the db field that maps to the equivalent field name in the class
put in the table name that maps to the class
tell it what the identity column is

Followed by a large amoutn of hand tweaking to get the associations right.

One of the biggest issues we had was all the collections in our domain model were lists not sets. We had to change all these as lists allow duplicates in which obviously is impossible to persist (unless you have an index column for each row in the list, which you are unlikely to have as its not very OO or obvious to put in when you aren't thinking of Hibernate when designing your domain model).

On a final note I can't recommend enough that you should buy "Hibernate in action", it really is worth every penny.

_________________
On the information super B road


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 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:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.