Close

JPA - @GeneratedValue Examples

JPA JAVA EE 

@Entity
public class MyEntity3 {

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private int myId;

public int getMyId() {
return myId;
}

public void setMyId(int myId) {
this.myId = myId;
}
}
Original Post




@Entity
public class MyEntity4 {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private int myId;

public int getMyId() {
return myId;
}

public void setMyId(int myId) {
this.myId = myId;
}
}
Original Post




@Entity
public class MyEntity2 {
@Id
@GeneratedValue(strategy = GenerationType.TABLE)
private int myId;

public int getMyId() {
return myId;
}

public void setMyId(int myId) {
this.myId = myId;
}
}
Original Post




@Entity
public class MyEntity1 {
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE)
private int myId;

public int getMyId() {
return myId;
}

public void setMyId(int myId) {
this.myId = myId;
}
}
Original Post




See Also