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 Guenther Wieser <gw...@creative-it.com> on 2005/02/16 21:20:32 UTC

problem with m:n relation to some class

hi,

i'm using ojb 1.0.1, and i need to implement a m:n relation ship from
objects of one class to objects of the same class.
before you complain that this is strange and can lead to circular
referencens, let me explain: i know that, but i need to implement this.
reason is: we want to use enhydra shark, a workflow engine, and it relies on
the capability of the data model that it can nest groups into groups, this
way building a hierarchy of groups.
here's the excerpt from repository.xml:

	<class-descriptor
		class="com.creative_it.webcreator.model.usergroup.Group"
		table="grouptable">
		<field-descriptor id="1" name="id" column="id"
			jdbc-type="BIGINT" primarykey="true" autoincrement="true" />
		<field-descriptor id="2" name="groupid" column="groupid"
			jdbc-type="VARCHAR" />
		<field-descriptor id="3" name="description" column="description"
			jdbc-type="VARCHAR" />
		<collection-descriptor name="users"
			collection-class="org.apache.ojb.broker.util.collections.ManageableArrayL
ist"
			element-class-ref="com.creative_it.webcreator.model.usergroup.User"
			auto-retrieve="true" auto-update="link" auto-delete="link"
			indirection-table="usergrouptable">
			<fk-pointing-to-this-class column="groupid" />
			<fk-pointing-to-element-class column="userid" />
		</collection-descriptor>
		<collection-descriptor name="subGroups"
			collection-class="org.apache.ojb.broker.util.collections.ManageableArrayL
ist"
			element-class-ref="com.creative_it.webcreator.model.usergroup.Group"
			auto-retrieve="true" auto-update="false" auto-delete="false"
			indirection-table="groupgrouptable">
			<fk-pointing-to-this-class column="groupid" />
			<fk-pointing-to-element-class column="sub_gid" />
		</collection-descriptor>
		<collection-descriptor name="parentGroups"
			collection-class="org.apache.ojb.broker.util.collections.ManageableArrayL
ist"
			element-class-ref="com.creative_it.webcreator.model.usergroup.Group"
			auto-retrieve="true" auto-update="false" auto-delete="false"
			indirection-table="groupgrouptable">
			<fk-pointing-to-this-class column="sub_gid" />
			<fk-pointing-to-element-class column="groupid" />
		</collection-descriptor>
	</class-descriptor>

my problem in detail is, that everything works fine when it comes to
creation and update, but when i delete a group, the entries in the
indirection table are not deleted. i tried all possibilities of auto-delete
and auto-update, so don't bother the "false" in this excerpt.

by the way, the user-group-relation (which is also a non-decomposed m:n
relation) works perfect, so i'm quite sure this is just a problem of
referencing the same class....

any idea how to solve this problem?

kr,
guenther



---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org