Hi Linda
Can you clarify the spec for the below :
The user has defined the following for his ID field
@Id
@GeneratedValue(strategy=GenerationType.SEQUENCE, generator="USERS_SEQUENCE_GENERATOR")
@SequenceGenerator(name="USERS_SEQUENCE_GENERATOR",sequenceName="users_id_seq")
@Column(name="id")
public Long getId() {
return id;
}
And then they try this in their stateless bean
public Long createUser(String userName) {
User user = new User();
user.setName(userName);
em.persist(user);
return user.getId();
}
What is the expected value from the user.getId() call in the case where they have used either a SEQUENCE or an IDENTITY generator.
Since in this case the value of the is obtained after the insert statement has successfully completed,
how is the user expected to get the value of the id ?
Thanks
Pramod