-->
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.  [ 2 posts ] 
Author Message
 Post subject: composite BO object X maps to multiple tables...
PostPosted: Mon May 24, 2004 9:13 am 
Newbie

Joined: Mon May 24, 2004 3:22 am
Posts: 1
Hello everybody

I have following case. I have BO objects already designed and a database already designed. Both cannot change.
Now I want to map my business object with tables in the database. Here is an example of what I have.


Following tables exist

DB
==
Table Y
Field a
Field b
Field c

Table Z
Field d
Field e
Field f

The tables relate one-to-one (a=d).

Now I have my business object myBO which contains following data:

myBO {
a
b
c
d
e
}


So what I want is a mapping for myBO wich maps a,b,c to DB-Table A and d,e mapping to DB-Table B and in such a way that,

myBO mapping does not relate to or represents a Table "myBO" in the database. The only thing I know is that the Table.A.a=Table.B.b is a valid one-to-one join. I am not allowed to create a new table in the database called "myBO" in wich somekind of id is stored.

I have gone though the examples. I have tried it in several ways, inheritance and component mapping. I have found out that a component mapping could be OK for me, and indeed it works but with the creation of a Table "myBO" filled with keys.

So what I want is,
a "myBO" in java which I have to give a mapping, to be able to work with it in hibernate, where I do not want to make this "myBO" persistent to any Table, because it exists only of elements of other persistant objects. The question to you: Can I do this in hibernate? If so, How does the mapping look like? Thank you very much in advance for any information by working with the same problem or already solving this particular problem.


The example,
I can give is the auction example delivered with hibernate. Here the object AuctionInfo I also want to make persistant to both instances AuctionItem and Bid. AuctionInfo does not have any properties to be stored itself, so there is no need for a Table of AuctionInfo. Here is the mapping I could see as valid, but does not work because Hibernate does create a table AuctionInfo with data in there, representing the join....


<hibernate-mapping package="org.hibernate.auction">

<!-- you see, no id here because it simply does not exist. -->

<class name="AuctionInfo" >
<component name="ItemPart" class="org.hibernate.auction.AuctionItem">
<property name="description"/>
<property name="ends"/>
</component>

<component name="BitPart" class="org.hibernate.auction.Bid">
<many-to-one name="successfulBid" outer-join="false"/>
</component>
<property name="condition"/>
</class>

</hibernate-mapping>



Marcel


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 25, 2004 12:02 pm 
Expert
Expert

Joined: Thu Sep 04, 2003 8:23 am
Posts: 368
I think that mapping one object to multiple tables will be possible in hibernate3.
In your case can't you map myBO to table Y and define a component just for table Z ?

seb


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