Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Teneo: Manually setting id
Teneo: Manually setting id [message #430622] Sat, 30 May 2009 11:44 Go to next message
Matt Biggs is currently offline Matt BiggsFriend
Messages: 71
Registered: July 2009
Member
This topic has been moved from email between myself and Martin Taal to
here for others to view.


I have been having problems recently getting teneo/hibernate to allow the
id attribute to be set manually.

After adding the attribute to my model object and settings its emf 'id'
property to true i can then set the id in EMF. This value however is
completely ignored and overwritten when persisted to the database.

After assistance from Martin i believe i have made some progress. It was
suggested setting the PersistenceOptions.SET_GENERATED_VALUE_ON_ID_FEATURE
property to false in teneo.

This initially didnt work (i made a mistake in my model), however i
believe i have now made some progress. By setting this to false, you have
to ensure that none of your model objects include any teneo
'GeneratedValue' annotations.

This then changes the hibernate mapping file from:


<id name="id" type="long" unsaved-value="0">
<column not-null="true" unique="false" name="`id`"/>
<generator class="native"/>
</id>

to:

<id name="id" type="long" unsaved-value="0">
<column not-null="true" unique="false" name="`id`"/>
</id>

So whilst this has solved my problem, it now means i have to add the
GeneratedValue annotation to all my other model objects? Is there a way in
which i can leave the option turned on but disable it for a specific id?

I'm not sure i understand the correlation between teneo's GeneratedValue
annotation using its GenerationType enum and hibernates Generator tag? I
guess im trying to find a way in which the hiberantes Generator tag can be
set to 'assigned'.
Re: Teneo: Manually setting id [message #430625 is a reply to message #430622] Sat, 30 May 2009 20:16 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Matt,
Here is the code that maps from the jpa GeneratedValue to the corresponding hibernate value:
GENERATOR_CLASS_NAMES = new String[GenerationType.VALUES.size()];
GENERATOR_CLASS_NAMES[GenerationType.AUTO.getValue()] = "native";
GENERATOR_CLASS_NAMES[GenerationType.IDENTITY.getValue()] = "identity";
GENERATOR_CLASS_NAMES[GenerationType.SEQUENCE.getValue()] = "sequence";
GENERATOR_CLASS_NAMES[GenerationType.TABLE.getValue()] = "hilo";
GENERATOR_CLASS_NAMES[GenerationType.SEQUENCESTYLE.getValue( )] = "org.hibernate.id.enhanced.SequenceStyleGenerator";

Based on your remarks I think it makes sense to support also the assigned value for generatedvalue. Can you enter a
bugzilla for this?
Which Teneo version are you on?

gr. Martin

Matt Biggs wrote:
> This topic has been moved from email between myself and Martin Taal to
> here for others to view.
>
> I have been having problems recently getting teneo/hibernate to allow
> the id attribute to be set manually.
> After adding the attribute to my model object and settings its emf 'id'
> property to true i can then set the id in EMF. This value however is
> completely ignored and overwritten when persisted to the database.
> After assistance from Martin i believe i have made some progress. It was
> suggested setting the
> PersistenceOptions.SET_GENERATED_VALUE_ON_ID_FEATURE property to false
> in teneo.
> This initially didnt work (i made a mistake in my model), however i
> believe i have now made some progress. By setting this to false, you
> have to ensure that none of your model objects include any teneo
> 'GeneratedValue' annotations.
>
> This then changes the hibernate mapping file from:
>
>
> <id name="id" type="long" unsaved-value="0">
> <column not-null="true" unique="false" name="`id`"/>
> <generator class="native"/>
> </id>
>
> to:
>
> <id name="id" type="long" unsaved-value="0">
> <column not-null="true" unique="false" name="`id`"/>
> </id>
>
> So whilst this has solved my problem, it now means i have to add the
> GeneratedValue annotation to all my other model objects? Is there a way
> in which i can leave the option turned on but disable it for a specific id?
>
> I'm not sure i understand the correlation between teneo's GeneratedValue
> annotation using its GenerationType enum and hibernates Generator tag?
> I guess im trying to find a way in which the hiberantes Generator tag
> can be set to 'assigned'.


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Cell: +31 (0)6 288 48 943
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: Manually setting id [message #430627 is a reply to message #430625] Sun, 31 May 2009 06:49 Go to previous messageGo to next message
Matt Biggs is currently offline Matt BiggsFriend
Messages: 71
Registered: July 2009
Member
Hi Martin,

I have filed bug 278543. I believe adding it would be very useful.
I am currently using teneo v1.0.3.

thanks

Matt
Re: Teneo: Manually setting id [message #430632 is a reply to message #430627] Sun, 31 May 2009 19:40 Go to previous message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Matt,
Okay, thanks! I saw it.

gr. Martin

Matt Biggs wrote:
> Hi Martin,
>
> I have filed bug 278543. I believe adding it would be very useful. I am
> currently using teneo v1.0.3.
> thanks
>
> Matt
>


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Cell: +31 (0)6 288 48 943
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:EMF -> EF, anyone?
Next Topic:Object simple validation against ecore model
Goto Forum:
  


Current Time: Thu Apr 25 14:27:30 GMT 2024

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

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

Back to the top