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
|