From: Marco P. <mp...@cm...> - 2002-04-16 09:46:53
|
Gavin, > the key column of the many-valued end must match the column of > the single-valued end. Hope that makes sense..... To summarize - A client has multiple orders and an order has only one client -- - Client class has a clientId - Order class a orderID - At this moment i see a referral from the many-valued site (Order) to the one site (Client) <many-to-one name="Client" column="clientId" class="com.mticket.Client"/> but the referal from the single-value, is not yet clear.. <set role="besteld" readonly="true"> --> makes sense! <key column="clientId"/> --> Is this the key column you mentioned ? Why does this refer to the clientId, looks like a self-referal! <one-to-many class="com.mticket.Order"/> --> makes sense! </set> Do i need to have other property things in my classes to hold the correct referals? Ath this moment i only have the getter ans setter methods mentioned as properties in the mapping files.. Again a lot of questions ;-) Greetings, Marco On Tue, 16 Apr 2002 Gavin_King/Cirrus%CI...@ci... wrote: > > > Hi Marco. Try the following: > > <hibernate-mapping> > <class name="com.mticket.Client" table="Client"> > <id name="clientId" type="long"> > <generator class="cirrus.hibernate.id.HiLoGenerator"/> > </id> > <property name="name"/> > > <set role="besteld" readonly="true"> > <key column="clientId"/> > <one-to-many class="com.mticket.Order"/> > </set> > </class> > > <class name="com.mticket.Order" table="order"> > <id name="orderid" type="long"> > <generator class="cirrus.hibernate.id.HiLoGenerator"/> > </id> > <property name="description"/> > <many-to-one name="Client" column="clientId" class > ="com.mticket.Client"/> > </class> > </hibernate-mapping> > > > For a bidirectional association, one (many-valued) end must be marked > read-only, telling hibernate to use the other end for updating persistent > state. Also the key column of the many-valued end must match the column of > the single-valued end. Hope that makes sense.... > > peace > > Gavin > |