-->
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.  [ 4 posts ] 
Author Message
 Post subject: Two Java Classes || Same database table
PostPosted: Mon Mar 15, 2010 11:47 am 
Newbie

Joined: Thu Jan 21, 2010 3:20 pm
Posts: 17
Hi ,

We are introducing Hibernate in an existing application.
I would like to map two existing beans in the current java application to one database table. One of the fields in these two tables are same. Is there a way to do this ?

Regards,
lrow

Note:- I already went through couple of suggestions in this link, but my case is slightly different
viewtopic.php?f=1&t=984333&start=15


Top
 Profile  
 
 Post subject: Re: Two Java Classes || Same database table
PostPosted: Tue Mar 16, 2010 4:16 pm 
Newbie

Joined: Thu Jan 21, 2010 3:20 pm
Posts: 17
Any pointers ??


Top
 Profile  
 
 Post subject: Re: Two Java Classes || Same database table
PostPosted: Tue Mar 16, 2010 10:56 pm 
Newbie

Joined: Tue Mar 16, 2010 10:39 pm
Posts: 1
I am new here. I just go over this thread. Nice topic!!!
But now I can not find out the answer.
__________________
http://spacequadrat.de


Top
 Profile  
 
 Post subject: Re: Two Java Classes || Same database table
PostPosted: Wed Mar 17, 2010 12:24 pm 
Newbie

Joined: Thu Jan 21, 2010 3:20 pm
Posts: 17
Okay. I found a temporary solution to do this with littlle manual work for now .

Steps
[*] Classes have Commonfield called "commonNumber"
[*] Let one class say "Thing" embeds the other "ThingDetail" class .
[*] Map the variable commonNumber of Thing to database using Anotations [ hibernate 3.2 , 3.0 ]
[*] Declare the commonNumber present in ThingDetails as "@Transient"
[*] Note:- Whenever thingDetail data is returned to other layers from DAO , manually populate it though Thing class and send out . Example


Thing thing = (Thing) query.uniqueResult();
ThingDetails thingDetails = thing.getThingDetails();
thingDetails.setCommonNumber(thing.getCommonNumber());


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