File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

get generated key

 
riccardo alfrilli
Greenhorn
Posts: 16
  • 0
  • 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
  • 0
  • 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
  • 0
  • 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
  • 0
  • 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!
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic