Hi together,

i have a little problem with the key-class.
I have two Entities which are linked (OneToOne):

@Entity
public class Coding{

        @OneToOne(cascade=CascadeType.ALL)
        protected Category category;
...


@Entity
public class Category {

        @Id
        @GeneratedValue(strategy=GenerationType.IDENTITY)
        private Key id;
.....

For interact with the Client i transform the EntityClasses in DTOs (in
general i replaces the Key id field to a Long Field). When i now
create such a DTO on client Side, i transform the DTO back to an
Entity, while i am generating the Key Class:

(i generate the Coding-DTO to an Coding-Entity and therefor i convert
here the Category-DTO to an Category-Entity)
i reCreate the KeyClass with the long value:

key=KeyFactory.createKey(Category.class.getSimpleName(), catDTO.id);

in general this works (e.g to edit an Coding-Entity this works fine
because JPA recognize after conversion (DTO->Entity) over the
generated Key Object that the Entity exists) But in this case, the
converted "Category"Entity (which HAVE a Key with the existing ID), is
created as an new Entity while persists (and get a new Key-ID)

I cann just guess, that the cascade type is the reason ("@OneToOne
(cascade=CascadeType.ALL") but with another cascadetype the commit
crashes..

Hope the problem becomes clear, and someone have an idea.

thanks a lot
Dom

-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.

Reply via email to