[hibernate-dev] Question regarding one-to-one forumla support.

Wei Gao wgao at packetmotion.com
Mon Mar 5 20:19:36 EST 2007


Hi There,

 

I have a question about one-to-one formula.

 

Let's say I have domain object and container (org uint) object. Domain
has list of containers, but only one is rootContainer. So domain to
rootContainer is one-to-one mapping base on container.parent is null. So
I'm using one-to-one with formula for this purpose.

 

<class name="Domain" ...>

  <id name"id" type="long">

     <generator class="native"/>

  </id>

  <one-to-one name="rootContainer" class="Container"
property-ref="rootContainer">

    <formula>id</formula>

    <formula>null</formula>

  </one-to-one>

</class>

<class name="Container" ...>

  <id name"id" type="long">

     <generator class="native"/>

  </id>

  <propperties name"rootContainer" >

     <many-to-one name="domain" class="Domain">

       <column name="domainid"/>

     </many-to-one>

     <many-to-one name="parent" class="Container">

       <column name="parentid"/>

     </many-to-one>

  </properties>

  <set name="children" inverse="true">

     <key column="parentid"/>

     <one-to-many class="Container" />

  </set>

</class>

 

I know it doesn't work, my question is: for two formulas, how can I set
domain object for first formula parameter? How can I set null object
reference as second formula parameter instead of "null" string?

 

Any hint will be highly appreciated.

 

Thanks

 

Wei

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/hibernate-dev/attachments/20070305/033b7aed/attachment.html 


More information about the hibernate-dev mailing list