Re: JDO and associations (1:n, m:n)

2004-01-25 Thread Hubert Behaghel
Hi Thomas,

Thank you for your answer, here is my XML ClassDescriptor :

--







































 









As you can see, these are the class descriptors of the application I
spoke about in my last post.

I hope you'll find something wrong (but in fact, because I read that for
JDO all the auto- attributed have to be kept as default, I don't
mention them in my repository_user.xml).

Thank you again.

--
Hubert


Le samedi 24 janvier 2004 à 12h11, Thomas Mahler a écrit :
> Hi Hubert,
> 
> Please post the xml ClassDescriptors of your classes. I could imagine 
> that there is some trouble with the auto-update attributes of your 
> reference- and/or collection-descriptors
> 
> Thomas
> 
> Hubert Behaghel wrote:
> >Hi there,
> >
> >I am trying to make a miniframework with OJB, based on its JDO plugin,
> >so has to have business classes being persistent (almost transparently)
> >and having a small application letting the user play with those
> >persistent classes while viewing the state of the DB. (To be clear I try
> >to have a very simple code for pedagogical purpose : this is like
> >tutorial5 except that the class isn't Product but a set of classes
> >generated from an UML diagram).
> >
> >All the basical operations work well but one : I can list, delete,
> >insert objects but I cannot edit them... More precisely I can't edit
> >them when they have references to other persistent objects.
> >
> >How do I proceed to edit one object ? I tried many ways :)
> >
> >First, my idea was to ask the user the id of the object (or everything
> >which let me identify the one he wants), to get it from the database,
> >and to modify a copy of it. Then when this is done, I begin a
> >transaction, copy all the fields from the up-to-date copy to the
> >original persistent instance (even the unmodified fiels) and commit. The
> >problem is : the instance itself is updated correctly but the references
> >are attempted to be reinserted automatically (even if unmodified)
> >causing the database to reject it. As a matter of fact, those references
> >have already been inserted so inserted them again is impossible : they
> >share the same primary key (id).
> >
> >The second idea was to simply delete and then insert the copy after
> >giving it the id of the deleted object. Here I got a JDOUserException
> >for trying to insert an object with a key that already exist in the
> >Persistence Manager cache... (does it means that JDO has got its own
> >cache ? is this cache unable to "see" that the object was deleted just
> >before ?)
> >
> >Then, I tried the tutorial-like way : that is to say to begin a
> >transaction, get the object after getting the id from the user, let the
> >user do what he wants with its fields and commit. This time, I got the
> >same error as in the first procedure but quicker (so, is it a progress ?
> >;) ) : in fact, when I reach the commit, the first thing that happen is
> >that my persistent layer wants to insert the references that my instance
> >has, but as ever, because they already are in the datastore, it is
> >impossible...
> >
> >So what ? Give up with editing what I stored and simply show how to
> >insert and delete ? :)
> >
> >Thank you in advance.
> >
> >--
> >Hubert
> >
> >-
> >To unsubscribe, e-mail: [EMAIL PROTECTED]
> >For additional commands, e-mail: [EMAIL PROTECTED]
> >
> >
> 
> 
> -
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: JDO and associations (1:n, m:n)

2004-01-24 Thread Thomas Mahler
Hi Hubert,

Please post the xml ClassDescriptors of your classes. I could imagine 
that there is some trouble with the auto-update attributes of your 
reference- and/or collection-descriptors

Thomas

Hubert Behaghel wrote:
Hi there,

I am trying to make a miniframework with OJB, based on its JDO plugin,
so has to have business classes being persistent (almost transparently)
and having a small application letting the user play with those
persistent classes while viewing the state of the DB. (To be clear I try
to have a very simple code for pedagogical purpose : this is like
tutorial5 except that the class isn't Product but a set of classes
generated from an UML diagram).
All the basical operations work well but one : I can list, delete,
insert objects but I cannot edit them... More precisely I can't edit
them when they have references to other persistent objects.
How do I proceed to edit one object ? I tried many ways :)

First, my idea was to ask the user the id of the object (or everything
which let me identify the one he wants), to get it from the database,
and to modify a copy of it. Then when this is done, I begin a
transaction, copy all the fields from the up-to-date copy to the
original persistent instance (even the unmodified fiels) and commit. The
problem is : the instance itself is updated correctly but the references
are attempted to be reinserted automatically (even if unmodified)
causing the database to reject it. As a matter of fact, those references
have already been inserted so inserted them again is impossible : they
share the same primary key (id).
The second idea was to simply delete and then insert the copy after
giving it the id of the deleted object. Here I got a JDOUserException
for trying to insert an object with a key that already exist in the
Persistence Manager cache... (does it means that JDO has got its own
cache ? is this cache unable to "see" that the object was deleted just
before ?)
Then, I tried the tutorial-like way : that is to say to begin a
transaction, get the object after getting the id from the user, let the
user do what he wants with its fields and commit. This time, I got the
same error as in the first procedure but quicker (so, is it a progress ?
;) ) : in fact, when I reach the commit, the first thing that happen is
that my persistent layer wants to insert the references that my instance
has, but as ever, because they already are in the datastore, it is
impossible...
So what ? Give up with editing what I stored and simply show how to
insert and delete ? :)
Thank you in advance.

--
Hubert
-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


JDO and associations (1:n, m:n)

2004-01-22 Thread Hubert Behaghel
Hi there,

I am trying to make a miniframework with OJB, based on its JDO plugin,
so has to have business classes being persistent (almost transparently)
and having a small application letting the user play with those
persistent classes while viewing the state of the DB. (To be clear I try
to have a very simple code for pedagogical purpose : this is like
tutorial5 except that the class isn't Product but a set of classes
generated from an UML diagram).

All the basical operations work well but one : I can list, delete,
insert objects but I cannot edit them... More precisely I can't edit
them when they have references to other persistent objects.

How do I proceed to edit one object ? I tried many ways :)

First, my idea was to ask the user the id of the object (or everything
which let me identify the one he wants), to get it from the database,
and to modify a copy of it. Then when this is done, I begin a
transaction, copy all the fields from the up-to-date copy to the
original persistent instance (even the unmodified fiels) and commit. The
problem is : the instance itself is updated correctly but the references
are attempted to be reinserted automatically (even if unmodified)
causing the database to reject it. As a matter of fact, those references
have already been inserted so inserted them again is impossible : they
share the same primary key (id).

The second idea was to simply delete and then insert the copy after
giving it the id of the deleted object. Here I got a JDOUserException
for trying to insert an object with a key that already exist in the
Persistence Manager cache... (does it means that JDO has got its own
cache ? is this cache unable to "see" that the object was deleted just
before ?)

Then, I tried the tutorial-like way : that is to say to begin a
transaction, get the object after getting the id from the user, let the
user do what he wants with its fields and commit. This time, I got the
same error as in the first procedure but quicker (so, is it a progress ?
;) ) : in fact, when I reach the commit, the first thing that happen is
that my persistent layer wants to insert the references that my instance
has, but as ever, because they already are in the datastore, it is
impossible...

So what ? Give up with editing what I stored and simply show how to
insert and delete ? :)

Thank you in advance.

--
Hubert

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]