[Teneo] id and version [message #119183] |
Sat, 19 April 2008 08:10  |
Eclipse User |
|
|
|
Originally posted by: tom.eiswind.de
Still more newbie questions. I have to be compatible with my existing
db. there i have id and version columns with Strategy.AUTO.
Im new to the hbm.xml syntax is generator class "native" the same ?
And how can I teach teneo to name the fields "id" and "version" ?
I want to have a mappedsuperclass (see question before) for id, version
and some more to have generic equals and hashcode on that on my model.
Regards Thomas
|
|
|
|
|
Re: [Teneo] id and version [message #119285 is a reply to message #119248] |
Sun, 20 April 2008 01:35  |
Eclipse User |
|
|
|
Hi Thomas,
Hmm I am not sure what is Strategy.AUTO? GenerationType.AUTO (the default) maps to the hibernate
native strategy which is this:
picks identity, sequence or hilo depending upon the capabilities of the underlying database.
to get the generationtype.auto you need to add this annotation:
@GeneratedValue
So with what Yigal said you get the annotations:
@Id @GeneratedValue @Column(name="myid")
For version you can either choose for a numeric increment or a timestamp. The numeric one is the
safest as not all databases support milliseconds in the timestamp. Numeric is the default so for the
version column you can set the following annotations:
@Version @Column(name="myversion")
gr. Martin
Yigal wrote:
> To make the hibernate mapping file to use id and version, use the JPA
> annotation for the attribute defining the "id" column.
> <eAnnotations source="teneo.jpa">
> <details key="appinfo" value="@Column(name='id'; )"/>
> </eAnnotations>
> When you generate the hibernate mapping file it will map the class
> attribute to the column id.
> Yigal
>
> Thomas wrote:
>> Still more newbie questions. I have to be compatible with my existing
>> db. there i have id and version columns with Strategy.AUTO.
>> Im new to the hbm.xml syntax is generator class "native" the same ?
>>
>> And how can I teach teneo to name the fields "id" and "version" ?
>>
>> I want to have a mappedsuperclass (see question before) for id,
>> version and some more to have generic equals and hashcode on that on
>> my model.
>>
>> Regards Thomas
--
With Regards, Martin Taal
Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@springsite.com - mtaal@elver.org
Web: www.springsite.com - www.elver.org
|
|
|
|
Re: [Teneo] id and version [message #617853 is a reply to message #119183] |
Sat, 19 April 2008 13:55  |
Eclipse User |
|
|
|
To make the hibernate mapping file to use id and version, use the JPA
annotation for the attribute defining the "id" column.
<eAnnotations source="teneo.jpa">
<details key="appinfo" value="@Column(name='id'; )"/>
</eAnnotations>
When you generate the hibernate mapping file it will map the class
attribute to the column id.
Yigal
Thomas wrote:
> Still more newbie questions. I have to be compatible with my existing
> db. there i have id and version columns with Strategy.AUTO.
> Im new to the hbm.xml syntax is generator class "native" the same ?
>
> And how can I teach teneo to name the fields "id" and "version" ?
>
> I want to have a mappedsuperclass (see question before) for id, version
> and some more to have generic equals and hashcode on that on my model.
>
> Regards Thomas
|
|
|
Re: [Teneo] id and version [message #617856 is a reply to message #119248] |
Sun, 20 April 2008 01:35  |
Eclipse User |
|
|
|
Hi Thomas,
Hmm I am not sure what is Strategy.AUTO? GenerationType.AUTO (the default) maps to the hibernate
native strategy which is this:
picks identity, sequence or hilo depending upon the capabilities of the underlying database.
to get the generationtype.auto you need to add this annotation:
@GeneratedValue
So with what Yigal said you get the annotations:
@Id @GeneratedValue @Column(name="myid")
For version you can either choose for a numeric increment or a timestamp. The numeric one is the
safest as not all databases support milliseconds in the timestamp. Numeric is the default so for the
version column you can set the following annotations:
@Version @Column(name="myversion")
gr. Martin
Yigal wrote:
> To make the hibernate mapping file to use id and version, use the JPA
> annotation for the attribute defining the "id" column.
> <eAnnotations source="teneo.jpa">
> <details key="appinfo" value="@Column(name='id'; )"/>
> </eAnnotations>
> When you generate the hibernate mapping file it will map the class
> attribute to the column id.
> Yigal
>
> Thomas wrote:
>> Still more newbie questions. I have to be compatible with my existing
>> db. there i have id and version columns with Strategy.AUTO.
>> Im new to the hbm.xml syntax is generator class "native" the same ?
>>
>> And how can I teach teneo to name the fields "id" and "version" ?
>>
>> I want to have a mappedsuperclass (see question before) for id,
>> version and some more to have generic equals and hashcode on that on
>> my model.
>>
>> Regards Thomas
--
With Regards, Martin Taal
Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@springsite.com - mtaal@elver.org
Web: www.springsite.com - www.elver.org
|
|
|
Powered by
FUDForum. Page generated in 0.02960 seconds