Hi Patrik,

Yup, that's what we tried.  We ran into a problem though.  Here's the
definition:

                Entity PropertyData {
                   - List<@PropertyItem> items fetch="join" cascade="all" 
inverse
                }
                
                ValueObject PropertyItem {
                        String stuff nullable
                }

When we did that, it created the correct one-to-many Hibernate mapping like
this:

<hibernate-mapping default-cascade="none" default-access="property"
default-lazy="true" auto-import="true">
        <class name="com.foo.PropertyData" table="OM_PROPERTY_DATA" 
mutable="true"
polymorphism="implicit" dynamic-update="false" dynamic-insert="false"
select-before-update="false" optimistic-lock="version">
                ...
                <list name="items" inverse="true" cascade="all" fetch="join" 
lazy="false"
mutable="true" optimistic-lock="true" embed-xml="true">
                        <key column="C_PROPERTY_DATA" on-delete="noaction"/>
                        <index column="C_ITEM_INDEX"/>
                        <one-to-many class="com.foo.PropertyItem" 
not-found="exception"
embed-xml="true"/>
                </list>
        </class>
</hibernate-mapping>


Then when we saved a PropertyData with PropertyItems, Hibernate created all
the PropertyData and PropertyItem records, but the C_PROPERTY_DATA foreign
key column in PropertyItem was null.  So when we retrieve the PropertyData
again, it does not have any PropertyItems attached to it.  Isn't "inverse"
in Hibernate only used for bi-directional relationships?  How does the
C_PROPERTY_DATA key get set?

Please let me know if I broke something or if we are doing something wrong.

Thanks!
--Polly


Patrik Nordwall wrote:
> 
> Do you need something like this, i.e. Moon doesn't refer back to Planet?
> 
> Entity Planet {
>    - @Set<Moon> moons
> }
> 
> Entity Moon {
> }
> 
> 
> This will result in a uni-directional many association, but will be
> implemented in the database as many-to-many.
> 
> To implement it with an ordinary foreign key in the child table you have
> to add inverse
> 
> Entity Planet {
>    - @Set<Moon> moons inverse
> }
> 
> Doc:
> http://www.fornax-platform.org/cp/display/fornax/3.+Advanced+Tutorial+(CSC)#3.AdvancedTutorial(CSC)-AdditionalReferenceFeatures
> 
> /Patrik
> 
> 

-- 
View this message in context: 
http://www.nabble.com/-Sculptor--uni-directional-one-to-many-mapping--tp21445883s17564p21461309.html
Sent from the Fornax-Platform mailing list archive at Nabble.com.


------------------------------------------------------------------------------
This SF.net email is sponsored by:
SourcForge Community
SourceForge wants to tell your story.
http://p.sf.net/sfu/sf-spreadtheword
_______________________________________________
Fornax-developer mailing list
Fornax-developer@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/fornax-developer

Reply via email to