Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Teneo: Id collision on mysql
Teneo: Id collision on mysql [message #430897] Tue, 16 June 2009 18:03 Go to next message
Matt Biggs is currently offline Matt BiggsFriend
Messages: 71
Registered: July 2009
Member
Martin,

I have recently added diagnostics into my EMF resource when i persist the
model and have noticed that mysql is throwing a Diagnostic Error. I've
tested also on Derby and this doesn't have the issue.

It seems to think the Id's of two completely different objects are
colliding. Ignoring the error saves the resource perfectly fine within
Mysql, however its obviously difficult to distinguish between this error
and a real error.

Am i doing something wrong?


Diagnostic ERROR source=TreeEditor code=0 failed to save resource
data=[org.eclipse.emf.edit.domain.AdapterFactoryEditingDomai n$AdapterFactoryEditingDomainResourceSet@aa39d6
resources=[org.eclipse.emf.teneo.hibernate.resource.HibernateResource@1bb3c06
uri='hibernate://?dsname=tree.editor&query=FROM Family WHERE id=1']]
[Diagnostic ERROR source=org.eclipse.emf.ecore code=12 The ID '1' of
' tree.impl.FamilyImpl@133fe5d{hibernate://?dsname=tree.editor &query=FROM
Family WHERE id=1#Family|id=1}' collides with that of
' tree.impl.PersonImpl@1d3e3f3{hibernate://?dsname=tree.editor &query=FROM
Family WHERE id=1#Person|id=1}' data=[tree.impl.FamilyImpl@133fe5d (id: 1,
name: The family), tree.impl.PersonImpl@1d3e3f3 (id: 1, title: null,
forename: New, surname: Person, gender: Male), 1]

cheers matt

ps) checking out teneo 1.1.0 and the bugfixes are working great! top job
:) thanks.
Re: Teneo: Id collision on mysql [message #430898 is a reply to message #430897] Tue, 16 June 2009 19:27 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Matt,
Is the id efeature an ID feature (has ID==true)? If so: the value of the ID feature should be globally unique for one
resource. See the thread with this subject:
'Does ID property have to be unique in the whole Resource?'

So I think that's why the diagnostic is thrown. That it is not thrown for Derby is maybe because of the way derby
assigns ids.

btw thanks for the positive feedback, is always appreciated!

gr. Martin

Matt Biggs wrote:
> Martin,
>
> I have recently added diagnostics into my EMF resource when i persist
> the model and have noticed that mysql is throwing a Diagnostic Error.
> I've tested also on Derby and this doesn't have the issue.
>
> It seems to think the Id's of two completely different objects are
> colliding. Ignoring the error saves the resource perfectly fine within
> Mysql, however its obviously difficult to distinguish between this error
> and a real error.
> Am i doing something wrong?
>
>
> Diagnostic ERROR source=TreeEditor code=0 failed to save resource
> data=[org.eclipse.emf.edit.domain.AdapterFactoryEditingDomai n$AdapterFactoryEditingDomainResourceSet@aa39d6
> resources=[org.eclipse.emf.teneo.hibernate.resource.HibernateResource@1bb3c06
> uri='hibernate://?dsname=tree.editor&query=FROM Family WHERE id=1']]
> [Diagnostic ERROR source=org.eclipse.emf.ecore code=12 The ID '1' of
> ' tree.impl.FamilyImpl@133fe5d{hibernate://?dsname=tree.editor &query=FROM
> Family WHERE id=1#Family|id=1}' collides with that of
> ' tree.impl.PersonImpl@1d3e3f3{hibernate://?dsname=tree.editor &query=FROM
> Family WHERE id=1#Person|id=1}' data=[tree.impl.FamilyImpl@133fe5d (id:
> 1, name: The family), tree.impl.PersonImpl@1d3e3f3 (id: 1, title: null,
> forename: New, surname: Person, gender: Male), 1]
>
> cheers matt
>
> ps) checking out teneo 1.1.0 and the bugfixes are working great! top job
> :) thanks.


--

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: Id collision on mysql [message #430900 is a reply to message #430898] Tue, 16 June 2009 20:02 Go to previous messageGo to next message
Matt Biggs is currently offline Matt BiggsFriend
Messages: 71
Registered: July 2009
Member
Martin,

They are indeed id==true attributes. However, im not actually manually
setting the id in these cases. I have simply added the attribute so i can
use queries to retrieve specific objects. Although its understandable that
EMF requires them to be unique.

The problem is, that this occurs with objects actually retrieved from
teneo. I persist a model, it sets the id using the auto generated one (eg
mysql auto_increment). I then load the model back up, modify a simple
string attribute, attempt to persist and a diagnostic error is produced,
even though teneo has correctly set the ids from the db onto the model,
and i am simply saving it back without modification to any ids or without
adding any new objects.

I guess i could overwrite all ids before save to something unique, however
i think im correct in saying these will be ignored by teneo before
persisting.

I think this seems a little strange, although im not sure what could be
done about it.

cheers

Matt

ps) not a problem, very impressed with the speed of replies both on here
and to bug fixes.
Re: Teneo: Id collision on mysql [message #430901 is a reply to message #430900] Tue, 16 June 2009 21:04 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Matt,
Yes, EMF resources and relational databases have some conceptual mismatches, this is one of them. Teneo does not really
do anything wrong here (and neither are you afaics), the database can not be forced to generate a unique id for a
resource, also because you are flexible to load anything in a resource.

So afaics there are two ways out:
- disable this validation (maybe there is an option to do so, I am not sure...), hopefully Ed or somefull else sees this
thread and can add some info
- do not use ID=true feature and use annotations to set the id (@Id)

But ofcourse it depends on your implementation if these are feasible options.

gr. Martin

Matt Biggs wrote:
> Martin,
>
> They are indeed id==true attributes. However, im not actually manually
> setting the id in these cases. I have simply added the attribute so i
> can use queries to retrieve specific objects. Although its
> understandable that EMF requires them to be unique.
> The problem is, that this occurs with objects actually retrieved from
> teneo. I persist a model, it sets the id using the auto generated one
> (eg mysql auto_increment). I then load the model back up, modify a
> simple string attribute, attempt to persist and a diagnostic error is
> produced, even though teneo has correctly set the ids from the db onto
> the model, and i am simply saving it back without modification to any
> ids or without adding any new objects.
>
> I guess i could overwrite all ids before save to something unique,
> however i think im correct in saying these will be ignored by teneo
> before persisting.
>
> I think this seems a little strange, although im not sure what could be
> done about it.
> cheers
>
> Matt
>
> ps) not a problem, very impressed with the speed of replies both on here
> and to bug fixes.
>


--

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: Id collision on mysql [message #430906 is a reply to message #430901] Wed, 17 June 2009 06:41 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Matt,
And to add a third solution: is implement your own id-generator which gives unique ids to all records. See the hibernate
documentation on id generators and the relevant annotations. That will work cross-database also.

gr. Martin

Martin Taal wrote:
> Hi Matt,
> Yes, EMF resources and relational databases have some conceptual
> mismatches, this is one of them. Teneo does not really do anything wrong
> here (and neither are you afaics), the database can not be forced to
> generate a unique id for a resource, also because you are flexible to
> load anything in a resource.
>
> So afaics there are two ways out:
> - disable this validation (maybe there is an option to do so, I am not
> sure...), hopefully Ed or somefull else sees this thread and can add
> some info
> - do not use ID=true feature and use annotations to set the id (@Id)
>
> But ofcourse it depends on your implementation if these are feasible
> options.
>
> gr. Martin
>
> Matt Biggs wrote:
>> Martin,
>>
>> They are indeed id==true attributes. However, im not actually manually
>> setting the id in these cases. I have simply added the attribute so i
>> can use queries to retrieve specific objects. Although its
>> understandable that EMF requires them to be unique.
>> The problem is, that this occurs with objects actually retrieved from
>> teneo. I persist a model, it sets the id using the auto generated one
>> (eg mysql auto_increment). I then load the model back up, modify a
>> simple string attribute, attempt to persist and a diagnostic error is
>> produced, even though teneo has correctly set the ids from the db onto
>> the model, and i am simply saving it back without modification to any
>> ids or without adding any new objects.
>>
>> I guess i could overwrite all ids before save to something unique,
>> however i think im correct in saying these will be ignored by teneo
>> before persisting.
>>
>> I think this seems a little strange, although im not sure what could
>> be done about it.
>> cheers
>>
>> Matt
>>
>> ps) not a problem, very impressed with the speed of replies both on
>> here and to bug fixes.
>>
>
>


--

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: Id collision on mysql [message #430908 is a reply to message #430906] Wed, 17 June 2009 07:57 Go to previous message
Matt Biggs is currently offline Matt BiggsFriend
Messages: 71
Registered: July 2009
Member
Martin,

That does make sense. I think in reality for my model, im only using the
ids for db querying, so really shouldn't be setting the id=true in EMF
land.

I will try changing the model over to use teneo @Id annotaion instead
which should then support all my needs.

thanks for the help

Matt
Previous Topic:Preserve EEnums literal by UML import
Next Topic:How to get model instance from other Plugin?
Goto Forum:
  


Current Time: Tue Apr 23 15:20:50 GMT 2024

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

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

Back to the top