Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF "Technology" (Ecore Tools, EMFatic, etc)  » [Teneo] id and version
[Teneo] id and version [message #119183] Sat, 19 April 2008 12:10 Go to next message
Eclipse UserFriend
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 #119196 is a reply to message #119183] Sat, 19 April 2008 12:21 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: tom.eiswind.de

What comes next to me, as I need to fetch everything eagerly, I want to
have bag semantics. IN my model I have a list. How can I do a set/bag
semantic ?
Re: [Teneo] id and version [message #119248 is a reply to message #119183] Sat, 19 April 2008 17:55 Go to previous messageGo to next message
Yigal Spinner is currently offline Yigal SpinnerFriend
Messages: 127
Registered: July 2009
Senior Member
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 #119285 is a reply to message #119248] Sun, 20 April 2008 05:35 Go to previous message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
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 #617849 is a reply to message #119183] Sat, 19 April 2008 12:21 Go to previous message
Thomas is currently offline ThomasFriend
Messages: 151
Registered: July 2009
Senior Member
What comes next to me, as I need to fetch everything eagerly, I want to
have bag semantics. IN my model I have a list. How can I do a set/bag
semantic ?
Re: [Teneo] id and version [message #617853 is a reply to message #119183] Sat, 19 April 2008 17:55 Go to previous message
Yigal Spinner is currently offline Yigal SpinnerFriend
Messages: 127
Registered: July 2009
Senior Member
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 05:35 Go to previous message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
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
Previous Topic:[Teneo] Still newbie questions
Next Topic:Hibernate Paging
Goto Forum:
  


Current Time: Mon Aug 26 02:52:40 GMT 2024

Powered by FUDForum. Page generated in 0.04252 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top