• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

From Murach's Java Servlets/JSP 3rd edition Question about example of Primary Keys in JPA entity.

 
Lisa Austin
Ranch Hand
Posts: 119
3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi there,
on page 428 - 429 of the book it explains if add the @Id annotation the annotation tells JPA that the following field is the primary key for the entity. If you use @GeneratedValue annotation it tells the JPA to automatically generate values for the primary key.

I just want to clarify. In the example and explanation this mean that the primary key is userID and the values are auto generated? Just checking that I understand . Thanks!!


A simple JPA entity

 
Stefan Evans
Bartender
Posts: 1807
10
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your understanding sounds fine to me.

userId is indeed the field which is being annotated here
 
Lisa Austin
Ranch Hand
Posts: 119
3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Stefan Evans wrote:Your understanding sounds fine to me.

userId is indeed the field which is being annotated here


Thank You. I wasn't too sure i it was JUST that field or all fields under it.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic