• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to assign primary key  RSS feed

 
Maya Pillai
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have a primary key in my table. I am using the below code to generate the primary key.

@Id
@GeneratedValue(strategy = GenerationType.ENTITY)
private Long id;


What change should i made to the annotation if i want to assign primary key. I will assign a number to id field before saving this entity to database.

Can anyone help me .

Thanks...
 
sarmaP lolla
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
remove the line . That should be suffcient. What ever the value you assign will be used for the Id.

Let me know if that helps.

Sarma
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!