I'm having the same problem. I tried what you suggested, but it isn't
working. All the documentation I have read says that @GeneratedValue only
works in conjunction with the @Id annotation, and this is exactly how my
program is reacting. I added a copy of the class where I am trying to
accomplish this below. Can you give me some pointers on what I'm doing
wrong, please?
@Entity
@Table(name = "Owner")
public class Owner {
@Id
@Column(name = "sysId")
private String sysId;
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "number")
private int number;
public Owner() {
}
public String getSysId() {
return sysId;
}
public int getNumber() {
return number;
}
}
James Sutherland wrote:
>
> Yes, just annotate the field with @GeneratedValue. However in
> TopLink-Essentials you can only generate a sequence value for one field in
> the class, it does not need to be the id, but only one field is supported.
>
>
> sud-3 wrote:
>>
>> Is it possible to have JPA (toplink-essentials) auto-generate a column
>> value for a non Id field?
>>
>
>
--
View this message in context: http://www.nabble.com/using-generated-value-with-a-non-Id-field-tf4339169.html#a12778415
Sent from the java.net - glassfish persistence mailing list archive at Nabble.com.