db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Brian McCallister <mccallis...@forthillcompany.com>
Subject Re: M:N same class mapping question...
Date Mon, 13 Oct 2003 02:40:33 GMT
Note that the package names *do* match in the actual code - Changed the 
one in place in the email and not the other =)

-Brian

On Sunday, October 12, 2003, at 10:38 PM, Brian McCallister wrote:

> I am having problems getting a class to properly persist collections 
> of instances of the same class (see configs later in the email). Using 
> the M:N mapping seems to be the way to do this, but it isn't actually 
> working. If the relations exist in the database the data loads fine, 
> however it doesn't seem to want to persist new instances to the M:N 
> table. I am using the non-decomposed style M:N and have tried with the 
> mapping listed below, and the auto-update and auto-retrieve removed 
> with no change in behavior.
>
> Anyone see what is wrong with the code below?
>
> -- OJB Mapping ---
>
> <class-descriptor class="test.User" table="USERS">
>     <field-descriptor name="id" column="ID" jdbc-type="INTEGER" 
> primarykey="true" autoincrement="true"/>
>
>     <collection-descriptor name="friends" 
> element-class-ref="org.skife.kim.model.User"
>         indirection-table="USER_FRIEND"
>         auto-retrieve="true"
>         auto-update="true"
>         >
>         <fk-pointing-to-this-class column="user_id"/>
>         <fk-pointing-to-element-class column="friend_id"/>
>     </collection-descriptor>
> </class-descriptor>
>
> -- Schema Def'n --
>
>     <table name="user_friend" description="M:N mapping table for 
> user's friends">
>         <column name="user_id" primaryKey="true" type="INTEGER" 
> description="User ID" />
>         <column name="friend_id" primaryKey="true" type="INTEGER" 
> description="User ID" />
>
>         <foreign-key foreignTable="users">
>             <reference local="user_id" foreign="id"/>
>         </foreign-key>
>         <foreign-key foreignTable="users">
>             <reference local="friend_id" foreign="id"/>
>         </foreign-key>
>     </table>
>
> -- Class --
>
> public class User
> {
> 	List friends;
> }
>
> Friends contains User instances. It seems that it loads classes 
> properly if they are already in the database, but is not inserting new 
> relations.
>
> Danke,
> Brian
>


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


Mime
View raw message