Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » [Teneo] Invalid Hibernate Mappings for subclasses w/ ID Fields (bugzilla 176821)
[Teneo] Invalid Hibernate Mappings for subclasses w/ ID Fields (bugzilla 176821) [message #423339] Mon, 29 September 2008 07:00 Go to next message
Andrew H is currently offline Andrew HFriend
Messages: 117
Registered: July 2009
Senior Member
I just tried adding a comment to
https://bugs.eclipse.org/bugs/show_bug.cgi?id=176821 but bugzilla seems to
be broken. I get an error saying "A Legal Version was not set"

So I'll post it as a news item instead for now

The issue relates to teneo adding id and version fields to subclass
elements which does not comply with the hibernate schema. The comment was
--

This is still an issue for me. A large part of our ecore models originates
from industry XSD's which have used ID fields in the schema on sub types.
e.g. they might have a Date base type and an IdentifiedDate subtype that
adds an ID field so they can create IDREF fields to point to them. i.e.
they introduce ID fields in subtypes specifically so those subtypes can be
the target of IDREF's elsewhere. I'm not sure why they subtyped for this
reason.

As these are ID fields in XSD they come into ecore as ID fields and cause
this problem in teneo.

Sure I would be inclined to avoid doing this in my own models but I don't
have any control over these industry schema's

Couldn't teneo have a rule that if an ID field appears on a subtype then
simply add the field as a unique property rather than an ID field.

e.g.
<property name="id" lazy="false" insert="true" update="true"
not-null="false" unique="true" type="java.lang.String">
<column not-null="false" unique="false" name="`false`"/>
</property>

Turning ID fields off on the whole model with the option is not desirable
either as in general I'd like it to use my ID fields as PK's when they are
there on the base class.
Re: [Teneo] Invalid Hibernate Mappings for subclasses w/ ID Fields (bugzilla 176821) [message #423344 is a reply to message #423339] Mon, 29 September 2008 10:33 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Andrew,
Would the following approach work in your case:
- Annote the id-fields in the supertypes/root of the hierarchy with @Id, and
- set the option: PersistenceOptions.ID_FEATURE_AS_PRIMARY_KEY to false

gr. Martin

Andrew H wrote:
> I just tried adding a comment to
> https://bugs.eclipse.org/bugs/show_bug.cgi?id=176821 but bugzilla seems
> to be broken. I get an error saying "A Legal Version was not set"
>
> So I'll post it as a news item instead for now
>
> The issue relates to teneo adding id and version fields to subclass
> elements which does not comply with the hibernate schema. The comment was
> --
>
> This is still an issue for me. A large part of our ecore models
> originates from industry XSD's which have used ID fields in the schema
> on sub types. e.g. they might have a Date base type and an
> IdentifiedDate subtype that adds an ID field so they can create IDREF
> fields to point to them. i.e. they introduce ID fields in subtypes
> specifically so those subtypes can be the target of IDREF's elsewhere.
> I'm not sure why they subtyped for this reason.
>
> As these are ID fields in XSD they come into ecore as ID fields and
> cause this problem in teneo.
>
> Sure I would be inclined to avoid doing this in my own models but I
> don't have any control over these industry schema's
>
> Couldn't teneo have a rule that if an ID field appears on a subtype then
> simply add the field as a unique property rather than an ID field.
>
> e.g. <property name="id" lazy="false" insert="true" update="true"
> not-null="false" unique="true" type="java.lang.String">
> <column not-null="false" unique="false" name="`false`"/>
> </property>
>
> Turning ID fields off on the whole model with the option is not
> desirable either as in general I'd like it to use my ID fields as PK's
> when they are there on the base class.
>
>


--

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] Invalid Hibernate Mappings for subclasses w/ ID Fields (bugzilla 176 [message #423406 is a reply to message #423344] Tue, 30 September 2008 01:00 Go to previous messageGo to next message
Andrew H is currently offline Andrew HFriend
Messages: 117
Registered: July 2009
Senior Member
Hi Martin

There are a few problems with this

1/ The models have come from industry standard schemas. We are trying to
avoid any manual changes to the models at this stage. At this stage we are
relying on purely automatic and essentially cosmetic refactoring of the
model (e.g. breaking it up into separate packages and moving classes
around a bit, but no changes to the actual classes themselves). The
reasons for this is that the model is so large it will take us a while to
understand it well enough to consider altering it and secondly we will
always need to maintain compatibility with it so the more we alter it the
more we will need custom transformations to import / export to the
standard.

2/ The base types don't have id fields in this case. Teneo is generating
the eId fields for these.

3/ Setting PersistenceOptions.ID_FEATURE_AS_PRIMARY_KEY to false means
that we will lose this feature for our own models. For our hand written
models we will (and have) made use of id fields on our base classes. We
like that teneo generates id elements for these.

The problem really stems from two issues

i/ The industry XSD's are using id's for an XML oriented technique for
referring to elements that are not child elements of the current element.
i.e. they are not considering the impact this has on an implementation
model such as ecore and the ramifications for persistence. i.e. from the
XSD point of view adding id fields to sub types is not an issue.

ii/ Teneo has a mapping bug in this case. Even if it is something best
avoided in an ecore model, its still the case that Teneo creates a
hibernate mapping that does not conform to the hibernate XSD. Surely that
should not happen. At the worst case it should throw an exception but I
still think that generating a unique property is the best answer. Is this
not possible / desirable?

Another possible avenue for us is if we can customise the mapping from XSD
such that the field remains an ID field in XML but is not an ID field in
ecore. I'm not sure if this is possible?

regards

Andrew

Martin Taal wrote:

> Hi Andrew,
> Would the following approach work in your case:
> - Annote the id-fields in the supertypes/root of the hierarchy with @Id, and
> - set the option: PersistenceOptions.ID_FEATURE_AS_PRIMARY_KEY to false

> gr. Martin

> Andrew H wrote:
>> I just tried adding a comment to
>> https://bugs.eclipse.org/bugs/show_bug.cgi?id=176821 but bugzilla seems
>> to be broken. I get an error saying "A Legal Version was not set"
>>
>> So I'll post it as a news item instead for now
>>
>> The issue relates to teneo adding id and version fields to subclass
>> elements which does not comply with the hibernate schema. The comment was
>> --
>>
>> This is still an issue for me. A large part of our ecore models
>> originates from industry XSD's which have used ID fields in the schema
>> on sub types. e.g. they might have a Date base type and an
>> IdentifiedDate subtype that adds an ID field so they can create IDREF
>> fields to point to them. i.e. they introduce ID fields in subtypes
>> specifically so those subtypes can be the target of IDREF's elsewhere.
>> I'm not sure why they subtyped for this reason.
>>
>> As these are ID fields in XSD they come into ecore as ID fields and
>> cause this problem in teneo.
>>
>> Sure I would be inclined to avoid doing this in my own models but I
>> don't have any control over these industry schema's
>>
>> Couldn't teneo have a rule that if an ID field appears on a subtype then
>> simply add the field as a unique property rather than an ID field.
>>
>> e.g. <property name="id" lazy="false" insert="true" update="true"
>> not-null="false" unique="true" type="java.lang.String">
>> <column not-null="false" unique="false" name="`false`"/>
>> </property>
>>
>> Turning ID fields off on the whole model with the option is not
>> desirable either as in general I'd like it to use my ID fields as PK's
>> when they are there on the base class.
>>
>>
Re: [Teneo] Invalid Hibernate Mappings for subclasses w/ ID Fields (bugzilla 176 [message #423407 is a reply to message #423406] Tue, 30 September 2008 04:10 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Andrew,
Okay, I will change it so that an ID efeature in a subtype is ignored (and a warning is logged).

Can you enter a new bugzilla or reopen the old one for this?

gr. Martin

Andrew H wrote:
> Hi Martin
>
> There are a few problems with this
>
> 1/ The models have come from industry standard schemas. We are trying to
> avoid any manual changes to the models at this stage. At this stage we
> are relying on purely automatic and essentially cosmetic refactoring of
> the model (e.g. breaking it up into separate packages and moving classes
> around a bit, but no changes to the actual classes themselves). The
> reasons for this is that the model is so large it will take us a while
> to understand it well enough to consider altering it and secondly we
> will always need to maintain compatibility with it so the more we alter
> it the more we will need custom transformations to import / export to
> the standard.
>
> 2/ The base types don't have id fields in this case. Teneo is generating
> the eId fields for these.
>
> 3/ Setting PersistenceOptions.ID_FEATURE_AS_PRIMARY_KEY to false means
> that we will lose this feature for our own models. For our hand written
> models we will (and have) made use of id fields on our base classes. We
> like that teneo generates id elements for these.
>
> The problem really stems from two issues
>
> i/ The industry XSD's are using id's for an XML oriented technique for
> referring to elements that are not child elements of the current
> element. i.e. they are not considering the impact this has on an
> implementation model such as ecore and the ramifications for
> persistence. i.e. from the XSD point of view adding id fields to sub
> types is not an issue.
>
> ii/ Teneo has a mapping bug in this case. Even if it is something best
> avoided in an ecore model, its still the case that Teneo creates a
> hibernate mapping that does not conform to the hibernate XSD. Surely
> that should not happen. At the worst case it should throw an exception
> but I still think that generating a unique property is the best answer.
> Is this not possible / desirable?
>
> Another possible avenue for us is if we can customise the mapping from
> XSD such that the field remains an ID field in XML but is not an ID
> field in ecore. I'm not sure if this is possible?
>
> regards
>
> Andrew
>
> Martin Taal wrote:
>
>> Hi Andrew,
>> Would the following approach work in your case:
>> - Annote the id-fields in the supertypes/root of the hierarchy with
>> @Id, and
>> - set the option: PersistenceOptions.ID_FEATURE_AS_PRIMARY_KEY to false
>
>> gr. Martin
>
>> Andrew H wrote:
>>> I just tried adding a comment to
>>> https://bugs.eclipse.org/bugs/show_bug.cgi?id=176821 but bugzilla
>>> seems to be broken. I get an error saying "A Legal Version was not set"
>>>
>>> So I'll post it as a news item instead for now
>>>
>>> The issue relates to teneo adding id and version fields to subclass
>>> elements which does not comply with the hibernate schema. The comment
>>> was
>>> --
>>>
>>> This is still an issue for me. A large part of our ecore models
>>> originates from industry XSD's which have used ID fields in the
>>> schema on sub types. e.g. they might have a Date base type and an
>>> IdentifiedDate subtype that adds an ID field so they can create IDREF
>>> fields to point to them. i.e. they introduce ID fields in subtypes
>>> specifically so those subtypes can be the target of IDREF's
>>> elsewhere. I'm not sure why they subtyped for this reason.
>>>
>>> As these are ID fields in XSD they come into ecore as ID fields and
>>> cause this problem in teneo.
>>>
>>> Sure I would be inclined to avoid doing this in my own models but I
>>> don't have any control over these industry schema's
>>>
>>> Couldn't teneo have a rule that if an ID field appears on a subtype
>>> then simply add the field as a unique property rather than an ID field.
>>>
>>> e.g. <property name="id" lazy="false" insert="true" update="true"
>>> not-null="false" unique="true" type="java.lang.String">
>>> <column not-null="false" unique="false" name="`false`"/>
>>> </property>
>>>
>>> Turning ID fields off on the whole model with the option is not
>>> desirable either as in general I'd like it to use my ID fields as
>>> PK's when they are there on the base class.
>>>
>>>
>
>
>
>


--

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] Invalid Hibernate Mappings for subclasses w/ ID Fields (bugzilla 176 [message #423409 is a reply to message #423407] Tue, 30 September 2008 07:51 Go to previous messageGo to next message
Andrew H is currently offline Andrew HFriend
Messages: 117
Registered: July 2009
Senior Member
Thanks Martin

Appreciate this.

Unfortunately, I can't get bugzilla to work. I get

Bugzilla has suffered an internal error. Please save this page and send it
to webmaster@eclipse.org with details of what you were doing at the time
this message appeared.

URL: https://bugs.eclipse.org/bugs/post_bug.cgi
A legal Version was not set.

cheers

Andrew

Martin Taal wrote:

> Hi Andrew,
> Okay, I will change it so that an ID efeature in a subtype is ignored (and a
warning is logged).

> Can you enter a new bugzilla or reopen the old one for this?

> gr. Martin

> Andrew H wrote:
>> Hi Martin
>>
>> There are a few problems with this
>>
>> 1/ The models have come from industry standard schemas. We are trying to
>> avoid any manual changes to the models at this stage. At this stage we
>> are relying on purely automatic and essentially cosmetic refactoring of
>> the model (e.g. breaking it up into separate packages and moving classes
>> around a bit, but no changes to the actual classes themselves). The
>> reasons for this is that the model is so large it will take us a while
>> to understand it well enough to consider altering it and secondly we
>> will always need to maintain compatibility with it so the more we alter
>> it the more we will need custom transformations to import / export to
>> the standard.
>>
>> 2/ The base types don't have id fields in this case. Teneo is generating
>> the eId fields for these.
>>
>> 3/ Setting PersistenceOptions.ID_FEATURE_AS_PRIMARY_KEY to false means
>> that we will lose this feature for our own models. For our hand written
>> models we will (and have) made use of id fields on our base classes. We
>> like that teneo generates id elements for these.
>>
>> The problem really stems from two issues
>>
>> i/ The industry XSD's are using id's for an XML oriented technique for
>> referring to elements that are not child elements of the current
>> element. i.e. they are not considering the impact this has on an
>> implementation model such as ecore and the ramifications for
>> persistence. i.e. from the XSD point of view adding id fields to sub
>> types is not an issue.
>>
>> ii/ Teneo has a mapping bug in this case. Even if it is something best
>> avoided in an ecore model, its still the case that Teneo creates a
>> hibernate mapping that does not conform to the hibernate XSD. Surely
>> that should not happen. At the worst case it should throw an exception
>> but I still think that generating a unique property is the best answer.
>> Is this not possible / desirable?
>>
>> Another possible avenue for us is if we can customise the mapping from
>> XSD such that the field remains an ID field in XML but is not an ID
>> field in ecore. I'm not sure if this is possible?
>>
>> regards
>>
>> Andrew
>>
>> Martin Taal wrote:
>>
>>> Hi Andrew,
>>> Would the following approach work in your case:
>>> - Annote the id-fields in the supertypes/root of the hierarchy with
>>> @Id, and
>>> - set the option: PersistenceOptions.ID_FEATURE_AS_PRIMARY_KEY to false
>>
>>> gr. Martin
>>
>>> Andrew H wrote:
>>>> I just tried adding a comment to
>>>> https://bugs.eclipse.org/bugs/show_bug.cgi?id=176821 but bugzilla
>>>> seems to be broken. I get an error saying "A Legal Version was not set"
>>>>
>>>> So I'll post it as a news item instead for now
>>>>
>>>> The issue relates to teneo adding id and version fields to subclass
>>>> elements which does not comply with the hibernate schema. The comment
>>>> was
>>>> --
>>>>
>>>> This is still an issue for me. A large part of our ecore models
>>>> originates from industry XSD's which have used ID fields in the
>>>> schema on sub types. e.g. they might have a Date base type and an
>>>> IdentifiedDate subtype that adds an ID field so they can create IDREF
>>>> fields to point to them. i.e. they introduce ID fields in subtypes
>>>> specifically so those subtypes can be the target of IDREF's
>>>> elsewhere. I'm not sure why they subtyped for this reason.
>>>>
>>>> As these are ID fields in XSD they come into ecore as ID fields and
>>>> cause this problem in teneo.
>>>>
>>>> Sure I would be inclined to avoid doing this in my own models but I
>>>> don't have any control over these industry schema's
>>>>
>>>> Couldn't teneo have a rule that if an ID field appears on a subtype
>>>> then simply add the field as a unique property rather than an ID field.
>>>>
>>>> e.g. <property name="id" lazy="false" insert="true" update="true"
>>>> not-null="false" unique="true" type="java.lang.String">
>>>> <column not-null="false" unique="false" name="`false`"/>
>>>> </property>
>>>>
>>>> Turning ID fields off on the whole model with the option is not
>>>> desirable either as in general I'd like it to use my ID fields as
>>>> PK's when they are there on the base class.
>>>>
>>>>
>>
>>
>>
>>
Re: [Teneo] Invalid Hibernate Mappings for subclasses w/ ID Fields (bugzilla 176 [message #423410 is a reply to message #423409] Tue, 30 September 2008 08:02 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
You also get this when entering a new bugzilla?

gr. Martin

Andrew H wrote:
> Thanks Martin
>
> Appreciate this.
>
> Unfortunately, I can't get bugzilla to work. I get
> Bugzilla has suffered an internal error. Please save this page and send
> it to webmaster@eclipse.org with details of what you were doing at the
> time this message appeared.
>
> URL: https://bugs.eclipse.org/bugs/post_bug.cgi
> A legal Version was not set.
>
> cheers
>
> Andrew
>
> Martin Taal wrote:
>
>> Hi Andrew,
>> Okay, I will change it so that an ID efeature in a subtype is ignored
>> (and a
> warning is logged).
>
>> Can you enter a new bugzilla or reopen the old one for this?
>
>> gr. Martin
>
>> Andrew H wrote:
>>> Hi Martin
>>>
>>> There are a few problems with this
>>>
>>> 1/ The models have come from industry standard schemas. We are trying
>>> to avoid any manual changes to the models at this stage. At this
>>> stage we are relying on purely automatic and essentially cosmetic
>>> refactoring of the model (e.g. breaking it up into separate packages
>>> and moving classes around a bit, but no changes to the actual classes
>>> themselves). The reasons for this is that the model is so large it
>>> will take us a while to understand it well enough to consider
>>> altering it and secondly we will always need to maintain
>>> compatibility with it so the more we alter it the more we will need
>>> custom transformations to import / export to the standard.
>>>
>>> 2/ The base types don't have id fields in this case. Teneo is
>>> generating the eId fields for these.
>>>
>>> 3/ Setting PersistenceOptions.ID_FEATURE_AS_PRIMARY_KEY to false
>>> means that we will lose this feature for our own models. For our hand
>>> written models we will (and have) made use of id fields on our base
>>> classes. We like that teneo generates id elements for these.
>>>
>>> The problem really stems from two issues
>>>
>>> i/ The industry XSD's are using id's for an XML oriented technique
>>> for referring to elements that are not child elements of the current
>>> element. i.e. they are not considering the impact this has on an
>>> implementation model such as ecore and the ramifications for
>>> persistence. i.e. from the XSD point of view adding id fields to sub
>>> types is not an issue.
>>>
>>> ii/ Teneo has a mapping bug in this case. Even if it is something
>>> best avoided in an ecore model, its still the case that Teneo creates
>>> a hibernate mapping that does not conform to the hibernate XSD.
>>> Surely that should not happen. At the worst case it should throw an
>>> exception but I still think that generating a unique property is the
>>> best answer. Is this not possible / desirable?
>>>
>>> Another possible avenue for us is if we can customise the mapping
>>> from XSD such that the field remains an ID field in XML but is not an
>>> ID field in ecore. I'm not sure if this is possible?
>>>
>>> regards
>>>
>>> Andrew
>>>
>>> Martin Taal wrote:
>>>
>>>> Hi Andrew,
>>>> Would the following approach work in your case:
>>>> - Annote the id-fields in the supertypes/root of the hierarchy with
>>>> @Id, and
>>>> - set the option: PersistenceOptions.ID_FEATURE_AS_PRIMARY_KEY to false
>>>
>>>> gr. Martin
>>>
>>>> Andrew H wrote:
>>>>> I just tried adding a comment to
>>>>> https://bugs.eclipse.org/bugs/show_bug.cgi?id=176821 but bugzilla
>>>>> seems to be broken. I get an error saying "A Legal Version was not
>>>>> set"
>>>>>
>>>>> So I'll post it as a news item instead for now
>>>>>
>>>>> The issue relates to teneo adding id and version fields to subclass
>>>>> elements which does not comply with the hibernate schema. The
>>>>> comment was
>>>>> --
>>>>>
>>>>> This is still an issue for me. A large part of our ecore models
>>>>> originates from industry XSD's which have used ID fields in the
>>>>> schema on sub types. e.g. they might have a Date base type and an
>>>>> IdentifiedDate subtype that adds an ID field so they can create
>>>>> IDREF fields to point to them. i.e. they introduce ID fields in
>>>>> subtypes specifically so those subtypes can be the target of
>>>>> IDREF's elsewhere. I'm not sure why they subtyped for this reason.
>>>>>
>>>>> As these are ID fields in XSD they come into ecore as ID fields and
>>>>> cause this problem in teneo.
>>>>>
>>>>> Sure I would be inclined to avoid doing this in my own models but I
>>>>> don't have any control over these industry schema's
>>>>>
>>>>> Couldn't teneo have a rule that if an ID field appears on a subtype
>>>>> then simply add the field as a unique property rather than an ID
>>>>> field.
>>>>>
>>>>> e.g. <property name="id" lazy="false" insert="true" update="true"
>>>>> not-null="false" unique="true" type="java.lang.String">
>>>>> <column not-null="false" unique="false" name="`false`"/>
>>>>> </property>
>>>>>
>>>>> Turning ID fields off on the whole model with the option is not
>>>>> desirable either as in general I'd like it to use my ID fields as
>>>>> PK's when they are there on the base class.
>>>>>
>>>>>
>>>
>>>
>>>
>>>
>
>
>
>


--

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] Invalid Hibernate Mappings for subclasses w/ ID Fields (bugzilla 176 [message #423544 is a reply to message #423410] Wed, 01 October 2008 23:57 Go to previous messageGo to next message
Andrew H is currently offline Andrew HFriend
Messages: 117
Registered: July 2009
Senior Member
Strange, I replied to this yesterday but it seems to have been lost.

I was able to create a new bugzilla when I did it from scratch rather than
trying to clone the other issue. Issue is
https://bugs.eclipse.org/bugs/show_bug.cgi?id=249246

Note, however, that after I filed this I progressed my persistence code
further and realised that the ID fields that originate from the XSD's are
not suitable as primary keys in the database. They are only intended to be
unique within a single document.

So in the end I used the option you suggested to turn off generation of
primary key fields for these fields.

Consequently, getting a fix for this is no longer a priority for us.
Apologies for the noise. Let me know if you want me to shut the issue down.

I'd be interested in Ed and others thoughts on ID fields. EMF seems to
default XSD ID fields to ID fields in EMF and Teneo then defaults to
setting these as the primary keys. I'm not clear on whether turning this
off in teneo is the right approach or whether I should look to turn it off
in EMF. i.e. are ID fields in EMF supposed to be effectively primary keys
for that class? If so then the mapping from XSD ID is questionable

cheers

Andrew

Martin Taal wrote:

> You also get this when entering a new bugzilla?

> gr. Martin

> Andrew H wrote:
>> Thanks Martin
>>
>> Appreciate this.
>>
>> Unfortunately, I can't get bugzilla to work. I get
>> Bugzilla has suffered an internal error. Please save this page and send
>> it to webmaster@eclipse.org with details of what you were doing at the
>> time this message appeared.
>>
>> URL: https://bugs.eclipse.org/bugs/post_bug.cgi
>> A legal Version was not set.
>>
>> cheers
>>
>> Andrew
>>
>> Martin Taal wrote:
>>
>>> Hi Andrew,
>>> Okay, I will change it so that an ID efeature in a subtype is ignored
>>> (and a
>> warning is logged).
>>
>>> Can you enter a new bugzilla or reopen the old one for this?
>>
>>> gr. Martin
>>
>>> Andrew H wrote:
>>>> Hi Martin
>>>>
>>>> There are a few problems with this
>>>>
>>>> 1/ The models have come from industry standard schemas. We are trying
>>>> to avoid any manual changes to the models at this stage. At this
>>>> stage we are relying on purely automatic and essentially cosmetic
>>>> refactoring of the model (e.g. breaking it up into separate packages
>>>> and moving classes around a bit, but no changes to the actual classes
>>>> themselves). The reasons for this is that the model is so large it
>>>> will take us a while to understand it well enough to consider
>>>> altering it and secondly we will always need to maintain
>>>> compatibility with it so the more we alter it the more we will need
>>>> custom transformations to import / export to the standard.
>>>>
>>>> 2/ The base types don't have id fields in this case. Teneo is
>>>> generating the eId fields for these.
>>>>
>>>> 3/ Setting PersistenceOptions.ID_FEATURE_AS_PRIMARY_KEY to false
>>>> means that we will lose this feature for our own models. For our hand
>>>> written models we will (and have) made use of id fields on our base
>>>> classes. We like that teneo generates id elements for these.
>>>>
>>>> The problem really stems from two issues
>>>>
>>>> i/ The industry XSD's are using id's for an XML oriented technique
>>>> for referring to elements that are not child elements of the current
>>>> element. i.e. they are not considering the impact this has on an
>>>> implementation model such as ecore and the ramifications for
>>>> persistence. i.e. from the XSD point of view adding id fields to sub
>>>> types is not an issue.
>>>>
>>>> ii/ Teneo has a mapping bug in this case. Even if it is something
>>>> best avoided in an ecore model, its still the case that Teneo creates
>>>> a hibernate mapping that does not conform to the hibernate XSD.
>>>> Surely that should not happen. At the worst case it should throw an
>>>> exception but I still think that generating a unique property is the
>>>> best answer. Is this not possible / desirable?
>>>>
>>>> Another possible avenue for us is if we can customise the mapping
>>>> from XSD such that the field remains an ID field in XML but is not an
>>>> ID field in ecore. I'm not sure if this is possible?
>>>>
>>>> regards
>>>>
>>>> Andrew
>>>>
>>>> Martin Taal wrote:
>>>>
>>>>> Hi Andrew,
>>>>> Would the following approach work in your case:
>>>>> - Annote the id-fields in the supertypes/root of the hierarchy with
>>>>> @Id, and
>>>>> - set the option: PersistenceOptions.ID_FEATURE_AS_PRIMARY_KEY to false
>>>>
>>>>> gr. Martin
>>>>
>>>>> Andrew H wrote:
>>>>>> I just tried adding a comment to
>>>>>> https://bugs.eclipse.org/bugs/show_bug.cgi?id=176821 but bugzilla
>>>>>> seems to be broken. I get an error saying "A Legal Version was not
>>>>>> set"
>>>>>>
>>>>>> So I'll post it as a news item instead for now
>>>>>>
>>>>>> The issue relates to teneo adding id and version fields to subclass
>>>>>> elements which does not comply with the hibernate schema. The
>>>>>> comment was
>>>>>> --
>>>>>>
>>>>>> This is still an issue for me. A large part of our ecore models
>>>>>> originates from industry XSD's which have used ID fields in the
>>>>>> schema on sub types. e.g. they might have a Date base type and an
>>>>>> IdentifiedDate subtype that adds an ID field so they can create
>>>>>> IDREF fields to point to them. i.e. they introduce ID fields in
>>>>>> subtypes specifically so those subtypes can be the target of
>>>>>> IDREF's elsewhere. I'm not sure why they subtyped for this reason.
>>>>>>
>>>>>> As these are ID fields in XSD they come into ecore as ID fields and
>>>>>> cause this problem in teneo.
>>>>>>
>>>>>> Sure I would be inclined to avoid doing this in my own models but I
>>>>>> don't have any control over these industry schema's
>>>>>>
>>>>>> Couldn't teneo have a rule that if an ID field appears on a subtype
>>>>>> then simply add the field as a unique property rather than an ID
>>>>>> field.
>>>>>>
>>>>>> e.g. <property name="id" lazy="false" insert="true" update="true"
>>>>>> not-null="false" unique="true" type="java.lang.String">
>>>>>> <column not-null="false" unique="false" name="`false`"/>
>>>>>> </property>
>>>>>>
>>>>>> Turning ID fields off on the whole model with the option is not
>>>>>> desirable either as in general I'd like it to use my ID fields as
>>>>>> PK's when they are there on the base class.
>>>>>>
>>>>>>
>>>>
>>>>
>>>>
>>>>
>>
>>
>>
>>
Re: [Teneo] Invalid Hibernate Mappings for subclasses w/ ID Fields (bugzilla 176 [message #423558 is a reply to message #423544] Thu, 02 October 2008 09:00 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Andrew,
Thanks for reporting back. I will keep the bugzilla for now because it can make sense to be a bit
more lenient when the subtype has an ID field.

gr. Martin

Andrew H wrote:
> Strange, I replied to this yesterday but it seems to have been lost.
>
> I was able to create a new bugzilla when I did it from scratch rather
> than trying to clone the other issue. Issue is
> https://bugs.eclipse.org/bugs/show_bug.cgi?id=249246
>
> Note, however, that after I filed this I progressed my persistence code
> further and realised that the ID fields that originate from the XSD's
> are not suitable as primary keys in the database. They are only intended
> to be unique within a single document.
>
> So in the end I used the option you suggested to turn off generation of
> primary key fields for these fields.
>
> Consequently, getting a fix for this is no longer a priority for us.
> Apologies for the noise. Let me know if you want me to shut the issue down.
>
> I'd be interested in Ed and others thoughts on ID fields. EMF seems to
> default XSD ID fields to ID fields in EMF and Teneo then defaults to
> setting these as the primary keys. I'm not clear on whether turning this
> off in teneo is the right approach or whether I should look to turn it
> off in EMF. i.e. are ID fields in EMF supposed to be effectively primary
> keys for that class? If so then the mapping from XSD ID is questionable
>
> cheers
>
> Andrew
>
> Martin Taal wrote:
>
>> You also get this when entering a new bugzilla?
>
>> gr. Martin
>
>> Andrew H wrote:
>>> Thanks Martin
>>>
>>> Appreciate this.
>>>
>>> Unfortunately, I can't get bugzilla to work. I get
>>> Bugzilla has suffered an internal error. Please save this page and
>>> send it to webmaster@eclipse.org with details of what you were doing
>>> at the time this message appeared.
>>>
>>> URL: https://bugs.eclipse.org/bugs/post_bug.cgi
>>> A legal Version was not set.
>>>
>>> cheers
>>>
>>> Andrew
>>>
>>> Martin Taal wrote:
>>>
>>>> Hi Andrew,
>>>> Okay, I will change it so that an ID efeature in a subtype is
>>>> ignored (and a
>>> warning is logged).
>>>
>>>> Can you enter a new bugzilla or reopen the old one for this?
>>>
>>>> gr. Martin
>>>
>>>> Andrew H wrote:
>>>>> Hi Martin
>>>>>
>>>>> There are a few problems with this
>>>>>
>>>>> 1/ The models have come from industry standard schemas. We are
>>>>> trying to avoid any manual changes to the models at this stage. At
>>>>> this stage we are relying on purely automatic and essentially
>>>>> cosmetic refactoring of the model (e.g. breaking it up into
>>>>> separate packages and moving classes around a bit, but no changes
>>>>> to the actual classes themselves). The reasons for this is that the
>>>>> model is so large it will take us a while to understand it well
>>>>> enough to consider altering it and secondly we will always need to
>>>>> maintain compatibility with it so the more we alter it the more we
>>>>> will need custom transformations to import / export to the standard.
>>>>>
>>>>> 2/ The base types don't have id fields in this case. Teneo is
>>>>> generating the eId fields for these.
>>>>>
>>>>> 3/ Setting PersistenceOptions.ID_FEATURE_AS_PRIMARY_KEY to false
>>>>> means that we will lose this feature for our own models. For our
>>>>> hand written models we will (and have) made use of id fields on our
>>>>> base classes. We like that teneo generates id elements for these.
>>>>>
>>>>> The problem really stems from two issues
>>>>>
>>>>> i/ The industry XSD's are using id's for an XML oriented technique
>>>>> for referring to elements that are not child elements of the
>>>>> current element. i.e. they are not considering the impact this has
>>>>> on an implementation model such as ecore and the ramifications for
>>>>> persistence. i.e. from the XSD point of view adding id fields to
>>>>> sub types is not an issue.
>>>>>
>>>>> ii/ Teneo has a mapping bug in this case. Even if it is something
>>>>> best avoided in an ecore model, its still the case that Teneo
>>>>> creates a hibernate mapping that does not conform to the hibernate
>>>>> XSD. Surely that should not happen. At the worst case it should
>>>>> throw an exception but I still think that generating a unique
>>>>> property is the best answer. Is this not possible / desirable?
>>>>>
>>>>> Another possible avenue for us is if we can customise the mapping
>>>>> from XSD such that the field remains an ID field in XML but is not
>>>>> an ID field in ecore. I'm not sure if this is possible?
>>>>>
>>>>> regards
>>>>>
>>>>> Andrew
>>>>>
>>>>> Martin Taal wrote:
>>>>>
>>>>>> Hi Andrew,
>>>>>> Would the following approach work in your case:
>>>>>> - Annote the id-fields in the supertypes/root of the hierarchy
>>>>>> with @Id, and
>>>>>> - set the option: PersistenceOptions.ID_FEATURE_AS_PRIMARY_KEY to
>>>>>> false
>>>>>
>>>>>> gr. Martin
>>>>>
>>>>>> Andrew H wrote:
>>>>>>> I just tried adding a comment to
>>>>>>> https://bugs.eclipse.org/bugs/show_bug.cgi?id=176821 but bugzilla
>>>>>>> seems to be broken. I get an error saying "A Legal Version was
>>>>>>> not set"
>>>>>>>
>>>>>>> So I'll post it as a news item instead for now
>>>>>>>
>>>>>>> The issue relates to teneo adding id and version fields to
>>>>>>> subclass elements which does not comply with the hibernate
>>>>>>> schema. The comment was
>>>>>>> --
>>>>>>>
>>>>>>> This is still an issue for me. A large part of our ecore models
>>>>>>> originates from industry XSD's which have used ID fields in the
>>>>>>> schema on sub types. e.g. they might have a Date base type and an
>>>>>>> IdentifiedDate subtype that adds an ID field so they can create
>>>>>>> IDREF fields to point to them. i.e. they introduce ID fields in
>>>>>>> subtypes specifically so those subtypes can be the target of
>>>>>>> IDREF's elsewhere. I'm not sure why they subtyped for this reason.
>>>>>>>
>>>>>>> As these are ID fields in XSD they come into ecore as ID fields
>>>>>>> and cause this problem in teneo.
>>>>>>>
>>>>>>> Sure I would be inclined to avoid doing this in my own models but
>>>>>>> I don't have any control over these industry schema's
>>>>>>>
>>>>>>> Couldn't teneo have a rule that if an ID field appears on a
>>>>>>> subtype then simply add the field as a unique property rather
>>>>>>> than an ID field.
>>>>>>>
>>>>>>> e.g. <property name="id" lazy="false" insert="true" update="true"
>>>>>>> not-null="false" unique="true" type="java.lang.String">
>>>>>>> <column not-null="false" unique="false" name="`false`"/>
>>>>>>> </property>
>>>>>>>
>>>>>>> Turning ID fields off on the whole model with the option is not
>>>>>>> desirable either as in general I'd like it to use my ID fields as
>>>>>>> PK's when they are there on the base class.
>>>>>>>
>>>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>
>>>
>>>
>>>
>
>
>
>


--

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] Invalid Hibernate Mappings for subclasses w/ ID Fields (bugzilla 176 [message #423611 is a reply to message #423558] Thu, 02 October 2008 23:50 Go to previous message
Andrew H is currently offline Andrew HFriend
Messages: 117
Registered: July 2009
Senior Member
Thanks Martin

I agree its best not to have cases where it produces mappings that don't
comply to the schema.

Martin Taal wrote:

> Hi Andrew,
> Thanks for reporting back. I will keep the bugzilla for now because it can
make sense to be a bit
> more lenient when the subtype has an ID field.

> gr. Martin

> Andrew H wrote:
>> Strange, I replied to this yesterday but it seems to have been lost.
>>
>> I was able to create a new bugzilla when I did it from scratch rather
>> than trying to clone the other issue. Issue is
>> https://bugs.eclipse.org/bugs/show_bug.cgi?id=249246
>>
>> Note, however, that after I filed this I progressed my persistence code
>> further and realised that the ID fields that originate from the XSD's
>> are not suitable as primary keys in the database. They are only intended
>> to be unique within a single document.
>>
>> So in the end I used the option you suggested to turn off generation of
>> primary key fields for these fields.
>>
>> Consequently, getting a fix for this is no longer a priority for us.
>> Apologies for the noise. Let me know if you want me to shut the issue down.
>>
>> I'd be interested in Ed and others thoughts on ID fields. EMF seems to
>> default XSD ID fields to ID fields in EMF and Teneo then defaults to
>> setting these as the primary keys. I'm not clear on whether turning this
>> off in teneo is the right approach or whether I should look to turn it
>> off in EMF. i.e. are ID fields in EMF supposed to be effectively primary
>> keys for that class? If so then the mapping from XSD ID is questionable
>>
>> cheers
>>
>> Andrew
>>
>> Martin Taal wrote:
>>
>>> You also get this when entering a new bugzilla?
>>
>>> gr. Martin
>>
>>> Andrew H wrote:
>>>> Thanks Martin
>>>>
>>>> Appreciate this.
>>>>
>>>> Unfortunately, I can't get bugzilla to work. I get
>>>> Bugzilla has suffered an internal error. Please save this page and
>>>> send it to webmaster@eclipse.org with details of what you were doing
>>>> at the time this message appeared.
>>>>
>>>> URL: https://bugs.eclipse.org/bugs/post_bug.cgi
>>>> A legal Version was not set.
>>>>
>>>> cheers
>>>>
>>>> Andrew
>>>>
>>>> Martin Taal wrote:
>>>>
>>>>> Hi Andrew,
>>>>> Okay, I will change it so that an ID efeature in a subtype is
>>>>> ignored (and a
>>>> warning is logged).
>>>>
>>>>> Can you enter a new bugzilla or reopen the old one for this?
>>>>
>>>>> gr. Martin
>>>>
>>>>> Andrew H wrote:
>>>>>> Hi Martin
>>>>>>
>>>>>> There are a few problems with this
>>>>>>
>>>>>> 1/ The models have come from industry standard schemas. We are
>>>>>> trying to avoid any manual changes to the models at this stage. At
>>>>>> this stage we are relying on purely automatic and essentially
>>>>>> cosmetic refactoring of the model (e.g. breaking it up into
>>>>>> separate packages and moving classes around a bit, but no changes
>>>>>> to the actual classes themselves). The reasons for this is that the
>>>>>> model is so large it will take us a while to understand it well
>>>>>> enough to consider altering it and secondly we will always need to
>>>>>> maintain compatibility with it so the more we alter it the more we
>>>>>> will need custom transformations to import / export to the standard.
>>>>>>
>>>>>> 2/ The base types don't have id fields in this case. Teneo is
>>>>>> generating the eId fields for these.
>>>>>>
>>>>>> 3/ Setting PersistenceOptions.ID_FEATURE_AS_PRIMARY_KEY to false
>>>>>> means that we will lose this feature for our own models. For our
>>>>>> hand written models we will (and have) made use of id fields on our
>>>>>> base classes. We like that teneo generates id elements for these.
>>>>>>
>>>>>> The problem really stems from two issues
>>>>>>
>>>>>> i/ The industry XSD's are using id's for an XML oriented technique
>>>>>> for referring to elements that are not child elements of the
>>>>>> current element. i.e. they are not considering the impact this has
>>>>>> on an implementation model such as ecore and the ramifications for
>>>>>> persistence. i.e. from the XSD point of view adding id fields to
>>>>>> sub types is not an issue.
>>>>>>
>>>>>> ii/ Teneo has a mapping bug in this case. Even if it is something
>>>>>> best avoided in an ecore model, its still the case that Teneo
>>>>>> creates a hibernate mapping that does not conform to the hibernate
>>>>>> XSD. Surely that should not happen. At the worst case it should
>>>>>> throw an exception but I still think that generating a unique
>>>>>> property is the best answer. Is this not possible / desirable?
>>>>>>
>>>>>> Another possible avenue for us is if we can customise the mapping
>>>>>> from XSD such that the field remains an ID field in XML but is not
>>>>>> an ID field in ecore. I'm not sure if this is possible?
>>>>>>
>>>>>> regards
>>>>>>
>>>>>> Andrew
>>>>>>
>>>>>> Martin Taal wrote:
>>>>>>
>>>>>>> Hi Andrew,
>>>>>>> Would the following approach work in your case:
>>>>>>> - Annote the id-fields in the supertypes/root of the hierarchy
>>>>>>> with @Id, and
>>>>>>> - set the option: PersistenceOptions.ID_FEATURE_AS_PRIMARY_KEY to
>>>>>>> false
>>>>>>
>>>>>>> gr. Martin
>>>>>>
>>>>>>> Andrew H wrote:
>>>>>>>> I just tried adding a comment to
>>>>>>>> https://bugs.eclipse.org/bugs/show_bug.cgi?id=176821 but bugzilla
>>>>>>>> seems to be broken. I get an error saying "A Legal Version was
>>>>>>>> not set"
>>>>>>>>
>>>>>>>> So I'll post it as a news item instead for now
>>>>>>>>
>>>>>>>> The issue relates to teneo adding id and version fields to
>>>>>>>> subclass elements which does not comply with the hibernate
>>>>>>>> schema. The comment was
>>>>>>>> --
>>>>>>>>
>>>>>>>> This is still an issue for me. A large part of our ecore models
>>>>>>>> originates from industry XSD's which have used ID fields in the
>>>>>>>> schema on sub types. e.g. they might have a Date base type and an
>>>>>>>> IdentifiedDate subtype that adds an ID field so they can create
>>>>>>>> IDREF fields to point to them. i.e. they introduce ID fields in
>>>>>>>> subtypes specifically so those subtypes can be the target of
>>>>>>>> IDREF's elsewhere. I'm not sure why they subtyped for this reason.
>>>>>>>>
>>>>>>>> As these are ID fields in XSD they come into ecore as ID fields
>>>>>>>> and cause this problem in teneo.
>>>>>>>>
>>>>>>>> Sure I would be inclined to avoid doing this in my own models but
>>>>>>>> I don't have any control over these industry schema's
>>>>>>>>
>>>>>>>> Couldn't teneo have a rule that if an ID field appears on a
>>>>>>>> subtype then simply add the field as a unique property rather
>>>>>>>> than an ID field.
>>>>>>>>
>>>>>>>> e.g. <property name="id" lazy="false" insert="true" update="true"
>>>>>>>> not-null="false" unique="true" type="java.lang.String">
>>>>>>>> <column not-null="false" unique="false" name="`false`"/>
>>>>>>>> </property>
>>>>>>>>
>>>>>>>> Turning ID fields off on the whole model with the option is not
>>>>>>>> desirable either as in general I'd like it to use my ID fields as
>>>>>>>> PK's when they are there on the base class.
>>>>>>>>
>>>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>
>>>>
>>>>
>>>>
>>
>>
>>
>>
Previous Topic:NPE in EPackageImpl.initializeFromLoadedEPackage when loadInitialization="true"
Next Topic:EMF eclipsecon07 tutorial materials ?
Goto Forum:
  


Current Time: Wed Sep 30 23:34:00 GMT 2020

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

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

Back to the top