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

hibernate to JPA: generator class=increment

 
David Balažic
Ranch Hand
Posts: 96
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi!

Can the following mapping be migrated from hibernate to JPA?


That is with minimum other changes?

Currently I try

But it gives this error when trying to persis an object:


Regards,
David
 
Prabhat Jha
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Add how the value will be generated.

Like
 
David Balažic
Ranch Hand
Posts: 96
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
GenerationType has no value for "increment".
 
Prabhat Jha
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am not sure i got what you meant? Can you elaborate please ?
 
David Balažic
Ranch Hand
Posts: 96
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I guess I did not understand you.

What did you mean by "Add how the value will be generated. " ?

In old project it was created automatically by hibernate.

How to have the same with JPA?
 
David Balažic
Ranch Hand
Posts: 96
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
David Balažic wrote:Hi!

Can the following mapping be migrated from hibernate to JPA?


OK, a coworker found the solution:



In case anyone else asks the same question...


Regards,
David
 
Michael Knoke
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the solution. However, I note that going this way requires me to add the import for GenericGenerator which is: org.hibernate.annotations.GenericGenerator

I was always taught that if I was using just JPA then I would never see a "org.hibernate" import; is this just wrong?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic