This week's book giveaways are in the Refactoring and Agile forums.
We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

get generated key

 
riccardo alfrilli
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi again!
The EntityManager.persist(EntityBean) method doesn't return the generated Id value by the Database...how can i obtain it?

public void create(Tbcustomer tbcustomer) {
em.persist(tbcustomer);
}

I'll try to implements a query or use annotations like @GeneratedValue...
Somebody can help me?
 
Bill Shirley
Ranch Hand
Posts: 457
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It sets the value (or values) in the object you passed it.

 
riccardo alfrilli
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tnx for reply!unfortuntely i have an exception,here is my code:


Maybe the @GeneratedValue annotation is wrong(I try also @GeneratedValue(strategy=TABLE),@GeneratedValue(strategy=IDENTITY))
 
riccardo alfrilli
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok,now it's work...I have to set the id(that was an Integer) with initial value of null,not 0!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic