-->
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: Problem with mapping of one table to multiple objects?
PostPosted: Thu Feb 26, 2004 4:49 am 
Newbie

Joined: Thu Feb 26, 2004 4:31 am
Posts: 3
Hi..

Is it possible to map multiple objects to one table?
I tried it and it gave me wrong objects! :-/

I have 1 table, which is modelled by 2 different objects.
Reason for this is that the 2nd object hold large BLOB data, so I'd like to keep them separate
for performance reasons.


My XML is something like this


<hibernate-mapping>
<class name="com.nic.interx.model.Broadcast" table="BROADCASTS">
<id name="id" column="ID" type="integer">
<generator class="sequence">
<param name="sequence">GEN_BROADCAST</param>
</generator>
</id>
<property name="name" column="NAME" type="string"/>
<property name="totalCount" column="TOTAL_COUNT" type="integer"/>
<property name="description" column="DESCRIPTION" type="string"/>
</class>

<class name="com.nic.interx.model.BroadcastTemplate" table="BROADCASTS">
<id name="id" column="ID" type="integer">
<generator class="assigned"/>
</id>
<property name="data" column="BROADCAST_TEMPLATE"
type="com.nic.hibernate.types.BinaryType"/>
</class>
</hibernate-mapping>



As for my query..

Broadcast bc = (Broadcast)session.load( Broadcast.class, broadcastId);
BroadcastTemplate bct = (BroadcastTemplate)session.load( BroadcastTemplate.class, broadcastId);

Since Broadcast and BroadcastTemplate shares the same primary key ID, and table,
Hibernate seems to be confused and actually returned me a Broadcast object in the 2nd query.
(It should be returning BroadcastTemplate object instead)


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 26, 2004 8:28 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
There is a rule : 1 row = 1 object max in session
http://www.hibernate.org/41.html

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 26, 2004 8:32 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
There is a rule : 1 row = 1 object max in session
http://www.hibernate.org/41.html

_________________
Emmanuel


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.