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 BOUESSAY Christian <cb...@businessdecision.com> on 2004/12/21 18:10:09 UTC
[OJBDoclet] sequence + inheritance + anonymous key
Hi,
We're using a database sequence manager ; when we insert an object, the next value of sequence is found; but how could we get the value of id?
for instance:
/**
* @ojb.class table="TableA"
* determine-extents="false"
*/
Class A {
/**
* @ojb.field primarykey="true"
* autoincrement="database"
* sequence-name="mySeq"
*/
int id ;
String creator;
//...
}
/**
* @ojb.class table="tableB"
* include-inherited="false"
*
* @ojb.field name="id"
* jdbc-type="INTEGER"
* primarykey="true"
*
* @ojb.reference class-ref="....A"
* auto-retrieve="true"
* auto-update="true"
* auto-delete="true"
* foreignkey="id"
*/
Class B extends A {
String attr;
// ...
}
B obj = new B();
obj.setAttr("blabla...");
obj.store();
String id = obj.getId();
//-----------------> id is null, but maSeq.nextval was called ...
We found that access is set to "readonly" for A and "anonymous" for B in 'repository_user.xml'.
And we would like to set these values to "readwrite"; how to do it?
(the annotation access="readwrite" doesn't work with others parameters ...)
Thanks.
Christian BOUESSAY
Re: [OJBDoclet] sequence + inheritance + anonymous key
Posted by Nouguier Olivier <ol...@wanadoo.fr>.
Hi all,
As you put id as anonymous find the above behaviour is as expected ...
You should replace:
@ojb.class table="tableB" include-inherited="false"
by
@ojb.class table="tableB" include-inherited="true" ( default )
and add:
@ojb.modify-inherited ignore="true" name="XXXX"
for "XXXX" all inherited field but "id"
hih
On Tue, 2004-12-21 at 18:10 +0100, BOUESSAY Christian wrote:
> Hi,
>
> We're using a database sequence manager ; when we insert an object, the next value of sequence is found; but how could we get the value of id?
>
> for instance:
> /**
> * @ojb.class table="TableA"
> * determine-extents="false"
> */
> Class A {
> /**
> * @ojb.field primarykey="true"
> * autoincrement="database"
> * sequence-name="mySeq"
> */
> int id ;
>
> String creator;
> //...
> }
>
> /**
> * @ojb.class table="tableB"
> * include-inherited="false"
> *
> * @ojb.field name="id"
> * jdbc-type="INTEGER"
> * primarykey="true"
> *
> * @ojb.reference class-ref="....A"
> * auto-retrieve="true"
> * auto-update="true"
> * auto-delete="true"
> * foreignkey="id"
> */
> Class B extends A {
> String attr;
> // ...
> }
>
>
> B obj = new B();
> obj.setAttr("blabla...");
> obj.store();
>
> String id = obj.getId();
>
> //-----------------> id is null, but maSeq.nextval was called ...
>
>
> We found that access is set to "readonly" for A and "anonymous" for B in 'repository_user.xml'.
> And we would like to set these values to "readwrite"; how to do it?
> (the annotation access="readwrite" doesn't work with others parameters ...)
>
> Thanks.
>
> Christian BOUESSAY
>
--
Nouguier Olivier <ol...@wanadoo.fr>
---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org
sequence + inheritance + anonymous key
Posted by Nouguier Olivier <ol...@wanadoo.fr>.
Hi look thread:
http://www.mail-archive.com/ojb-user@db.apache.org/msg10447.html
---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org
Re: [OJBDoclet] sequence + inheritance + anonymous key
Posted by Nouguier Olivier <ol...@wanadoo.fr>.
Hi
http://www.mail-archive.com/ojb-user@db.apache.org/msg10447.html
On Tue, 2004-12-21 at 18:10 +0100, BOUESSAY Christian wrote:
> Hi,
>
> We're using a database sequence manager ; when we insert an object, the next value of sequence is found; but how could we get the value of id?
>
> for instance:
> /**
> * @ojb.class table="TableA"
> * determine-extents="false"
> */
> Class A {
> /**
> * @ojb.field primarykey="true"
> * autoincrement="database"
> * sequence-name="mySeq"
> */
> int id ;
>
> String creator;
> //...
> }
>
> /**
> * @ojb.class table="tableB"
> * include-inherited="false"
> *
> * @ojb.field name="id"
> * jdbc-type="INTEGER"
> * primarykey="true"
> *
> * @ojb.reference class-ref="....A"
> * auto-retrieve="true"
> * auto-update="true"
> * auto-delete="true"
> * foreignkey="id"
> */
> Class B extends A {
> String attr;
> // ...
> }
>
>
> B obj = new B();
> obj.setAttr("blabla...");
> obj.store();
>
> String id = obj.getId();
>
> //-----------------> id is null, but maSeq.nextval was called ...
>
>
> We found that access is set to "readonly" for A and "anonymous" for B in 'repository_user.xml'.
> And we would like to set these values to "readwrite"; how to do it?
> (the annotation access="readwrite" doesn't work with others parameters ...)
>
> Thanks.
>
> Christian BOUESSAY
>
--
Nouguier Olivier <ol...@wanadoo.fr>
---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org