two table reference one table with one-to-many throws an error

0 views
Skip to first unread message

Daniel

unread,
Sep 21, 2009, 12:57:45 PM9/21/09
to transfer-dev
I have two table entites which have a one-to-many relationship to an
image table. Both are used to attach several pictures to them. Both
using the same reference field 'img_ref_uuid' in the image table.

It works well for ONE one-to-many realtionship. When I use iSECOND
one-to-many realtioshiop and try to save it, I get an error.

"Error Type: Database : 42000
Error Messages: Error Executing Database Query.
Column 'img_ref_uuid' specified twice"

in variables.transfer.save(imgBean);

The funny thing IS: It's DOES SAVE correctly to the database. It get
the images as an array in the object whe I read the the object with
transfer...


Since it seems to work properly by saving it to the database in the
background, It's strange to get this error message. Maybe I miss here
something or is it a bug?

<object name="branch" table="branch"
decorator="com.baehler.branch.branch">
<id name="branch_id" type="UUID" generate="true" />
<property name="branch_label" type="string" column="branch_label"
nullable="true" />
...
<onetomany name="branchimage">
<link to="asset.image" column="img_ref_uuid"/>
<collection type="array">
<order property="img_created"/>
</collection>
</onetomany>
</object>

<object name="product" table="product"
decorator="com.baehler.product.product">
<id name="prd_id" column="prd_id" type="UUID" generate="true" />
<property name="prd_name" type="string" column="prd_bezeichnung"
nullable="false" />
....
<onetomany name="productimage">
<link to="asset.image" column="img_ref_uuid"/>
<collection type="array">
<order property="img_created"/>
</collection>
</onetomany>
</object>

<object name="image" table="image"
decorator="com.baehler.asset.image">
<id name="img_id" type="UUID" generate="true"/>
<property name="img_src" type="string" column="img_src"
nullable="false" />
<property name="img_height" type="numeric" column="img_height"
nullable="true" />
<property name="img_width" type="numeric" column="img_width"
nullable="true" />
<property name="img_size" type="numeric" column="img_size"
nullable="true" />
<property name="img_type" type="string" column="img_type"
nullable="false" />
<property name="img_caption" type="string" column="img_caption"
nullable="true" />
<property name="img_created" type="date" column="img_created" ignore-
insert="true" ignore-update="true"/>
<property name="img_updated" type="date" column="img_updated"
nullable="true" />
<property name="img_tn" type="string" column="img_tn"
nullable="true" />
</object>

Daniel

Mark Mandel

unread,
Sep 21, 2009, 10:53:40 PM9/21/09
to transf...@googlegroups.com
You can only have one relationship per foreign key - otherwise how is Transfer meant to know which relationship to save on?

Mark
--
E: mark....@gmail.com
T: http://www.twitter.com/neurotic
W: www.compoundtheory.com

Reply all
Reply to author
Forward
0 new messages