You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ojb-user@db.apache.org by "Janssen, Roger" <Ro...@ibanx.nl> on 2003/05/15 15:54:57 UTC
[BUG 1.0.rc3 / PB API] storing object removes all related items i
n indirection table
hi,
i'm noticing the following weird behaviour (ojb1.0.rc3 / PB API).
i have a class Organization, and a class Role, both are stored
in different tables, table_org and table_role. they are linked
using an indirection-table; table_org_role.
so relationally we have got:
table_org table_org_role table_role
id <----> org_id
role_id <------> id
looking at the object Organization, it has a collection that will
be used to autoretrieve the roles in.
i also modelled the data stored in the indirection-table,
OrganizationRoleMapping.
i use these objects to create/delete the mappings explicitely myself, not
letting ojb do the work. the Organization object also has a collection
that will hold all the OrgRoleMapping objects.
the class descriptor of Organization contains:
<collection-descriptor
name="roles"
element-class-ref="ibanx.org.Role"
auto-retrieve="true"
auto-update="false"
auto-delete="false"
indirection-table="TABLE_ORG_ROLE"
>
<fk-pointing-to-this-class column="ORG_ID"/>
<fk-pointing-to-element-class column="ROLE_ID"/>
</collection-descriptor>
<collection-descriptor name="organizationRoleMappings"
element-class-ref="ibanx.org.OrganizationRoleMapping"
auto-retrieve="true"
auto-update="false"
auto-delete="false"
>
<inverse-foreignkey field-ref="orgId"/>
</collection-descriptor>
the problem:
now, when i create a new organization (or modify an existing one) i create
OrganizationRoleMapping mappings and store them explicity. the 'roles'
collection on the Organization stays empty (null). using ojb (PB API) to
store the object, i observe that first the OrganizationRoleMapping's are
stored (by our explixit code), the the OrganizationRoleMapping object
itself is stored, but then a delete query is executed to delete all
OrganizationRoleMapping related to the just created Organization!!!
sqltrace excerpt:
1053004657565|0|0|statement|DELETE FROM TABLE_ORG_ROLE WHERE
ORG_ID=?|DELETE FROM TABLE_ORG_ROLE WHERE ORG_ID='11281'
This deletes all my just created mappings.
Removing this part from the class descriptor;
<collection-descriptor
name="roles"
element-class-ref="ibanx.org.Role"
auto-retrieve="true"
auto-update="false"
auto-delete="false"
indirection-table="TABLE_ORG_ROLE"
>
<fk-pointing-to-this-class column="ORG_ID"/>
<fk-pointing-to-element-class column="ROLE_ID"/>
</collection-descriptor>
results in correct behaviour, but as soon as i define this
collection descriptor, i'm in trouble (even with auto retrieve
to true).
Some more testing with various configs leads me to conclude that using an
indirection-mapping as above, store the object containing the mapping
always results in deleting all mappings!
my guess is that this is not what is supposed to happen!
using ODMG api, there is no problem!
can anybody confirm this?
roger janssen
iBanx
*************************************************************************
The information contained in this communication is confidential and is
intended solely for the use of the individual or entity to whom it is
addressed.You should not copy, disclose or distribute this communication
without the authority of iBanx bv. iBanx bv is neither liable for
the proper and complete transmission of the information has been maintained
nor that the communication is free of viruses, interceptions or interference.
If you are not the intended recipient of this communication please return
the communication to the sender and delete and destroy all copies.