• Post Reply Bookmark Topic Watch Topic
  • New Topic

Unknown Id.generator Hibernate exception  RSS feed

 
Pramod Kumar
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am getting this exeception when i m trying to generate sequence ids with oracle database.

@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE ,generator="my_seq")
@Column(name = "USER_ID", unique = true, nullable = false, insertable = true, updatable = true, scale = 0)
public long getUserId() {
return this.UserId;
}

public void setUserId(long UserId) {
this.UserId = UserId;
}

I am getting this exception

javax.persistence.PersistenceException: org.hibernate.AnnotationException: Unknown Id.generator: my_seq

I have created sequence in oracle --> create sequence my_seq.
Any Idea?

Thanks,
 
Shailesh Kini
Ranch Hand
Posts: 153
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi ngpramod,

Not sure if you are compliant with the naming convention used at JavaRanch.

But... Here's what you are supposed to do.

You have declared your strategy to use Sequences, however you haven't told JPA which sequence it should be using.

You should add another annotation under @GeneratedValue...
@SequenceGenerator(name="my_seq" sequenceName="<actual seq name as it exists in oracle database>")

This should fix your problem.
 
Pramod Kumar
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Shailesh Kini,

Thanks a lot, its working
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!