Hi

I'm using JPA in my application. Yesterday I tried to delete some Entities 
with a same class in one transaction, but I got an exception which said 
that I can not do this in one transaction as they are in a different entity 
group. I thought If I persist two entities with the same class they will be 
in the same entity group, but now I know that they won't. 

The question is how can I persist two entities to be in the same group? 

My  entity looks like this:
@Entity
public class SomeEntity {

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
protected Key key;

}

When I persist them the key is set automatically:
entityManager.persist(someEntityObject);

Deleting them:
... EntityManager em;
... List<SomeEntity> toDelete;
EntityTransaction tx = em.getTransaction();
try {
tx.begin();

for (SomeEntity entity : toDelete) {

em.remove(entity);

} 

tx.commit();
} finally {
if (tx.isActive()) {
tx.rollback();
}
em.close();
}
I saw somehow I can set a parent key to the keys but I think in this way 
I'll loose the automatic id generation.
Is there a good way to resolve this problem?

Thanks,
Peter

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/google-appengine/-/Dd9uTFlIPYMJ.
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-appengine?hl=en.

Reply via email to