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.  [ 3 posts ] 
Author Message
 Post subject: Persistence two beans in the same table
PostPosted: Fri Feb 24, 2006 5:25 pm 
Newbie

Joined: Fri Feb 24, 2006 5:18 pm
Posts: 2
hi,

I want to know if is possible to persist two beans of differents classes in the same table with hibernate and how can I do it.

regards,

Jose


Top
 Profile  
 
 Post subject: Re: Persistence two beans in the same table
PostPosted: Sun Feb 26, 2006 2:53 pm 
Newbie

Joined: Tue Jan 25, 2005 3:03 am
Posts: 11
Location: Bangalore, India
Hi,

Could you be a bit more elaborate ? For starters, is it the case that your table has, say (m + n) columns, and you want to represent it using two different beans having properties corresponding to the m and n columns, respectively ?

It would be great if you could provide a little background here, since your requirement seems interesting.

_________________
Rgds,
Vikas.

"Quidquid latine dictum sit, altum sonatur".
Whatever is said in Latin, sounds profound


Top
 Profile  
 
 Post subject:
PostPosted: Mon Feb 27, 2006 4:30 pm 
Newbie

Joined: Fri Dec 23, 2005 1:18 pm
Posts: 7
You can set a discriminator in your mapping file, related to a column in the table.
That let's you to create a superclass, and then, creates many classes (each one which a value of the discriminator column) that extends the superclass. Hibernate will manage the differents subclasses instances depending the value of the discriminator column.
For example, if you choose the column "id_type" as the discriminator column in a table Documents corresponding with class Document, and subclass Note (extending Document) when the discriminator is equals to 1, when you try to load a Document with id_type = 1, hibernate will return a Note instance. And when you try to save a Note instance, hibernate will save a register in the Documents table with id_type = 1. Each subclass of Document can have its owns properties.

For more information, read hibernate documentation.


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