Logo 
Search:

Java Answers

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds
  Question Asked By: Trupti Patil   on Dec 24 In Java Category.

  
Question Answered By: Silvia Chapman   on Dec 24

first before closing EM try to flush it by calling this.manager.flush()
second, where do you create your entity User? in other words, if you
create the user  entity once, this is considered a already attached
entity.
I think you should create User each time you are going to persist

em.beginTransaction()
User user = new User() //this line is between begin transaction and commit
user.setId(10L);
...
em.persist(user);

em.commit();

if you're not sure whether this user is a new user or an already
persisted user then I recommend you to use user = em.merge(user);
instead, this is usually happens when you pass your entity through a
method argument.

Share: 

 

This Question has 8 more answer(s). View Complete Question Thread

 
Didn't find what you were looking for? Find more on toplink/jpa problem Or get search suggestion and latest updates.


Tagged: