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 "Kollivakkam R. Raghavan" <rk...@cisco.com> on 2003/12/17 19:07:10 UTC
Anonymous keys
I have a situation where I have a 1-n relation between a group and its
members. The members are created independently and get assigned to a
group later (hence the null group id in member). I have the matching
reference descriptor to the Group class in Member and a collection
descriptor for the Members in the group.
Table Member
(
id int primary key
name varchar(32) not null
group_id int,
foreign key group_id references group(id)
)
Table Group
(
id int primary key
name varchar(32)
...
)
Here's the problem:
When I add a member to the table with no group object reference, it sets
the group_id field to 0 (which is not correct - I want it to be null).
In order to get around this, I set the access="anonymous" attribute on
the reference descriptor as well as the primary keys and was able to get
the null into the group id like I wanted but after the insert of the
member instance no longer has the new primary key (which is set to
autoincrement using HiLow Seq. manager) field set which is a problem.
It seems that I have a problem whichever method I choose. Is this true,
or am I doing something wrong? Seems like a pretty basic thing to me so
I'm sure the problem is on my side.
I'm using rc4 and HSQL
Thanks
Raghavan
---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org
Re: Anonymous keys
Posted by Armin Waibel <ar...@code-au-lait.de>.
Hi Raghaven,
don't use primitve types for FK, PK fields in your pc classes if you do
(null/0 problem).
Think you can't use anonymous access for group_id field-descriptor,
because Member ask for group_id values.
regards,
Armin
Kollivakkam R. Raghavan wrote:
> I have a situation where I have a 1-n relation between a group and its
> members. The members are created independently and get assigned to a
> group later (hence the null group id in member). I have the matching
> reference descriptor to the Group class in Member and a collection
> descriptor for the Members in the group.
>
> Table Member
> (
> id int primary key
> name varchar(32) not null
> group_id int,
> foreign key group_id references group(id)
> )
>
> Table Group
> (
> id int primary key
> name varchar(32)
> ...
> )
>
>
> Here's the problem:
> When I add a member to the table with no group object reference, it sets
> the group_id field to 0 (which is not correct - I want it to be null).
> In order to get around this, I set the access="anonymous" attribute on
> the reference descriptor as well as the primary keys and was able to get
> the null into the group id like I wanted but after the insert of the
> member instance no longer has the new primary key (which is set to
> autoincrement using HiLow Seq. manager) field set which is a problem.
> It seems that I have a problem whichever method I choose. Is this true,
> or am I doing something wrong? Seems like a pretty basic thing to me so
> I'm sure the problem is on my side.
>
> I'm using rc4 and HSQL
>
> Thanks
> Raghavan
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-user-help@db.apache.org
>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org