Home » Modeling » EMF "Technology" (Ecore Tools, EMFatic, etc) » teneo - why tables for interfaces?
teneo - why tables for interfaces? [message #60559] |
Fri, 10 November 2006 14:38 ![Go to next message Go to next message](theme/Solstice/images/down.png) |
Andre Pareis![Friend of Eclipse Friend](/donate/web-api/friends_decorator.php?email=andre.pareis%40entura.ch) Messages: 113 Registered: July 2009 |
Senior Member |
|
|
Hi,
IIRC, the former teneo implementation (elver) did not create tables for interface, whereas the new one does.
I have, for example, an interface called "Identifiable" declaring an "id" attribute. This way I can add the "id" feature to some classes by just realizing this
interface. I would also like to have a "Named" interface with an attribute "name", which can be added in addition to the Identifiable interface.
I'm not sure if this is possible at all and how it would look like. However, even if, my concerns with mapped interfaces are these:
1. It is IMO not desirable to see tables for interfaces as this can be translated as implementation. Instead, the attributes defined in the interface should be
implemented only and first in the classes implementing the interface.
2. I wonder if the current approach allows a JOINED mapping strategy whilst having multiple super interfaces each declaring some attribute, i.e., multiple
inheritance as it is possible with EMF, which is capable of implementing the declared attributes in all classes implementing an interface.
3. As a side effect of the current solution: If I use SINGLE_TABLE at present, then all classes implementing the Identifiable interface (there are many) go into
the "IDENTIFIABLE" table, which looks extremely denormalized.
I would be interested in your opinion and in the rationale behind the current approach.
Regards
Andre
|
|
|
Re: teneo - why tables for interfaces? [message #60570 is a reply to message #60559] |
Fri, 10 November 2006 16:22 ![Go to previous message Go to previous message](theme/Solstice/images/up.png) ![Go to next message Go to next message](theme/Solstice/images/down.png) |
Martin Taal![Friend of Eclipse Friend](/donate/web-api/friends_decorator.php?email=mtaal%40springsite.com) Messages: 5468 Registered: July 2009 |
Senior Member |
|
|
Hi Andre,
Teneo maps the model and not the actual java implementations classes/interfaces. By also explicitly
mapping the types (with interface=true) modeled it is possible to do polymorphic queries on the
interface eclass.
The reason that in case of multiple inheritance mappings are created for each superinterface
(although Hibernate does not support multiple inheritance, and only the first is used) is that Teneo
currently does not identify if a type is used as the second or third type or also as a first
supertype somewhere (see bug link below).
As an example, say there is a SchoolBook type which inherits from types Book and Asset. In this case
EMF will let SchoolBookImpl inherit from BookImpl and the SchoolBook interface from Book and Asset
interfaces.
Teneo will generate a mapping for SchoolBook, Book and Asset, The SchoolBook mapping will have an
extends attribute pointing to Book. The attributes of Asset are mapped directly in SchoolBook but
there is no relation between SchoolBook and Asset but the Asset attributes are mapped correctly (in
the SchoolBook mapping). Asset is in a way treated as a mappedsuperclass.
In this case the mapping (and table) for Asset is not stricly required and can be removed. However
Teneo then needs to discover that there are no other subtypes which have Asset as the first
supertype. This feature needs to be added. I entered this myself as a bug (see issue below) in august.
Btw, you can prevent explicit mapping of the extra interface classes by using the MappedSuperClass
annotation (on the interface types). This annotation will/should also prevent all classes to be
persisted in one table in case of single table (if you the single root is denoted as a
mappedsuperclass).
Regarding joined, in case of multiple inheritance the first supertype is considered the real super,
the others are treated as a mappedsuperclasses. So joined will work but only use one path to the root.
Here are some other related links:
https://bugs.eclipse.org/bugs/show_bug.cgi?id=153746
http://www.elver.org/hibernate/inheritance.html#Multiple+Inh eritance+Support
http://comments.gmane.org/gmane.comp.java.emf.persistency/64 5
http://forum.hibernate.org/viewtopic.php?t=947670
gr. Martin
Andre Pareis wrote:
> Hi,
>
> IIRC, the former teneo implementation (elver) did not create tables for
> interface, whereas the new one does.
>
> I have, for example, an interface called "Identifiable" declaring an
> "id" attribute. This way I can add the "id" feature to some classes by
> just realizing this interface. I would also like to have a "Named"
> interface with an attribute "name", which can be added in addition to
> the Identifiable interface.
>
> I'm not sure if this is possible at all and how it would look like.
> However, even if, my concerns with mapped interfaces are these:
>
> 1. It is IMO not desirable to see tables for interfaces as this can be
> translated as implementation. Instead, the attributes defined in the
> interface should be implemented only and first in the classes
> implementing the interface.
>
> 2. I wonder if the current approach allows a JOINED mapping strategy
> whilst having multiple super interfaces each declaring some attribute,
> i.e., multiple inheritance as it is possible with EMF, which is capable
> of implementing the declared attributes in all classes implementing an
> interface.
>
> 3. As a side effect of the current solution: If I use SINGLE_TABLE at
> present, then all classes implementing the Identifiable interface (there
> are many) go into the "IDENTIFIABLE" table, which looks extremely
> denormalized.
>
> I would be interested in your opinion and in the rationale behind the
> current approach.
>
> Regards
> Andre
--
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 - why tables for interfaces? [message #60571 is a reply to message #60570] |
Fri, 10 November 2006 17:43 ![Go to previous message Go to previous message](theme/Solstice/images/up.png) ![Go to next message Go to next message](theme/Solstice/images/down.png) |
Andre Pareis![Friend of Eclipse Friend](/donate/web-api/friends_decorator.php?email=andre.pareis%40entura.ch) Messages: 113 Registered: July 2009 |
Senior Member |
|
|
Thanks Martin, that makes perfect sense. I have added the @MappedSuperClass to
my super interface (Identifiable) now. But I'm getting XML parser exceptions:
1547 [main] ERROR org.hibernate.util.XMLHelper - Error parsing XML: XML
String(44) The content of element type "class" must match
" (meta*,subselect?,cache?,synchronize*,comment?,tuplizer*,(id |composite-id),discriminator?,natural-id?,(version|timestamp )?,(property|many-to-one|one-to-one|component|dynamic-compon ent|properties|any|map|set|list|bag|idbag|array|primitive-ar ray)*,((join*,subclass*)|joined-subclass*|union-subclass*),l oader?,sql-insert?,sql-update?,sql-delete?,filter*,resultset *,(query|sql-query)*) ".
....
<!-- Generated by Teneo on Fri Nov 10 18:27:53 CET 2006 -->
<hibernate-mapping>
<class entity-name="Instrument" abstract="true" lazy="false" table="`Instrument`">
<property name="id" type="java.lang.String" lazy="false" column="`id`"
not-null="false"/>
<property name="name" type="java.lang.String" lazy="false" column="`name`"
not-null="false"/>
<many-to-one name="Client" entity-name="Client"
cascade="merge,persist,save-update,lock,refresh" lazy="false" insert="false"
update="false" not-null="false">
<column not-null="false" unique="false" name="`Instrument_Client_id`"/>
</many-to-one>
<list name="symbols" lazy="true" cascade="all,delete-orphan">
<key update="true">
<column name="`Symbol_instrument_id`" not-null="false" unique="false"/>
</key>
<list-index column="`INSTRUMENT_SYMBOLS_IDX`"/>
<one-to-many entity-name="Symbol"/>
</list>
<list name="categories" lazy="true"
cascade="merge,persist,save-update,lock,refresh" table="Instrument_Category">
<key update="true">
<column name="`Instrument_id`" not-null="true" unique="false"/>
</key>
<list-index column="`INSTRUMENT_CATEGORIES_IDX`"/>
<many-to-many entity-name="Category" unique="false">
<column name="`Category_id`" not-null="true" unique="false"/>
</many-to-many>
</list>
<list name="options" lazy="true" cascade="all,delete-orphan">
<key update="true">
<column name="`Option_underlying_id`" not-null="false" unique="false"/>
</key>
<list-index column="`INSTRUMENT_OPTIONS_IDX`"/>
<one-to-many entity-name="Option"/>
</list>
<list name="optionSources" lazy="true"
cascade="merge,persist,save-update,lock,refresh" table="Instrument_OptionSource">
<key update="true">
<column name="`Instrument_id`" not-null="true" unique="false"/>
</key>
<list-index column="`INSTRUMENT_OPTIONSOURCES_IDX`"/>
<many-to-many entity-name="OptionSource" unique="false">
<column name="`OptionSource_id`" not-null="true" unique="false"/>
</many-to-many>
</list>
</class>
I think hibernate misses an <id> or <composite-id> inside the <class> tag. The
top-level classes are abstract, can this be the cause of the problem?
THanks
Andre
Martin Taal wrote:
> Hi Andre,
> Teneo maps the model and not the actual java implementations
> classes/interfaces. By also explicitly mapping the types (with
> interface=true) modeled it is possible to do polymorphic queries on the
> interface eclass.
>
> The reason that in case of multiple inheritance mappings are created for
> each superinterface (although Hibernate does not support multiple
> inheritance, and only the first is used) is that Teneo currently does
> not identify if a type is used as the second or third type or also as a
> first supertype somewhere (see bug link below).
> As an example, say there is a SchoolBook type which inherits from types
> Book and Asset. In this case EMF will let SchoolBookImpl inherit from
> BookImpl and the SchoolBook interface from Book and Asset interfaces.
> Teneo will generate a mapping for SchoolBook, Book and Asset, The
> SchoolBook mapping will have an extends attribute pointing to Book. The
> attributes of Asset are mapped directly in SchoolBook but there is no
> relation between SchoolBook and Asset but the Asset attributes are
> mapped correctly (in the SchoolBook mapping). Asset is in a way treated
> as a mappedsuperclass.
> In this case the mapping (and table) for Asset is not stricly required
> and can be removed. However Teneo then needs to discover that there are
> no other subtypes which have Asset as the first supertype. This feature
> needs to be added. I entered this myself as a bug (see issue below) in
> august.
>
> Btw, you can prevent explicit mapping of the extra interface classes by
> using the MappedSuperClass annotation (on the interface types). This
> annotation will/should also prevent all classes to be persisted in one
> table in case of single table (if you the single root is denoted as a
> mappedsuperclass).
>
> Regarding joined, in case of multiple inheritance the first supertype is
> considered the real super, the others are treated as a
> mappedsuperclasses. So joined will work but only use one path to the root.
>
> Here are some other related links:
> https://bugs.eclipse.org/bugs/show_bug.cgi?id=153746
> http://www.elver.org/hibernate/inheritance.html#Multiple+Inh eritance+Support
>
> http://comments.gmane.org/gmane.comp.java.emf.persistency/64 5
> http://forum.hibernate.org/viewtopic.php?t=947670
>
> gr. Martin
>
> Andre Pareis wrote:
>> Hi,
>>
>> IIRC, the former teneo implementation (elver) did not create tables
>> for interface, whereas the new one does.
>>
>> I have, for example, an interface called "Identifiable" declaring an
>> "id" attribute. This way I can add the "id" feature to some classes by
>> just realizing this interface. I would also like to have a "Named"
>> interface with an attribute "name", which can be added in addition to
>> the Identifiable interface.
>>
>> I'm not sure if this is possible at all and how it would look like.
>> However, even if, my concerns with mapped interfaces are these:
>>
>> 1. It is IMO not desirable to see tables for interfaces as this can be
>> translated as implementation. Instead, the attributes defined in the
>> interface should be implemented only and first in the classes
>> implementing the interface.
>>
>> 2. I wonder if the current approach allows a JOINED mapping strategy
>> whilst having multiple super interfaces each declaring some attribute,
>> i.e., multiple inheritance as it is possible with EMF, which is
>> capable of implementing the declared attributes in all classes
>> implementing an interface.
>>
>> 3. As a side effect of the current solution: If I use SINGLE_TABLE at
>> present, then all classes implementing the Identifiable interface
>> (there are many) go into the "IDENTIFIABLE" table, which looks
>> extremely denormalized.
>>
>> I would be interested in your opinion and in the rationale behind the
>> current approach.
>>
>> Regards
>> Andre
>
>
|
|
|
Re: teneo - why tables for interfaces? [message #60572 is a reply to message #60571] |
Fri, 10 November 2006 19:36 ![Go to previous message Go to previous message](theme/Solstice/images/up.png) ![Go to next message Go to next message](theme/Solstice/images/down.png) |
Martin Taal![Friend of Eclipse Friend](/donate/web-api/friends_decorator.php?email=mtaal%40springsite.com) Messages: 5468 Registered: July 2009 |
Senior Member |
|
|
Hi Andre,
Can you send me the annotated ecore? Does the id property also have a basic annotation (it should
only have an id annotation).
gr. Martin
Andre Pareis wrote:
> Thanks Martin, that makes perfect sense. I have added the
> @MappedSuperClass to my super interface (Identifiable) now. But I'm
> getting XML parser exceptions:
>
> 1547 [main] ERROR org.hibernate.util.XMLHelper - Error parsing XML: XML
> String(44) The content of element type "class" must match
> " (meta*,subselect?,cache?,synchronize*,comment?,tuplizer*,(id |composite-id),discriminator?,natural-id?,(version|timestamp )?,(property|many-to-one|one-to-one|component|dynamic-compon ent|properties|any|map|set|list|bag|idbag|array|primitive-ar ray)*,((join*,subclass*)|joined-subclass*|union-subclass*),l oader?,sql-insert?,sql-update?,sql-delete?,filter*,resultset *,(query|sql-query)*) ".
>
> ....
>
> <!-- Generated by Teneo on Fri Nov 10 18:27:53 CET 2006 -->
> <hibernate-mapping>
> <class entity-name="Instrument" abstract="true" lazy="false"
> table="`Instrument`">
> <property name="id" type="java.lang.String" lazy="false"
> column="`id`" not-null="false"/>
> <property name="name" type="java.lang.String" lazy="false"
> column="`name`" not-null="false"/>
> <many-to-one name="Client" entity-name="Client"
> cascade="merge,persist,save-update,lock,refresh" lazy="false"
> insert="false" update="false" not-null="false">
> <column not-null="false" unique="false"
> name="`Instrument_Client_id`"/>
> </many-to-one>
> <list name="symbols" lazy="true" cascade="all,delete-orphan">
> <key update="true">
> <column name="`Symbol_instrument_id`" not-null="false"
> unique="false"/>
> </key>
> <list-index column="`INSTRUMENT_SYMBOLS_IDX`"/>
> <one-to-many entity-name="Symbol"/>
> </list>
> <list name="categories" lazy="true"
> cascade="merge,persist,save-update,lock,refresh"
> table="Instrument_Category">
> <key update="true">
> <column name="`Instrument_id`" not-null="true"
> unique="false"/>
> </key>
> <list-index column="`INSTRUMENT_CATEGORIES_IDX`"/>
> <many-to-many entity-name="Category" unique="false">
> <column name="`Category_id`" not-null="true"
> unique="false"/>
> </many-to-many>
> </list>
> <list name="options" lazy="true" cascade="all,delete-orphan">
> <key update="true">
> <column name="`Option_underlying_id`" not-null="false"
> unique="false"/>
> </key>
> <list-index column="`INSTRUMENT_OPTIONS_IDX`"/>
> <one-to-many entity-name="Option"/>
> </list>
> <list name="optionSources" lazy="true"
> cascade="merge,persist,save-update,lock,refresh"
> table="Instrument_OptionSource">
> <key update="true">
> <column name="`Instrument_id`" not-null="true"
> unique="false"/>
> </key>
> <list-index column="`INSTRUMENT_OPTIONSOURCES_IDX`"/>
> <many-to-many entity-name="OptionSource" unique="false">
> <column name="`OptionSource_id`" not-null="true"
> unique="false"/>
> </many-to-many>
> </list>
> </class>
>
> I think hibernate misses an <id> or <composite-id> inside the <class>
> tag. The top-level classes are abstract, can this be the cause of the
> problem?
>
> THanks
> Andre
>
>
> Martin Taal wrote:
>> Hi Andre,
>> Teneo maps the model and not the actual java implementations
>> classes/interfaces. By also explicitly mapping the types (with
>> interface=true) modeled it is possible to do polymorphic queries on
>> the interface eclass.
>>
>> The reason that in case of multiple inheritance mappings are created
>> for each superinterface (although Hibernate does not support multiple
>> inheritance, and only the first is used) is that Teneo currently does
>> not identify if a type is used as the second or third type or also as
>> a first supertype somewhere (see bug link below).
>> As an example, say there is a SchoolBook type which inherits from
>> types Book and Asset. In this case EMF will let SchoolBookImpl inherit
>> from BookImpl and the SchoolBook interface from Book and Asset
>> interfaces.
>> Teneo will generate a mapping for SchoolBook, Book and Asset, The
>> SchoolBook mapping will have an extends attribute pointing to Book.
>> The attributes of Asset are mapped directly in SchoolBook but there is
>> no relation between SchoolBook and Asset but the Asset attributes are
>> mapped correctly (in the SchoolBook mapping). Asset is in a way
>> treated as a mappedsuperclass.
>> In this case the mapping (and table) for Asset is not stricly required
>> and can be removed. However Teneo then needs to discover that there
>> are no other subtypes which have Asset as the first supertype. This
>> feature needs to be added. I entered this myself as a bug (see issue
>> below) in august.
>>
>> Btw, you can prevent explicit mapping of the extra interface classes
>> by using the MappedSuperClass annotation (on the interface types).
>> This annotation will/should also prevent all classes to be persisted
>> in one table in case of single table (if you the single root is
>> denoted as a mappedsuperclass).
>>
>> Regarding joined, in case of multiple inheritance the first supertype
>> is considered the real super, the others are treated as a
>> mappedsuperclasses. So joined will work but only use one path to the
>> root.
>>
>> Here are some other related links:
>> https://bugs.eclipse.org/bugs/show_bug.cgi?id=153746
>> http://www.elver.org/hibernate/inheritance.html#Multiple+Inh eritance+Support
>>
>> http://comments.gmane.org/gmane.comp.java.emf.persistency/64 5
>> http://forum.hibernate.org/viewtopic.php?t=947670
>>
>> gr. Martin
>>
>> Andre Pareis wrote:
>>> Hi,
>>>
>>> IIRC, the former teneo implementation (elver) did not create tables
>>> for interface, whereas the new one does.
>>>
>>> I have, for example, an interface called "Identifiable" declaring an
>>> "id" attribute. This way I can add the "id" feature to some classes
>>> by just realizing this interface. I would also like to have a "Named"
>>> interface with an attribute "name", which can be added in addition to
>>> the Identifiable interface.
>>>
>>> I'm not sure if this is possible at all and how it would look like.
>>> However, even if, my concerns with mapped interfaces are these:
>>>
>>> 1. It is IMO not desirable to see tables for interfaces as this can
>>> be translated as implementation. Instead, the attributes defined in
>>> the interface should be implemented only and first in the classes
>>> implementing the interface.
>>>
>>> 2. I wonder if the current approach allows a JOINED mapping strategy
>>> whilst having multiple super interfaces each declaring some
>>> attribute, i.e., multiple inheritance as it is possible with EMF,
>>> which is capable of implementing the declared attributes in all
>>> classes implementing an interface.
>>>
>>> 3. As a side effect of the current solution: If I use SINGLE_TABLE at
>>> present, then all classes implementing the Identifiable interface
>>> (there are many) go into the "IDENTIFIABLE" table, which looks
>>> extremely denormalized.
>>>
>>> I would be interested in your opinion and in the rationale behind the
>>> current approach.
>>>
>>> Regards
>>> Andre
>>
>>
--
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 - why tables for interfaces? [message #60900 is a reply to message #60572] |
Fri, 10 November 2006 20:01 ![Go to previous message Go to previous message](theme/Solstice/images/up.png) ![Go to next message Go to next message](theme/Solstice/images/down.png) |
Andre Pareis![Friend of Eclipse Friend](/donate/web-api/friends_decorator.php?email=andre.pareis%40entura.ch) Messages: 113 Registered: July 2009 |
Senior Member |
|
|
Martin,
No the id attribute is just a normal attribute, it does not have ID semantics
and no annotations at all. I expected teneo to generate a primary key for my
classes.
I can send you the ecore if that does not help.
-Andre
Martin Taal wrote:
> Hi Andre,
> Can you send me the annotated ecore? Does the id property also have a
> basic annotation (it should only have an id annotation).
>
> gr. Martin
>
> Andre Pareis wrote:
>> Thanks Martin, that makes perfect sense. I have added the
>> @MappedSuperClass to my super interface (Identifiable) now. But I'm
>> getting XML parser exceptions:
>>
>> 1547 [main] ERROR org.hibernate.util.XMLHelper - Error parsing XML:
>> XML String(44) The content of element type "class" must match
>> " (meta*,subselect?,cache?,synchronize*,comment?,tuplizer*,(id |composite-id),discriminator?,natural-id?,(version|timestamp )?,(property|many-to-one|one-to-one|component|dynamic-compon ent|properties|any|map|set|list|bag|idbag|array|primitive-ar ray)*,((join*,subclass*)|joined-subclass*|union-subclass*),l oader?,sql-insert?,sql-update?,sql-delete?,filter*,resultset *,(query|sql-query)*) ".
>>
>> ....
>>
>> <!-- Generated by Teneo on Fri Nov 10 18:27:53 CET 2006 -->
>> <hibernate-mapping>
>> <class entity-name="Instrument" abstract="true" lazy="false"
>> table="`Instrument`">
>> <property name="id" type="java.lang.String" lazy="false"
>> column="`id`" not-null="false"/>
>> <property name="name" type="java.lang.String" lazy="false"
>> column="`name`" not-null="false"/>
>> <many-to-one name="Client" entity-name="Client"
>> cascade="merge,persist,save-update,lock,refresh" lazy="false"
>> insert="false" update="false" not-null="false">
>> <column not-null="false" unique="false"
>> name="`Instrument_Client_id`"/>
>> </many-to-one>
>> <list name="symbols" lazy="true" cascade="all,delete-orphan">
>> <key update="true">
>> <column name="`Symbol_instrument_id`" not-null="false"
>> unique="false"/>
>> </key>
>> <list-index column="`INSTRUMENT_SYMBOLS_IDX`"/>
>> <one-to-many entity-name="Symbol"/>
>> </list>
>> <list name="categories" lazy="true"
>> cascade="merge,persist,save-update,lock,refresh"
>> table="Instrument_Category">
>> <key update="true">
>> <column name="`Instrument_id`" not-null="true"
>> unique="false"/>
>> </key>
>> <list-index column="`INSTRUMENT_CATEGORIES_IDX`"/>
>> <many-to-many entity-name="Category" unique="false">
>> <column name="`Category_id`" not-null="true"
>> unique="false"/>
>> </many-to-many>
>> </list>
>> <list name="options" lazy="true" cascade="all,delete-orphan">
>> <key update="true">
>> <column name="`Option_underlying_id`" not-null="false"
>> unique="false"/>
>> </key>
>> <list-index column="`INSTRUMENT_OPTIONS_IDX`"/>
>> <one-to-many entity-name="Option"/>
>> </list>
>> <list name="optionSources" lazy="true"
>> cascade="merge,persist,save-update,lock,refresh"
>> table="Instrument_OptionSource">
>> <key update="true">
>> <column name="`Instrument_id`" not-null="true"
>> unique="false"/>
>> </key>
>> <list-index column="`INSTRUMENT_OPTIONSOURCES_IDX`"/>
>> <many-to-many entity-name="OptionSource" unique="false">
>> <column name="`OptionSource_id`" not-null="true"
>> unique="false"/>
>> </many-to-many>
>> </list>
>> </class>
>>
>> I think hibernate misses an <id> or <composite-id> inside the <class>
>> tag. The top-level classes are abstract, can this be the cause of the
>> problem?
>>
>> THanks
>> Andre
>>
>>
>> Martin Taal wrote:
>>> Hi Andre,
>>> Teneo maps the model and not the actual java implementations
>>> classes/interfaces. By also explicitly mapping the types (with
>>> interface=true) modeled it is possible to do polymorphic queries on
>>> the interface eclass.
>>>
>>> The reason that in case of multiple inheritance mappings are created
>>> for each superinterface (although Hibernate does not support multiple
>>> inheritance, and only the first is used) is that Teneo currently does
>>> not identify if a type is used as the second or third type or also as
>>> a first supertype somewhere (see bug link below).
>>> As an example, say there is a SchoolBook type which inherits from
>>> types Book and Asset. In this case EMF will let SchoolBookImpl
>>> inherit from BookImpl and the SchoolBook interface from Book and
>>> Asset interfaces.
>>> Teneo will generate a mapping for SchoolBook, Book and Asset, The
>>> SchoolBook mapping will have an extends attribute pointing to Book.
>>> The attributes of Asset are mapped directly in SchoolBook but there
>>> is no relation between SchoolBook and Asset but the Asset attributes
>>> are mapped correctly (in the SchoolBook mapping). Asset is in a way
>>> treated as a mappedsuperclass.
>>> In this case the mapping (and table) for Asset is not stricly
>>> required and can be removed. However Teneo then needs to discover
>>> that there are no other subtypes which have Asset as the first
>>> supertype. This feature needs to be added. I entered this myself as a
>>> bug (see issue below) in august.
>>>
>>> Btw, you can prevent explicit mapping of the extra interface classes
>>> by using the MappedSuperClass annotation (on the interface types).
>>> This annotation will/should also prevent all classes to be persisted
>>> in one table in case of single table (if you the single root is
>>> denoted as a mappedsuperclass).
>>>
>>> Regarding joined, in case of multiple inheritance the first supertype
>>> is considered the real super, the others are treated as a
>>> mappedsuperclasses. So joined will work but only use one path to the
>>> root.
>>>
>>> Here are some other related links:
>>> https://bugs.eclipse.org/bugs/show_bug.cgi?id=153746
>>> http://www.elver.org/hibernate/inheritance.html#Multiple+Inh eritance+Support
>>>
>>> http://comments.gmane.org/gmane.comp.java.emf.persistency/64 5
>>> http://forum.hibernate.org/viewtopic.php?t=947670
>>>
>>> gr. Martin
>>>
>>> Andre Pareis wrote:
>>>> Hi,
>>>>
>>>> IIRC, the former teneo implementation (elver) did not create tables
>>>> for interface, whereas the new one does.
>>>>
>>>> I have, for example, an interface called "Identifiable" declaring an
>>>> "id" attribute. This way I can add the "id" feature to some classes
>>>> by just realizing this interface. I would also like to have a
>>>> "Named" interface with an attribute "name", which can be added in
>>>> addition to the Identifiable interface.
>>>>
>>>> I'm not sure if this is possible at all and how it would look like.
>>>> However, even if, my concerns with mapped interfaces are these:
>>>>
>>>> 1. It is IMO not desirable to see tables for interfaces as this can
>>>> be translated as implementation. Instead, the attributes defined in
>>>> the interface should be implemented only and first in the classes
>>>> implementing the interface.
>>>>
>>>> 2. I wonder if the current approach allows a JOINED mapping strategy
>>>> whilst having multiple super interfaces each declaring some
>>>> attribute, i.e., multiple inheritance as it is possible with EMF,
>>>> which is capable of implementing the declared attributes in all
>>>> classes implementing an interface.
>>>>
>>>> 3. As a side effect of the current solution: If I use SINGLE_TABLE
>>>> at present, then all classes implementing the Identifiable interface
>>>> (there are many) go into the "IDENTIFIABLE" table, which looks
>>>> extremely denormalized.
>>>>
>>>> I would be interested in your opinion and in the rationale behind
>>>> the current approach.
>>>>
>>>> Regards
>>>> Andre
>>>
>>>
>
>
|
|
|
Re: teneo - why tables for interfaces? [message #60947 is a reply to message #60900] |
Fri, 10 November 2006 20:44 ![Go to previous message Go to previous message](theme/Solstice/images/up.png) ![Go to next message Go to next message](theme/Solstice/images/down.png) |
Martin Taal![Friend of Eclipse Friend](/donate/web-api/friends_decorator.php?email=mtaal%40springsite.com) Messages: 5468 Registered: July 2009 |
Senior Member |
|
|
Ha I see, the current logic assumes that if there is a mappedsuperclass that there is then an
explicit id feature definition (in the mappedsuperclass). This is a bug/missing feature. I have
solved it now. I will check it in later.
gr. Martin
Andre Pareis wrote:
> Martin,
>
> No the id attribute is just a normal attribute, it does not have ID
> semantics and no annotations at all. I expected teneo to generate a
> primary key for my classes.
>
> I can send you the ecore if that does not help.
>
> -Andre
>
>
> Martin Taal wrote:
>> Hi Andre,
>> Can you send me the annotated ecore? Does the id property also have a
>> basic annotation (it should only have an id annotation).
>>
>> gr. Martin
>>
>> Andre Pareis wrote:
>>> Thanks Martin, that makes perfect sense. I have added the
>>> @MappedSuperClass to my super interface (Identifiable) now. But I'm
>>> getting XML parser exceptions:
>>>
>>> 1547 [main] ERROR org.hibernate.util.XMLHelper - Error parsing XML:
>>> XML String(44) The content of element type "class" must match
>>> " (meta*,subselect?,cache?,synchronize*,comment?,tuplizer*,(id |composite-id),discriminator?,natural-id?,(version|timestamp )?,(property|many-to-one|one-to-one|component|dynamic-compon ent|properties|any|map|set|list|bag|idbag|array|primitive-ar ray)*,((join*,subclass*)|joined-subclass*|union-subclass*),l oader?,sql-insert?,sql-update?,sql-delete?,filter*,resultset *,(query|sql-query)*) ".
>>>
>>> ....
>>>
>>> <!-- Generated by Teneo on Fri Nov 10 18:27:53 CET 2006 -->
>>> <hibernate-mapping>
>>> <class entity-name="Instrument" abstract="true" lazy="false"
>>> table="`Instrument`">
>>> <property name="id" type="java.lang.String" lazy="false"
>>> column="`id`" not-null="false"/>
>>> <property name="name" type="java.lang.String" lazy="false"
>>> column="`name`" not-null="false"/>
>>> <many-to-one name="Client" entity-name="Client"
>>> cascade="merge,persist,save-update,lock,refresh" lazy="false"
>>> insert="false" update="false" not-null="false">
>>> <column not-null="false" unique="false"
>>> name="`Instrument_Client_id`"/>
>>> </many-to-one>
>>> <list name="symbols" lazy="true" cascade="all,delete-orphan">
>>> <key update="true">
>>> <column name="`Symbol_instrument_id`"
>>> not-null="false" unique="false"/>
>>> </key>
>>> <list-index column="`INSTRUMENT_SYMBOLS_IDX`"/>
>>> <one-to-many entity-name="Symbol"/>
>>> </list>
>>> <list name="categories" lazy="true"
>>> cascade="merge,persist,save-update,lock,refresh"
>>> table="Instrument_Category">
>>> <key update="true">
>>> <column name="`Instrument_id`" not-null="true"
>>> unique="false"/>
>>> </key>
>>> <list-index column="`INSTRUMENT_CATEGORIES_IDX`"/>
>>> <many-to-many entity-name="Category" unique="false">
>>> <column name="`Category_id`" not-null="true"
>>> unique="false"/>
>>> </many-to-many>
>>> </list>
>>> <list name="options" lazy="true" cascade="all,delete-orphan">
>>> <key update="true">
>>> <column name="`Option_underlying_id`"
>>> not-null="false" unique="false"/>
>>> </key>
>>> <list-index column="`INSTRUMENT_OPTIONS_IDX`"/>
>>> <one-to-many entity-name="Option"/>
>>> </list>
>>> <list name="optionSources" lazy="true"
>>> cascade="merge,persist,save-update,lock,refresh"
>>> table="Instrument_OptionSource">
>>> <key update="true">
>>> <column name="`Instrument_id`" not-null="true"
>>> unique="false"/>
>>> </key>
>>> <list-index column="`INSTRUMENT_OPTIONSOURCES_IDX`"/>
>>> <many-to-many entity-name="OptionSource" unique="false">
>>> <column name="`OptionSource_id`" not-null="true"
>>> unique="false"/>
>>> </many-to-many>
>>> </list>
>>> </class>
>>>
>>> I think hibernate misses an <id> or <composite-id> inside the <class>
>>> tag. The top-level classes are abstract, can this be the cause of the
>>> problem?
>>>
>>> THanks
>>> Andre
>>>
>>>
>>> Martin Taal wrote:
>>>> Hi Andre,
>>>> Teneo maps the model and not the actual java implementations
>>>> classes/interfaces. By also explicitly mapping the types (with
>>>> interface=true) modeled it is possible to do polymorphic queries on
>>>> the interface eclass.
>>>>
>>>> The reason that in case of multiple inheritance mappings are created
>>>> for each superinterface (although Hibernate does not support
>>>> multiple inheritance, and only the first is used) is that Teneo
>>>> currently does not identify if a type is used as the second or third
>>>> type or also as a first supertype somewhere (see bug link below).
>>>> As an example, say there is a SchoolBook type which inherits from
>>>> types Book and Asset. In this case EMF will let SchoolBookImpl
>>>> inherit from BookImpl and the SchoolBook interface from Book and
>>>> Asset interfaces.
>>>> Teneo will generate a mapping for SchoolBook, Book and Asset, The
>>>> SchoolBook mapping will have an extends attribute pointing to Book.
>>>> The attributes of Asset are mapped directly in SchoolBook but there
>>>> is no relation between SchoolBook and Asset but the Asset attributes
>>>> are mapped correctly (in the SchoolBook mapping). Asset is in a way
>>>> treated as a mappedsuperclass.
>>>> In this case the mapping (and table) for Asset is not stricly
>>>> required and can be removed. However Teneo then needs to discover
>>>> that there are no other subtypes which have Asset as the first
>>>> supertype. This feature needs to be added. I entered this myself as
>>>> a bug (see issue below) in august.
>>>>
>>>> Btw, you can prevent explicit mapping of the extra interface classes
>>>> by using the MappedSuperClass annotation (on the interface types).
>>>> This annotation will/should also prevent all classes to be persisted
>>>> in one table in case of single table (if you the single root is
>>>> denoted as a mappedsuperclass).
>>>>
>>>> Regarding joined, in case of multiple inheritance the first
>>>> supertype is considered the real super, the others are treated as a
>>>> mappedsuperclasses. So joined will work but only use one path to the
>>>> root.
>>>>
>>>> Here are some other related links:
>>>> https://bugs.eclipse.org/bugs/show_bug.cgi?id=153746
>>>> http://www.elver.org/hibernate/inheritance.html#Multiple+Inh eritance+Support
>>>>
>>>> http://comments.gmane.org/gmane.comp.java.emf.persistency/64 5
>>>> http://forum.hibernate.org/viewtopic.php?t=947670
>>>>
>>>> gr. Martin
>>>>
>>>> Andre Pareis wrote:
>>>>> Hi,
>>>>>
>>>>> IIRC, the former teneo implementation (elver) did not create tables
>>>>> for interface, whereas the new one does.
>>>>>
>>>>> I have, for example, an interface called "Identifiable" declaring
>>>>> an "id" attribute. This way I can add the "id" feature to some
>>>>> classes by just realizing this interface. I would also like to have
>>>>> a "Named" interface with an attribute "name", which can be added in
>>>>> addition to the Identifiable interface.
>>>>>
>>>>> I'm not sure if this is possible at all and how it would look like.
>>>>> However, even if, my concerns with mapped interfaces are these:
>>>>>
>>>>> 1. It is IMO not desirable to see tables for interfaces as this can
>>>>> be translated as implementation. Instead, the attributes defined in
>>>>> the interface should be implemented only and first in the classes
>>>>> implementing the interface.
>>>>>
>>>>> 2. I wonder if the current approach allows a JOINED mapping
>>>>> strategy whilst having multiple super interfaces each declaring
>>>>> some attribute, i.e., multiple inheritance as it is possible with
>>>>> EMF, which is capable of implementing the declared attributes in
>>>>> all classes implementing an interface.
>>>>>
>>>>> 3. As a side effect of the current solution: If I use SINGLE_TABLE
>>>>> at present, then all classes implementing the Identifiable
>>>>> interface (there are many) go into the "IDENTIFIABLE" table, which
>>>>> looks extremely denormalized.
>>>>>
>>>>> I would be interested in your opinion and in the rationale behind
>>>>> the current approach.
>>>>>
>>>>> Regards
>>>>> Andre
>>>>
>>>>
>>
>>
--
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 - why tables for interfaces? [message #63615 is a reply to message #60570] |
Mon, 04 December 2006 17:23 ![Go to previous message Go to previous message](theme/Solstice/images/up.png) ![Go to next message Go to next message](theme/Solstice/images/down.png) |
Brian Vetter![Friend of Eclipse Friend](/donate/web-api/friends_decorator.php?email=bvetter%40alterpoint.com) Messages: 74 Registered: July 2009 |
Member |
|
|
I'm just getting started looking at Teneo when I saw this thread. Can
Teneo use discriminators when using the table/subclass type of mapping
in hibernate or is it fixed to use hibernate's "joined-subclass" mappings?
Thanks,
Brian
Martin Taal wrote:
> Hi Andre,
> Teneo maps the model and not the actual java implementations
> classes/interfaces. By also explicitly mapping the types (with
> interface=true) modeled it is possible to do polymorphic queries on the
> interface eclass.
>
> The reason that in case of multiple inheritance mappings are created for
> each superinterface (although Hibernate does not support multiple
> inheritance, and only the first is used) is that Teneo currently does
> not identify if a type is used as the second or third type or also as a
> first supertype somewhere (see bug link below).
> As an example, say there is a SchoolBook type which inherits from types
> Book and Asset. In this case EMF will let SchoolBookImpl inherit from
> BookImpl and the SchoolBook interface from Book and Asset interfaces.
> Teneo will generate a mapping for SchoolBook, Book and Asset, The
> SchoolBook mapping will have an extends attribute pointing to Book. The
> attributes of Asset are mapped directly in SchoolBook but there is no
> relation between SchoolBook and Asset but the Asset attributes are
> mapped correctly (in the SchoolBook mapping). Asset is in a way treated
> as a mappedsuperclass.
> In this case the mapping (and table) for Asset is not stricly required
> and can be removed. However Teneo then needs to discover that there are
> no other subtypes which have Asset as the first supertype. This feature
> needs to be added. I entered this myself as a bug (see issue below) in
> august.
>
> Btw, you can prevent explicit mapping of the extra interface classes by
> using the MappedSuperClass annotation (on the interface types). This
> annotation will/should also prevent all classes to be persisted in one
> table in case of single table (if you the single root is denoted as a
> mappedsuperclass).
>
> Regarding joined, in case of multiple inheritance the first supertype is
> considered the real super, the others are treated as a
> mappedsuperclasses. So joined will work but only use one path to the root.
>
> Here are some other related links:
> https://bugs.eclipse.org/bugs/show_bug.cgi?id=153746
> http://www.elver.org/hibernate/inheritance.html#Multiple+Inh eritance+Support
>
> http://comments.gmane.org/gmane.comp.java.emf.persistency/64 5
> http://forum.hibernate.org/viewtopic.php?t=947670
>
> gr. Martin
>
> Andre Pareis wrote:
>> Hi,
>>
>> IIRC, the former teneo implementation (elver) did not create tables
>> for interface, whereas the new one does.
>>
>> I have, for example, an interface called "Identifiable" declaring an
>> "id" attribute. This way I can add the "id" feature to some classes by
>> just realizing this interface. I would also like to have a "Named"
>> interface with an attribute "name", which can be added in addition to
>> the Identifiable interface.
>>
>> I'm not sure if this is possible at all and how it would look like.
>> However, even if, my concerns with mapped interfaces are these:
>>
>> 1. It is IMO not desirable to see tables for interfaces as this can be
>> translated as implementation. Instead, the attributes defined in the
>> interface should be implemented only and first in the classes
>> implementing the interface.
>>
>> 2. I wonder if the current approach allows a JOINED mapping strategy
>> whilst having multiple super interfaces each declaring some attribute,
>> i.e., multiple inheritance as it is possible with EMF, which is
>> capable of implementing the declared attributes in all classes
>> implementing an interface.
>>
>> 3. As a side effect of the current solution: If I use SINGLE_TABLE at
>> present, then all classes implementing the Identifiable interface
>> (there are many) go into the "IDENTIFIABLE" table, which looks
>> extremely denormalized.
>>
>> I would be interested in your opinion and in the rationale behind the
>> current approach.
>>
>> Regards
>> Andre
>
>
|
|
|
Re: teneo - why tables for interfaces? [message #63639 is a reply to message #63615] |
Mon, 04 December 2006 18:14 ![Go to previous message Go to previous message](theme/Solstice/images/up.png) |
Martin Taal![Friend of Eclipse Friend](/donate/web-api/friends_decorator.php?email=mtaal%40springsite.com) Messages: 5468 Registered: July 2009 |
Senior Member |
|
|
Brian,
Both joined-subclass and single_table are supported. You can set this globally using an option (see
http://www.elver.org/hibernate/options.html) or per eclass by using the Inheritance annotation, see
http://www.elver.org/hibernate/ejb3_examples.html#inheritanc e.
You can also use the MappedSuperclass annotation to force the supereclass to be persisted in the
table of the subclass.
gr. Martin
Brian Vetter wrote:
> I'm just getting started looking at Teneo when I saw this thread. Can
> Teneo use discriminators when using the table/subclass type of mapping
> in hibernate or is it fixed to use hibernate's "joined-subclass" mappings?
>
> Thanks,
>
> Brian
>
> Martin Taal wrote:
>> Hi Andre,
>> Teneo maps the model and not the actual java implementations
>> classes/interfaces. By also explicitly mapping the types (with
>> interface=true) modeled it is possible to do polymorphic queries on
>> the interface eclass.
>>
>> The reason that in case of multiple inheritance mappings are created
>> for each superinterface (although Hibernate does not support multiple
>> inheritance, and only the first is used) is that Teneo currently does
>> not identify if a type is used as the second or third type or also as
>> a first supertype somewhere (see bug link below).
>> As an example, say there is a SchoolBook type which inherits from
>> types Book and Asset. In this case EMF will let SchoolBookImpl inherit
>> from BookImpl and the SchoolBook interface from Book and Asset
>> interfaces.
>> Teneo will generate a mapping for SchoolBook, Book and Asset, The
>> SchoolBook mapping will have an extends attribute pointing to Book.
>> The attributes of Asset are mapped directly in SchoolBook but there is
>> no relation between SchoolBook and Asset but the Asset attributes are
>> mapped correctly (in the SchoolBook mapping). Asset is in a way
>> treated as a mappedsuperclass.
>> In this case the mapping (and table) for Asset is not stricly required
>> and can be removed. However Teneo then needs to discover that there
>> are no other subtypes which have Asset as the first supertype. This
>> feature needs to be added. I entered this myself as a bug (see issue
>> below) in august.
>>
>> Btw, you can prevent explicit mapping of the extra interface classes
>> by using the MappedSuperClass annotation (on the interface types).
>> This annotation will/should also prevent all classes to be persisted
>> in one table in case of single table (if you the single root is
>> denoted as a mappedsuperclass).
>>
>> Regarding joined, in case of multiple inheritance the first supertype
>> is considered the real super, the others are treated as a
>> mappedsuperclasses. So joined will work but only use one path to the
>> root.
>>
>> Here are some other related links:
>> https://bugs.eclipse.org/bugs/show_bug.cgi?id=153746
>> http://www.elver.org/hibernate/inheritance.html#Multiple+Inh eritance+Support
>>
>> http://comments.gmane.org/gmane.comp.java.emf.persistency/64 5
>> http://forum.hibernate.org/viewtopic.php?t=947670
>>
>> gr. Martin
>>
>> Andre Pareis wrote:
>>> Hi,
>>>
>>> IIRC, the former teneo implementation (elver) did not create tables
>>> for interface, whereas the new one does.
>>>
>>> I have, for example, an interface called "Identifiable" declaring an
>>> "id" attribute. This way I can add the "id" feature to some classes
>>> by just realizing this interface. I would also like to have a "Named"
>>> interface with an attribute "name", which can be added in addition to
>>> the Identifiable interface.
>>>
>>> I'm not sure if this is possible at all and how it would look like.
>>> However, even if, my concerns with mapped interfaces are these:
>>>
>>> 1. It is IMO not desirable to see tables for interfaces as this can
>>> be translated as implementation. Instead, the attributes defined in
>>> the interface should be implemented only and first in the classes
>>> implementing the interface.
>>>
>>> 2. I wonder if the current approach allows a JOINED mapping strategy
>>> whilst having multiple super interfaces each declaring some
>>> attribute, i.e., multiple inheritance as it is possible with EMF,
>>> which is capable of implementing the declared attributes in all
>>> classes implementing an interface.
>>>
>>> 3. As a side effect of the current solution: If I use SINGLE_TABLE at
>>> present, then all classes implementing the Identifiable interface
>>> (there are many) go into the "IDENTIFIABLE" table, which looks
>>> extremely denormalized.
>>>
>>> I would be interested in your opinion and in the rationale behind the
>>> current approach.
>>>
>>> Regards
>>> Andre
>>
>>
--
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 - why tables for interfaces? [message #595411 is a reply to message #60559] |
Fri, 10 November 2006 16:22 ![Go to previous message Go to previous message](theme/Solstice/images/up.png) |
Martin Taal![Friend of Eclipse Friend](/donate/web-api/friends_decorator.php?email=mtaal%40springsite.com) Messages: 5468 Registered: July 2009 |
Senior Member |
|
|
Hi Andre,
Teneo maps the model and not the actual java implementations classes/interfaces. By also explicitly
mapping the types (with interface=true) modeled it is possible to do polymorphic queries on the
interface eclass.
The reason that in case of multiple inheritance mappings are created for each superinterface
(although Hibernate does not support multiple inheritance, and only the first is used) is that Teneo
currently does not identify if a type is used as the second or third type or also as a first
supertype somewhere (see bug link below).
As an example, say there is a SchoolBook type which inherits from types Book and Asset. In this case
EMF will let SchoolBookImpl inherit from BookImpl and the SchoolBook interface from Book and Asset
interfaces.
Teneo will generate a mapping for SchoolBook, Book and Asset, The SchoolBook mapping will have an
extends attribute pointing to Book. The attributes of Asset are mapped directly in SchoolBook but
there is no relation between SchoolBook and Asset but the Asset attributes are mapped correctly (in
the SchoolBook mapping). Asset is in a way treated as a mappedsuperclass.
In this case the mapping (and table) for Asset is not stricly required and can be removed. However
Teneo then needs to discover that there are no other subtypes which have Asset as the first
supertype. This feature needs to be added. I entered this myself as a bug (see issue below) in august.
Btw, you can prevent explicit mapping of the extra interface classes by using the MappedSuperClass
annotation (on the interface types). This annotation will/should also prevent all classes to be
persisted in one table in case of single table (if you the single root is denoted as a
mappedsuperclass).
Regarding joined, in case of multiple inheritance the first supertype is considered the real super,
the others are treated as a mappedsuperclasses. So joined will work but only use one path to the root.
Here are some other related links:
https://bugs.eclipse.org/bugs/show_bug.cgi?id=153746
http://www.elver.org/hibernate/inheritance.html#Multiple+Inh eritance+Support
http://comments.gmane.org/gmane.comp.java.emf.persistency/64 5
http://forum.hibernate.org/viewtopic.php?t=947670
gr. Martin
Andre Pareis wrote:
> Hi,
>
> IIRC, the former teneo implementation (elver) did not create tables for
> interface, whereas the new one does.
>
> I have, for example, an interface called "Identifiable" declaring an
> "id" attribute. This way I can add the "id" feature to some classes by
> just realizing this interface. I would also like to have a "Named"
> interface with an attribute "name", which can be added in addition to
> the Identifiable interface.
>
> I'm not sure if this is possible at all and how it would look like.
> However, even if, my concerns with mapped interfaces are these:
>
> 1. It is IMO not desirable to see tables for interfaces as this can be
> translated as implementation. Instead, the attributes defined in the
> interface should be implemented only and first in the classes
> implementing the interface.
>
> 2. I wonder if the current approach allows a JOINED mapping strategy
> whilst having multiple super interfaces each declaring some attribute,
> i.e., multiple inheritance as it is possible with EMF, which is capable
> of implementing the declared attributes in all classes implementing an
> interface.
>
> 3. As a side effect of the current solution: If I use SINGLE_TABLE at
> present, then all classes implementing the Identifiable interface (there
> are many) go into the "IDENTIFIABLE" table, which looks extremely
> denormalized.
>
> I would be interested in your opinion and in the rationale behind the
> current approach.
>
> Regards
> Andre
--
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 - why tables for interfaces? [message #595422 is a reply to message #60570] |
Fri, 10 November 2006 17:43 ![Go to previous message Go to previous message](theme/Solstice/images/up.png) |
Andre Pareis![Friend of Eclipse Friend](/donate/web-api/friends_decorator.php?email=andre.pareis%40entura.ch) Messages: 113 Registered: July 2009 |
Senior Member |
|
|
Thanks Martin, that makes perfect sense. I have added the @MappedSuperClass to
my super interface (Identifiable) now. But I'm getting XML parser exceptions:
1547 [main] ERROR org.hibernate.util.XMLHelper - Error parsing XML: XML
String(44) The content of element type "class" must match
" (meta*,subselect?,cache?,synchronize*,comment?,tuplizer*,(id |composite-id),discriminator?,natural-id?,(version|timestamp )?,(property|many-to-one|one-to-one|component|dynamic-compon ent|properties|any|map|set|list|bag|idbag|array|primitive-ar ray)*,((join*,subclass*)|joined-subclass*|union-subclass*),l oader?,sql-insert?,sql-update?,sql-delete?,filter*,resultset *,(query|sql-query)*) ".
....
<!-- Generated by Teneo on Fri Nov 10 18:27:53 CET 2006 -->
<hibernate-mapping>
<class entity-name="Instrument" abstract="true" lazy="false" table="`Instrument`">
<property name="id" type="java.lang.String" lazy="false" column="`id`"
not-null="false"/>
<property name="name" type="java.lang.String" lazy="false" column="`name`"
not-null="false"/>
<many-to-one name="Client" entity-name="Client"
cascade="merge,persist,save-update,lock,refresh" lazy="false" insert="false"
update="false" not-null="false">
<column not-null="false" unique="false" name="`Instrument_Client_id`"/>
</many-to-one>
<list name="symbols" lazy="true" cascade="all,delete-orphan">
<key update="true">
<column name="`Symbol_instrument_id`" not-null="false" unique="false"/>
</key>
<list-index column="`INSTRUMENT_SYMBOLS_IDX`"/>
<one-to-many entity-name="Symbol"/>
</list>
<list name="categories" lazy="true"
cascade="merge,persist,save-update,lock,refresh" table="Instrument_Category">
<key update="true">
<column name="`Instrument_id`" not-null="true" unique="false"/>
</key>
<list-index column="`INSTRUMENT_CATEGORIES_IDX`"/>
<many-to-many entity-name="Category" unique="false">
<column name="`Category_id`" not-null="true" unique="false"/>
</many-to-many>
</list>
<list name="options" lazy="true" cascade="all,delete-orphan">
<key update="true">
<column name="`Option_underlying_id`" not-null="false" unique="false"/>
</key>
<list-index column="`INSTRUMENT_OPTIONS_IDX`"/>
<one-to-many entity-name="Option"/>
</list>
<list name="optionSources" lazy="true"
cascade="merge,persist,save-update,lock,refresh" table="Instrument_OptionSource">
<key update="true">
<column name="`Instrument_id`" not-null="true" unique="false"/>
</key>
<list-index column="`INSTRUMENT_OPTIONSOURCES_IDX`"/>
<many-to-many entity-name="OptionSource" unique="false">
<column name="`OptionSource_id`" not-null="true" unique="false"/>
</many-to-many>
</list>
</class>
I think hibernate misses an <id> or <composite-id> inside the <class> tag. The
top-level classes are abstract, can this be the cause of the problem?
THanks
Andre
Martin Taal wrote:
> Hi Andre,
> Teneo maps the model and not the actual java implementations
> classes/interfaces. By also explicitly mapping the types (with
> interface=true) modeled it is possible to do polymorphic queries on the
> interface eclass.
>
> The reason that in case of multiple inheritance mappings are created for
> each superinterface (although Hibernate does not support multiple
> inheritance, and only the first is used) is that Teneo currently does
> not identify if a type is used as the second or third type or also as a
> first supertype somewhere (see bug link below).
> As an example, say there is a SchoolBook type which inherits from types
> Book and Asset. In this case EMF will let SchoolBookImpl inherit from
> BookImpl and the SchoolBook interface from Book and Asset interfaces.
> Teneo will generate a mapping for SchoolBook, Book and Asset, The
> SchoolBook mapping will have an extends attribute pointing to Book. The
> attributes of Asset are mapped directly in SchoolBook but there is no
> relation between SchoolBook and Asset but the Asset attributes are
> mapped correctly (in the SchoolBook mapping). Asset is in a way treated
> as a mappedsuperclass.
> In this case the mapping (and table) for Asset is not stricly required
> and can be removed. However Teneo then needs to discover that there are
> no other subtypes which have Asset as the first supertype. This feature
> needs to be added. I entered this myself as a bug (see issue below) in
> august.
>
> Btw, you can prevent explicit mapping of the extra interface classes by
> using the MappedSuperClass annotation (on the interface types). This
> annotation will/should also prevent all classes to be persisted in one
> table in case of single table (if you the single root is denoted as a
> mappedsuperclass).
>
> Regarding joined, in case of multiple inheritance the first supertype is
> considered the real super, the others are treated as a
> mappedsuperclasses. So joined will work but only use one path to the root.
>
> Here are some other related links:
> https://bugs.eclipse.org/bugs/show_bug.cgi?id=153746
> http://www.elver.org/hibernate/inheritance.html#Multiple+Inh eritance+Support
>
> http://comments.gmane.org/gmane.comp.java.emf.persistency/64 5
> http://forum.hibernate.org/viewtopic.php?t=947670
>
> gr. Martin
>
> Andre Pareis wrote:
>> Hi,
>>
>> IIRC, the former teneo implementation (elver) did not create tables
>> for interface, whereas the new one does.
>>
>> I have, for example, an interface called "Identifiable" declaring an
>> "id" attribute. This way I can add the "id" feature to some classes by
>> just realizing this interface. I would also like to have a "Named"
>> interface with an attribute "name", which can be added in addition to
>> the Identifiable interface.
>>
>> I'm not sure if this is possible at all and how it would look like.
>> However, even if, my concerns with mapped interfaces are these:
>>
>> 1. It is IMO not desirable to see tables for interfaces as this can be
>> translated as implementation. Instead, the attributes defined in the
>> interface should be implemented only and first in the classes
>> implementing the interface.
>>
>> 2. I wonder if the current approach allows a JOINED mapping strategy
>> whilst having multiple super interfaces each declaring some attribute,
>> i.e., multiple inheritance as it is possible with EMF, which is
>> capable of implementing the declared attributes in all classes
>> implementing an interface.
>>
>> 3. As a side effect of the current solution: If I use SINGLE_TABLE at
>> present, then all classes implementing the Identifiable interface
>> (there are many) go into the "IDENTIFIABLE" table, which looks
>> extremely denormalized.
>>
>> I would be interested in your opinion and in the rationale behind the
>> current approach.
>>
>> Regards
>> Andre
>
>
|
|
|
Re: teneo - why tables for interfaces? [message #595431 is a reply to message #60571] |
Fri, 10 November 2006 19:36 ![Go to previous message Go to previous message](theme/Solstice/images/up.png) |
Martin Taal![Friend of Eclipse Friend](/donate/web-api/friends_decorator.php?email=mtaal%40springsite.com) Messages: 5468 Registered: July 2009 |
Senior Member |
|
|
Hi Andre,
Can you send me the annotated ecore? Does the id property also have a basic annotation (it should
only have an id annotation).
gr. Martin
Andre Pareis wrote:
> Thanks Martin, that makes perfect sense. I have added the
> @MappedSuperClass to my super interface (Identifiable) now. But I'm
> getting XML parser exceptions:
>
> 1547 [main] ERROR org.hibernate.util.XMLHelper - Error parsing XML: XML
> String(44) The content of element type "class" must match
> " (meta*,subselect?,cache?,synchronize*,comment?,tuplizer*,(id |composite-id),discriminator?,natural-id?,(version|timestamp )?,(property|many-to-one|one-to-one|component|dynamic-compon ent|properties|any|map|set|list|bag|idbag|array|primitive-ar ray)*,((join*,subclass*)|joined-subclass*|union-subclass*),l oader?,sql-insert?,sql-update?,sql-delete?,filter*,resultset *,(query|sql-query)*) ".
>
> ....
>
> <!-- Generated by Teneo on Fri Nov 10 18:27:53 CET 2006 -->
> <hibernate-mapping>
> <class entity-name="Instrument" abstract="true" lazy="false"
> table="`Instrument`">
> <property name="id" type="java.lang.String" lazy="false"
> column="`id`" not-null="false"/>
> <property name="name" type="java.lang.String" lazy="false"
> column="`name`" not-null="false"/>
> <many-to-one name="Client" entity-name="Client"
> cascade="merge,persist,save-update,lock,refresh" lazy="false"
> insert="false" update="false" not-null="false">
> <column not-null="false" unique="false"
> name="`Instrument_Client_id`"/>
> </many-to-one>
> <list name="symbols" lazy="true" cascade="all,delete-orphan">
> <key update="true">
> <column name="`Symbol_instrument_id`" not-null="false"
> unique="false"/>
> </key>
> <list-index column="`INSTRUMENT_SYMBOLS_IDX`"/>
> <one-to-many entity-name="Symbol"/>
> </list>
> <list name="categories" lazy="true"
> cascade="merge,persist,save-update,lock,refresh"
> table="Instrument_Category">
> <key update="true">
> <column name="`Instrument_id`" not-null="true"
> unique="false"/>
> </key>
> <list-index column="`INSTRUMENT_CATEGORIES_IDX`"/>
> <many-to-many entity-name="Category" unique="false">
> <column name="`Category_id`" not-null="true"
> unique="false"/>
> </many-to-many>
> </list>
> <list name="options" lazy="true" cascade="all,delete-orphan">
> <key update="true">
> <column name="`Option_underlying_id`" not-null="false"
> unique="false"/>
> </key>
> <list-index column="`INSTRUMENT_OPTIONS_IDX`"/>
> <one-to-many entity-name="Option"/>
> </list>
> <list name="optionSources" lazy="true"
> cascade="merge,persist,save-update,lock,refresh"
> table="Instrument_OptionSource">
> <key update="true">
> <column name="`Instrument_id`" not-null="true"
> unique="false"/>
> </key>
> <list-index column="`INSTRUMENT_OPTIONSOURCES_IDX`"/>
> <many-to-many entity-name="OptionSource" unique="false">
> <column name="`OptionSource_id`" not-null="true"
> unique="false"/>
> </many-to-many>
> </list>
> </class>
>
> I think hibernate misses an <id> or <composite-id> inside the <class>
> tag. The top-level classes are abstract, can this be the cause of the
> problem?
>
> THanks
> Andre
>
>
> Martin Taal wrote:
>> Hi Andre,
>> Teneo maps the model and not the actual java implementations
>> classes/interfaces. By also explicitly mapping the types (with
>> interface=true) modeled it is possible to do polymorphic queries on
>> the interface eclass.
>>
>> The reason that in case of multiple inheritance mappings are created
>> for each superinterface (although Hibernate does not support multiple
>> inheritance, and only the first is used) is that Teneo currently does
>> not identify if a type is used as the second or third type or also as
>> a first supertype somewhere (see bug link below).
>> As an example, say there is a SchoolBook type which inherits from
>> types Book and Asset. In this case EMF will let SchoolBookImpl inherit
>> from BookImpl and the SchoolBook interface from Book and Asset
>> interfaces.
>> Teneo will generate a mapping for SchoolBook, Book and Asset, The
>> SchoolBook mapping will have an extends attribute pointing to Book.
>> The attributes of Asset are mapped directly in SchoolBook but there is
>> no relation between SchoolBook and Asset but the Asset attributes are
>> mapped correctly (in the SchoolBook mapping). Asset is in a way
>> treated as a mappedsuperclass.
>> In this case the mapping (and table) for Asset is not stricly required
>> and can be removed. However Teneo then needs to discover that there
>> are no other subtypes which have Asset as the first supertype. This
>> feature needs to be added. I entered this myself as a bug (see issue
>> below) in august.
>>
>> Btw, you can prevent explicit mapping of the extra interface classes
>> by using the MappedSuperClass annotation (on the interface types).
>> This annotation will/should also prevent all classes to be persisted
>> in one table in case of single table (if you the single root is
>> denoted as a mappedsuperclass).
>>
>> Regarding joined, in case of multiple inheritance the first supertype
>> is considered the real super, the others are treated as a
>> mappedsuperclasses. So joined will work but only use one path to the
>> root.
>>
>> Here are some other related links:
>> https://bugs.eclipse.org/bugs/show_bug.cgi?id=153746
>> http://www.elver.org/hibernate/inheritance.html#Multiple+Inh eritance+Support
>>
>> http://comments.gmane.org/gmane.comp.java.emf.persistency/64 5
>> http://forum.hibernate.org/viewtopic.php?t=947670
>>
>> gr. Martin
>>
>> Andre Pareis wrote:
>>> Hi,
>>>
>>> IIRC, the former teneo implementation (elver) did not create tables
>>> for interface, whereas the new one does.
>>>
>>> I have, for example, an interface called "Identifiable" declaring an
>>> "id" attribute. This way I can add the "id" feature to some classes
>>> by just realizing this interface. I would also like to have a "Named"
>>> interface with an attribute "name", which can be added in addition to
>>> the Identifiable interface.
>>>
>>> I'm not sure if this is possible at all and how it would look like.
>>> However, even if, my concerns with mapped interfaces are these:
>>>
>>> 1. It is IMO not desirable to see tables for interfaces as this can
>>> be translated as implementation. Instead, the attributes defined in
>>> the interface should be implemented only and first in the classes
>>> implementing the interface.
>>>
>>> 2. I wonder if the current approach allows a JOINED mapping strategy
>>> whilst having multiple super interfaces each declaring some
>>> attribute, i.e., multiple inheritance as it is possible with EMF,
>>> which is capable of implementing the declared attributes in all
>>> classes implementing an interface.
>>>
>>> 3. As a side effect of the current solution: If I use SINGLE_TABLE at
>>> present, then all classes implementing the Identifiable interface
>>> (there are many) go into the "IDENTIFIABLE" table, which looks
>>> extremely denormalized.
>>>
>>> I would be interested in your opinion and in the rationale behind the
>>> current approach.
>>>
>>> Regards
>>> Andre
>>
>>
--
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 - why tables for interfaces? [message #595440 is a reply to message #60572] |
Fri, 10 November 2006 20:01 ![Go to previous message Go to previous message](theme/Solstice/images/up.png) |
Andre Pareis![Friend of Eclipse Friend](/donate/web-api/friends_decorator.php?email=andre.pareis%40entura.ch) Messages: 113 Registered: July 2009 |
Senior Member |
|
|
Martin,
No the id attribute is just a normal attribute, it does not have ID semantics
and no annotations at all. I expected teneo to generate a primary key for my
classes.
I can send you the ecore if that does not help.
-Andre
Martin Taal wrote:
> Hi Andre,
> Can you send me the annotated ecore? Does the id property also have a
> basic annotation (it should only have an id annotation).
>
> gr. Martin
>
> Andre Pareis wrote:
>> Thanks Martin, that makes perfect sense. I have added the
>> @MappedSuperClass to my super interface (Identifiable) now. But I'm
>> getting XML parser exceptions:
>>
>> 1547 [main] ERROR org.hibernate.util.XMLHelper - Error parsing XML:
>> XML String(44) The content of element type "class" must match
>> " (meta*,subselect?,cache?,synchronize*,comment?,tuplizer*,(id |composite-id),discriminator?,natural-id?,(version|timestamp )?,(property|many-to-one|one-to-one|component|dynamic-compon ent|properties|any|map|set|list|bag|idbag|array|primitive-ar ray)*,((join*,subclass*)|joined-subclass*|union-subclass*),l oader?,sql-insert?,sql-update?,sql-delete?,filter*,resultset *,(query|sql-query)*) ".
>>
>> ....
>>
>> <!-- Generated by Teneo on Fri Nov 10 18:27:53 CET 2006 -->
>> <hibernate-mapping>
>> <class entity-name="Instrument" abstract="true" lazy="false"
>> table="`Instrument`">
>> <property name="id" type="java.lang.String" lazy="false"
>> column="`id`" not-null="false"/>
>> <property name="name" type="java.lang.String" lazy="false"
>> column="`name`" not-null="false"/>
>> <many-to-one name="Client" entity-name="Client"
>> cascade="merge,persist,save-update,lock,refresh" lazy="false"
>> insert="false" update="false" not-null="false">
>> <column not-null="false" unique="false"
>> name="`Instrument_Client_id`"/>
>> </many-to-one>
>> <list name="symbols" lazy="true" cascade="all,delete-orphan">
>> <key update="true">
>> <column name="`Symbol_instrument_id`" not-null="false"
>> unique="false"/>
>> </key>
>> <list-index column="`INSTRUMENT_SYMBOLS_IDX`"/>
>> <one-to-many entity-name="Symbol"/>
>> </list>
>> <list name="categories" lazy="true"
>> cascade="merge,persist,save-update,lock,refresh"
>> table="Instrument_Category">
>> <key update="true">
>> <column name="`Instrument_id`" not-null="true"
>> unique="false"/>
>> </key>
>> <list-index column="`INSTRUMENT_CATEGORIES_IDX`"/>
>> <many-to-many entity-name="Category" unique="false">
>> <column name="`Category_id`" not-null="true"
>> unique="false"/>
>> </many-to-many>
>> </list>
>> <list name="options" lazy="true" cascade="all,delete-orphan">
>> <key update="true">
>> <column name="`Option_underlying_id`" not-null="false"
>> unique="false"/>
>> </key>
>> <list-index column="`INSTRUMENT_OPTIONS_IDX`"/>
>> <one-to-many entity-name="Option"/>
>> </list>
>> <list name="optionSources" lazy="true"
>> cascade="merge,persist,save-update,lock,refresh"
>> table="Instrument_OptionSource">
>> <key update="true">
>> <column name="`Instrument_id`" not-null="true"
>> unique="false"/>
>> </key>
>> <list-index column="`INSTRUMENT_OPTIONSOURCES_IDX`"/>
>> <many-to-many entity-name="OptionSource" unique="false">
>> <column name="`OptionSource_id`" not-null="true"
>> unique="false"/>
>> </many-to-many>
>> </list>
>> </class>
>>
>> I think hibernate misses an <id> or <composite-id> inside the <class>
>> tag. The top-level classes are abstract, can this be the cause of the
>> problem?
>>
>> THanks
>> Andre
>>
>>
>> Martin Taal wrote:
>>> Hi Andre,
>>> Teneo maps the model and not the actual java implementations
>>> classes/interfaces. By also explicitly mapping the types (with
>>> interface=true) modeled it is possible to do polymorphic queries on
>>> the interface eclass.
>>>
>>> The reason that in case of multiple inheritance mappings are created
>>> for each superinterface (although Hibernate does not support multiple
>>> inheritance, and only the first is used) is that Teneo currently does
>>> not identify if a type is used as the second or third type or also as
>>> a first supertype somewhere (see bug link below).
>>> As an example, say there is a SchoolBook type which inherits from
>>> types Book and Asset. In this case EMF will let SchoolBookImpl
>>> inherit from BookImpl and the SchoolBook interface from Book and
>>> Asset interfaces.
>>> Teneo will generate a mapping for SchoolBook, Book and Asset, The
>>> SchoolBook mapping will have an extends attribute pointing to Book.
>>> The attributes of Asset are mapped directly in SchoolBook but there
>>> is no relation between SchoolBook and Asset but the Asset attributes
>>> are mapped correctly (in the SchoolBook mapping). Asset is in a way
>>> treated as a mappedsuperclass.
>>> In this case the mapping (and table) for Asset is not stricly
>>> required and can be removed. However Teneo then needs to discover
>>> that there are no other subtypes which have Asset as the first
>>> supertype. This feature needs to be added. I entered this myself as a
>>> bug (see issue below) in august.
>>>
>>> Btw, you can prevent explicit mapping of the extra interface classes
>>> by using the MappedSuperClass annotation (on the interface types).
>>> This annotation will/should also prevent all classes to be persisted
>>> in one table in case of single table (if you the single root is
>>> denoted as a mappedsuperclass).
>>>
>>> Regarding joined, in case of multiple inheritance the first supertype
>>> is considered the real super, the others are treated as a
>>> mappedsuperclasses. So joined will work but only use one path to the
>>> root.
>>>
>>> Here are some other related links:
>>> https://bugs.eclipse.org/bugs/show_bug.cgi?id=153746
>>> http://www.elver.org/hibernate/inheritance.html#Multiple+Inh eritance+Support
>>>
>>> http://comments.gmane.org/gmane.comp.java.emf.persistency/64 5
>>> http://forum.hibernate.org/viewtopic.php?t=947670
>>>
>>> gr. Martin
>>>
>>> Andre Pareis wrote:
>>>> Hi,
>>>>
>>>> IIRC, the former teneo implementation (elver) did not create tables
>>>> for interface, whereas the new one does.
>>>>
>>>> I have, for example, an interface called "Identifiable" declaring an
>>>> "id" attribute. This way I can add the "id" feature to some classes
>>>> by just realizing this interface. I would also like to have a
>>>> "Named" interface with an attribute "name", which can be added in
>>>> addition to the Identifiable interface.
>>>>
>>>> I'm not sure if this is possible at all and how it would look like.
>>>> However, even if, my concerns with mapped interfaces are these:
>>>>
>>>> 1. It is IMO not desirable to see tables for interfaces as this can
>>>> be translated as implementation. Instead, the attributes defined in
>>>> the interface should be implemented only and first in the classes
>>>> implementing the interface.
>>>>
>>>> 2. I wonder if the current approach allows a JOINED mapping strategy
>>>> whilst having multiple super interfaces each declaring some
>>>> attribute, i.e., multiple inheritance as it is possible with EMF,
>>>> which is capable of implementing the declared attributes in all
>>>> classes implementing an interface.
>>>>
>>>> 3. As a side effect of the current solution: If I use SINGLE_TABLE
>>>> at present, then all classes implementing the Identifiable interface
>>>> (there are many) go into the "IDENTIFIABLE" table, which looks
>>>> extremely denormalized.
>>>>
>>>> I would be interested in your opinion and in the rationale behind
>>>> the current approach.
>>>>
>>>> Regards
>>>> Andre
>>>
>>>
>
>
|
|
|
Re: teneo - why tables for interfaces? [message #595454 is a reply to message #60900] |
Fri, 10 November 2006 20:44 ![Go to previous message Go to previous message](theme/Solstice/images/up.png) |
Martin Taal![Friend of Eclipse Friend](/donate/web-api/friends_decorator.php?email=mtaal%40springsite.com) Messages: 5468 Registered: July 2009 |
Senior Member |
|
|
Ha I see, the current logic assumes that if there is a mappedsuperclass that there is then an
explicit id feature definition (in the mappedsuperclass). This is a bug/missing feature. I have
solved it now. I will check it in later.
gr. Martin
Andre Pareis wrote:
> Martin,
>
> No the id attribute is just a normal attribute, it does not have ID
> semantics and no annotations at all. I expected teneo to generate a
> primary key for my classes.
>
> I can send you the ecore if that does not help.
>
> -Andre
>
>
> Martin Taal wrote:
>> Hi Andre,
>> Can you send me the annotated ecore? Does the id property also have a
>> basic annotation (it should only have an id annotation).
>>
>> gr. Martin
>>
>> Andre Pareis wrote:
>>> Thanks Martin, that makes perfect sense. I have added the
>>> @MappedSuperClass to my super interface (Identifiable) now. But I'm
>>> getting XML parser exceptions:
>>>
>>> 1547 [main] ERROR org.hibernate.util.XMLHelper - Error parsing XML:
>>> XML String(44) The content of element type "class" must match
>>> " (meta*,subselect?,cache?,synchronize*,comment?,tuplizer*,(id |composite-id),discriminator?,natural-id?,(version|timestamp )?,(property|many-to-one|one-to-one|component|dynamic-compon ent|properties|any|map|set|list|bag|idbag|array|primitive-ar ray)*,((join*,subclass*)|joined-subclass*|union-subclass*),l oader?,sql-insert?,sql-update?,sql-delete?,filter*,resultset *,(query|sql-query)*) ".
>>>
>>> ....
>>>
>>> <!-- Generated by Teneo on Fri Nov 10 18:27:53 CET 2006 -->
>>> <hibernate-mapping>
>>> <class entity-name="Instrument" abstract="true" lazy="false"
>>> table="`Instrument`">
>>> <property name="id" type="java.lang.String" lazy="false"
>>> column="`id`" not-null="false"/>
>>> <property name="name" type="java.lang.String" lazy="false"
>>> column="`name`" not-null="false"/>
>>> <many-to-one name="Client" entity-name="Client"
>>> cascade="merge,persist,save-update,lock,refresh" lazy="false"
>>> insert="false" update="false" not-null="false">
>>> <column not-null="false" unique="false"
>>> name="`Instrument_Client_id`"/>
>>> </many-to-one>
>>> <list name="symbols" lazy="true" cascade="all,delete-orphan">
>>> <key update="true">
>>> <column name="`Symbol_instrument_id`"
>>> not-null="false" unique="false"/>
>>> </key>
>>> <list-index column="`INSTRUMENT_SYMBOLS_IDX`"/>
>>> <one-to-many entity-name="Symbol"/>
>>> </list>
>>> <list name="categories" lazy="true"
>>> cascade="merge,persist,save-update,lock,refresh"
>>> table="Instrument_Category">
>>> <key update="true">
>>> <column name="`Instrument_id`" not-null="true"
>>> unique="false"/>
>>> </key>
>>> <list-index column="`INSTRUMENT_CATEGORIES_IDX`"/>
>>> <many-to-many entity-name="Category" unique="false">
>>> <column name="`Category_id`" not-null="true"
>>> unique="false"/>
>>> </many-to-many>
>>> </list>
>>> <list name="options" lazy="true" cascade="all,delete-orphan">
>>> <key update="true">
>>> <column name="`Option_underlying_id`"
>>> not-null="false" unique="false"/>
>>> </key>
>>> <list-index column="`INSTRUMENT_OPTIONS_IDX`"/>
>>> <one-to-many entity-name="Option"/>
>>> </list>
>>> <list name="optionSources" lazy="true"
>>> cascade="merge,persist,save-update,lock,refresh"
>>> table="Instrument_OptionSource">
>>> <key update="true">
>>> <column name="`Instrument_id`" not-null="true"
>>> unique="false"/>
>>> </key>
>>> <list-index column="`INSTRUMENT_OPTIONSOURCES_IDX`"/>
>>> <many-to-many entity-name="OptionSource" unique="false">
>>> <column name="`OptionSource_id`" not-null="true"
>>> unique="false"/>
>>> </many-to-many>
>>> </list>
>>> </class>
>>>
>>> I think hibernate misses an <id> or <composite-id> inside the <class>
>>> tag. The top-level classes are abstract, can this be the cause of the
>>> problem?
>>>
>>> THanks
>>> Andre
>>>
>>>
>>> Martin Taal wrote:
>>>> Hi Andre,
>>>> Teneo maps the model and not the actual java implementations
>>>> classes/interfaces. By also explicitly mapping the types (with
>>>> interface=true) modeled it is possible to do polymorphic queries on
>>>> the interface eclass.
>>>>
>>>> The reason that in case of multiple inheritance mappings are created
>>>> for each superinterface (although Hibernate does not support
>>>> multiple inheritance, and only the first is used) is that Teneo
>>>> currently does not identify if a type is used as the second or third
>>>> type or also as a first supertype somewhere (see bug link below).
>>>> As an example, say there is a SchoolBook type which inherits from
>>>> types Book and Asset. In this case EMF will let SchoolBookImpl
>>>> inherit from BookImpl and the SchoolBook interface from Book and
>>>> Asset interfaces.
>>>> Teneo will generate a mapping for SchoolBook, Book and Asset, The
>>>> SchoolBook mapping will have an extends attribute pointing to Book.
>>>> The attributes of Asset are mapped directly in SchoolBook but there
>>>> is no relation between SchoolBook and Asset but the Asset attributes
>>>> are mapped correctly (in the SchoolBook mapping). Asset is in a way
>>>> treated as a mappedsuperclass.
>>>> In this case the mapping (and table) for Asset is not stricly
>>>> required and can be removed. However Teneo then needs to discover
>>>> that there are no other subtypes which have Asset as the first
>>>> supertype. This feature needs to be added. I entered this myself as
>>>> a bug (see issue below) in august.
>>>>
>>>> Btw, you can prevent explicit mapping of the extra interface classes
>>>> by using the MappedSuperClass annotation (on the interface types).
>>>> This annotation will/should also prevent all classes to be persisted
>>>> in one table in case of single table (if you the single root is
>>>> denoted as a mappedsuperclass).
>>>>
>>>> Regarding joined, in case of multiple inheritance the first
>>>> supertype is considered the real super, the others are treated as a
>>>> mappedsuperclasses. So joined will work but only use one path to the
>>>> root.
>>>>
>>>> Here are some other related links:
>>>> https://bugs.eclipse.org/bugs/show_bug.cgi?id=153746
>>>> http://www.elver.org/hibernate/inheritance.html#Multiple+Inh eritance+Support
>>>>
>>>> http://comments.gmane.org/gmane.comp.java.emf.persistency/64 5
>>>> http://forum.hibernate.org/viewtopic.php?t=947670
>>>>
>>>> gr. Martin
>>>>
>>>> Andre Pareis wrote:
>>>>> Hi,
>>>>>
>>>>> IIRC, the former teneo implementation (elver) did not create tables
>>>>> for interface, whereas the new one does.
>>>>>
>>>>> I have, for example, an interface called "Identifiable" declaring
>>>>> an "id" attribute. This way I can add the "id" feature to some
>>>>> classes by just realizing this interface. I would also like to have
>>>>> a "Named" interface with an attribute "name", which can be added in
>>>>> addition to the Identifiable interface.
>>>>>
>>>>> I'm not sure if this is possible at all and how it would look like.
>>>>> However, even if, my concerns with mapped interfaces are these:
>>>>>
>>>>> 1. It is IMO not desirable to see tables for interfaces as this can
>>>>> be translated as implementation. Instead, the attributes defined in
>>>>> the interface should be implemented only and first in the classes
>>>>> implementing the interface.
>>>>>
>>>>> 2. I wonder if the current approach allows a JOINED mapping
>>>>> strategy whilst having multiple super interfaces each declaring
>>>>> some attribute, i.e., multiple inheritance as it is possible with
>>>>> EMF, which is capable of implementing the declared attributes in
>>>>> all classes implementing an interface.
>>>>>
>>>>> 3. As a side effect of the current solution: If I use SINGLE_TABLE
>>>>> at present, then all classes implementing the Identifiable
>>>>> interface (there are many) go into the "IDENTIFIABLE" table, which
>>>>> looks extremely denormalized.
>>>>>
>>>>> I would be interested in your opinion and in the rationale behind
>>>>> the current approach.
>>>>>
>>>>> Regards
>>>>> Andre
>>>>
>>>>
>>
>>
--
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 - why tables for interfaces? [message #596478 is a reply to message #60570] |
Mon, 04 December 2006 17:23 ![Go to previous message Go to previous message](theme/Solstice/images/up.png) |
Brian Vetter![Friend of Eclipse Friend](/donate/web-api/friends_decorator.php?email=bvetter%40alterpoint.com) Messages: 74 Registered: July 2009 |
Member |
|
|
I'm just getting started looking at Teneo when I saw this thread. Can
Teneo use discriminators when using the table/subclass type of mapping
in hibernate or is it fixed to use hibernate's "joined-subclass" mappings?
Thanks,
Brian
Martin Taal wrote:
> Hi Andre,
> Teneo maps the model and not the actual java implementations
> classes/interfaces. By also explicitly mapping the types (with
> interface=true) modeled it is possible to do polymorphic queries on the
> interface eclass.
>
> The reason that in case of multiple inheritance mappings are created for
> each superinterface (although Hibernate does not support multiple
> inheritance, and only the first is used) is that Teneo currently does
> not identify if a type is used as the second or third type or also as a
> first supertype somewhere (see bug link below).
> As an example, say there is a SchoolBook type which inherits from types
> Book and Asset. In this case EMF will let SchoolBookImpl inherit from
> BookImpl and the SchoolBook interface from Book and Asset interfaces.
> Teneo will generate a mapping for SchoolBook, Book and Asset, The
> SchoolBook mapping will have an extends attribute pointing to Book. The
> attributes of Asset are mapped directly in SchoolBook but there is no
> relation between SchoolBook and Asset but the Asset attributes are
> mapped correctly (in the SchoolBook mapping). Asset is in a way treated
> as a mappedsuperclass.
> In this case the mapping (and table) for Asset is not stricly required
> and can be removed. However Teneo then needs to discover that there are
> no other subtypes which have Asset as the first supertype. This feature
> needs to be added. I entered this myself as a bug (see issue below) in
> august.
>
> Btw, you can prevent explicit mapping of the extra interface classes by
> using the MappedSuperClass annotation (on the interface types). This
> annotation will/should also prevent all classes to be persisted in one
> table in case of single table (if you the single root is denoted as a
> mappedsuperclass).
>
> Regarding joined, in case of multiple inheritance the first supertype is
> considered the real super, the others are treated as a
> mappedsuperclasses. So joined will work but only use one path to the root.
>
> Here are some other related links:
> https://bugs.eclipse.org/bugs/show_bug.cgi?id=153746
> http://www.elver.org/hibernate/inheritance.html#Multiple+Inh eritance+Support
>
> http://comments.gmane.org/gmane.comp.java.emf.persistency/64 5
> http://forum.hibernate.org/viewtopic.php?t=947670
>
> gr. Martin
>
> Andre Pareis wrote:
>> Hi,
>>
>> IIRC, the former teneo implementation (elver) did not create tables
>> for interface, whereas the new one does.
>>
>> I have, for example, an interface called "Identifiable" declaring an
>> "id" attribute. This way I can add the "id" feature to some classes by
>> just realizing this interface. I would also like to have a "Named"
>> interface with an attribute "name", which can be added in addition to
>> the Identifiable interface.
>>
>> I'm not sure if this is possible at all and how it would look like.
>> However, even if, my concerns with mapped interfaces are these:
>>
>> 1. It is IMO not desirable to see tables for interfaces as this can be
>> translated as implementation. Instead, the attributes defined in the
>> interface should be implemented only and first in the classes
>> implementing the interface.
>>
>> 2. I wonder if the current approach allows a JOINED mapping strategy
>> whilst having multiple super interfaces each declaring some attribute,
>> i.e., multiple inheritance as it is possible with EMF, which is
>> capable of implementing the declared attributes in all classes
>> implementing an interface.
>>
>> 3. As a side effect of the current solution: If I use SINGLE_TABLE at
>> present, then all classes implementing the Identifiable interface
>> (there are many) go into the "IDENTIFIABLE" table, which looks
>> extremely denormalized.
>>
>> I would be interested in your opinion and in the rationale behind the
>> current approach.
>>
>> Regards
>> Andre
>
>
|
|
|
Re: teneo - why tables for interfaces? [message #596482 is a reply to message #63615] |
Mon, 04 December 2006 18:14 ![Go to previous message Go to previous message](theme/Solstice/images/up.png) |
Martin Taal![Friend of Eclipse Friend](/donate/web-api/friends_decorator.php?email=mtaal%40springsite.com) Messages: 5468 Registered: July 2009 |
Senior Member |
|
|
Brian,
Both joined-subclass and single_table are supported. You can set this globally using an option (see
http://www.elver.org/hibernate/options.html) or per eclass by using the Inheritance annotation, see
http://www.elver.org/hibernate/ejb3_examples.html#inheritanc e
You can also use the MappedSuperclass annotation to force the supereclass to be persisted in the
table of the subclass.
gr. Martin
Brian Vetter wrote:
> I'm just getting started looking at Teneo when I saw this thread. Can
> Teneo use discriminators when using the table/subclass type of mapping
> in hibernate or is it fixed to use hibernate's "joined-subclass" mappings?
>
> Thanks,
>
> Brian
>
> Martin Taal wrote:
>> Hi Andre,
>> Teneo maps the model and not the actual java implementations
>> classes/interfaces. By also explicitly mapping the types (with
>> interface=true) modeled it is possible to do polymorphic queries on
>> the interface eclass.
>>
>> The reason that in case of multiple inheritance mappings are created
>> for each superinterface (although Hibernate does not support multiple
>> inheritance, and only the first is used) is that Teneo currently does
>> not identify if a type is used as the second or third type or also as
>> a first supertype somewhere (see bug link below).
>> As an example, say there is a SchoolBook type which inherits from
>> types Book and Asset. In this case EMF will let SchoolBookImpl inherit
>> from BookImpl and the SchoolBook interface from Book and Asset
>> interfaces.
>> Teneo will generate a mapping for SchoolBook, Book and Asset, The
>> SchoolBook mapping will have an extends attribute pointing to Book.
>> The attributes of Asset are mapped directly in SchoolBook but there is
>> no relation between SchoolBook and Asset but the Asset attributes are
>> mapped correctly (in the SchoolBook mapping). Asset is in a way
>> treated as a mappedsuperclass.
>> In this case the mapping (and table) for Asset is not stricly required
>> and can be removed. However Teneo then needs to discover that there
>> are no other subtypes which have Asset as the first supertype. This
>> feature needs to be added. I entered this myself as a bug (see issue
>> below) in august.
>>
>> Btw, you can prevent explicit mapping of the extra interface classes
>> by using the MappedSuperClass annotation (on the interface types).
>> This annotation will/should also prevent all classes to be persisted
>> in one table in case of single table (if you the single root is
>> denoted as a mappedsuperclass).
>>
>> Regarding joined, in case of multiple inheritance the first supertype
>> is considered the real super, the others are treated as a
>> mappedsuperclasses. So joined will work but only use one path to the
>> root.
>>
>> Here are some other related links:
>> https://bugs.eclipse.org/bugs/show_bug.cgi?id=153746
>> http://www.elver.org/hibernate/inheritance.html#Multiple+Inh eritance+Support
>>
>> http://comments.gmane.org/gmane.comp.java.emf.persistency/64 5
>> http://forum.hibernate.org/viewtopic.php?t=947670
>>
>> gr. Martin
>>
>> Andre Pareis wrote:
>>> Hi,
>>>
>>> IIRC, the former teneo implementation (elver) did not create tables
>>> for interface, whereas the new one does.
>>>
>>> I have, for example, an interface called "Identifiable" declaring an
>>> "id" attribute. This way I can add the "id" feature to some classes
>>> by just realizing this interface. I would also like to have a "Named"
>>> interface with an attribute "name", which can be added in addition to
>>> the Identifiable interface.
>>>
>>> I'm not sure if this is possible at all and how it would look like.
>>> However, even if, my concerns with mapped interfaces are these:
>>>
>>> 1. It is IMO not desirable to see tables for interfaces as this can
>>> be translated as implementation. Instead, the attributes defined in
>>> the interface should be implemented only and first in the classes
>>> implementing the interface.
>>>
>>> 2. I wonder if the current approach allows a JOINED mapping strategy
>>> whilst having multiple super interfaces each declaring some
>>> attribute, i.e., multiple inheritance as it is possible with EMF,
>>> which is capable of implementing the declared attributes in all
>>> classes implementing an interface.
>>>
>>> 3. As a side effect of the current solution: If I use SINGLE_TABLE at
>>> present, then all classes implementing the Identifiable interface
>>> (there are many) go into the "IDENTIFIABLE" table, which looks
>>> extremely denormalized.
>>>
>>> I would be interested in your opinion and in the rationale behind the
>>> current approach.
>>>
>>> Regards
>>> Andre
>>
>>
--
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
|
|
|
Goto Forum:
Current Time: Sat Aug 31 23:17:40 GMT 2024
Powered by FUDForum. Page generated in 0.05977 seconds
|