Hello,
You have specified:
@GeneratedValue(strategy = GenerationType.IDENTITY)
> @Column(name = "number")
> private int number;
and:
> 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.
> >
> >
I think it is because you have specified it as Identity which means the primary key of this entity. I am not sure if you can specify @GeneratedValue without is being the primary of the entity.
You have to make the choice the number as the @GeneratedValue as the primary key or the:
@Id
> @Column(name = "sysId")
> private String sysId;
>
Is the above the primary key of this class or a foreign
key from another entity/Table.
eve
> Date: Wed, 19 Sep 2007 07:15:17 -0700
> From: dknotts_at_co.brazos.tx.us
> To: persistence_at_glassfish.dev.java.net
> Subject: Re: using generated value with a non Id field
>
>
> 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.
_________________________________________________________________
Get free emoticon packs and customisation from Windows Live.
http://www.pimpmylive.co.uk