Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » TENEO: Problems with AttributeOverride
TENEO: Problems with AttributeOverride [message #431160] Tue, 30 June 2009 20:28 Go to next message
Roberto Leibman is currently offline Roberto LeibmanFriend
Messages: 6
Registered: July 2009
Junior Member
I'm having a problem with an attribute override where the attribute I
want to override is in a doubly contained class.

Long story, I'm using the hibernate eclipse plugin to reverse engineer
java classes from hibernate mapping files. From the Java classes I'll
get the necessary teneo annotations that I'll put in the xsd's, from
which I'll generate an emf model.

Given the example below, for some reason, when I do a query the
persistence layer insists on using BAR_KEY instead of FOO_KEY.

Thanks a lot

Roberto Leibman

------------------------------------------------------------

Code follows.

The original mapping file looks something like this

<hibernate-mapping package="com.example">
<class
name="Foo"
table="FOO"
dynamic-update="false"
dynamic-insert="false"
lazy="false">
<component
name="bar"
class="com.example.Bar">
<component
name="yoyo"
class="com.example.Yoyo">
<property
name="key"
column="FOO_KEY"/>
</component>
</component>
</class>
</hibernate-mapping>

The generated classes, look like this:

@Entity
@Table(name = "FOO")
public class Foo {
@Embedded
@AttributeOverrides( {@AttributeOverride(name = "yoyo.key", column =
@Column(name = "FOO_KEY")) })
public Bar getBar() {
return bar;
}

public void setBar(Bar bar) {
this.bar = bar;
}

private Bar bar;
}


@Embeddable
public class Bar {
private Yoyo yoyo;

@Embedded
@AttributeOverrides( {@AttributeOverride(name = "key", column =
@Column(name = "BAR_KEY")) })
public Yoyo getYoyo() {
return yoyo;
}

public void setYoyo(Yoyo yoyo) {
this.yoyo = yoyo;
}
}

@Embeddable
public class Yoyo {
private String key;
@Column(name="KEY")
public String getKey() {
return key;
}

public void setKey(String key) {
this.key = key;
}

}

The XSD files are direct translations of the classes.
Re: TENEO: Problems with AttributeOverride [message #431162 is a reply to message #431160] Tue, 30 June 2009 22:10 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Roberto,
To understand better, do the classes/mapping below work or fail (with the error you describe)?

If it works, but Teneo fails, can you show the generated mapping for this case for Teneo? It can be retrieved from the
datastore using the method getMappingXml.

gr. Martin

Roberto Leibman wrote:
> I'm having a problem with an attribute override where the attribute I
> want to override is in a doubly contained class.
>
> Long story, I'm using the hibernate eclipse plugin to reverse engineer
> java classes from hibernate mapping files. From the Java classes I'll
> get the necessary teneo annotations that I'll put in the xsd's, from
> which I'll generate an emf model.
>
> Given the example below, for some reason, when I do a query the
> persistence layer insists on using BAR_KEY instead of FOO_KEY.
>
> Thanks a lot
>
> Roberto Leibman
>
> ------------------------------------------------------------
>
> Code follows.
>
> The original mapping file looks something like this
>
> <hibernate-mapping package="com.example">
> <class
> name="Foo"
> table="FOO"
> dynamic-update="false"
> dynamic-insert="false"
> lazy="false">
> <component
> name="bar"
> class="com.example.Bar">
> <component
> name="yoyo"
> class="com.example.Yoyo">
> <property
> name="key"
> column="FOO_KEY"/>
> </component>
> </component>
> </class>
> </hibernate-mapping>
>
> The generated classes, look like this:
>
> @Entity
> @Table(name = "FOO")
> public class Foo {
> @Embedded
> @AttributeOverrides( {@AttributeOverride(name = "yoyo.key", column =
> @Column(name = "FOO_KEY")) })
> public Bar getBar() {
> return bar;
> }
>
> public void setBar(Bar bar) {
> this.bar = bar;
> }
>
> private Bar bar;
> }
>
>
> @Embeddable
> public class Bar {
> private Yoyo yoyo;
>
> @Embedded
> @AttributeOverrides( {@AttributeOverride(name = "key", column =
> @Column(name = "BAR_KEY")) })
> public Yoyo getYoyo() {
> return yoyo;
> }
>
> public void setYoyo(Yoyo yoyo) {
> this.yoyo = yoyo;
> }
> }
>
> @Embeddable
> public class Yoyo {
> private String key;
> @Column(name="KEY")
> public String getKey() {
> return key;
> }
>
> public void setKey(String key) {
> this.key = key;
> }
>
> }
>
> The XSD files are direct translations of the classes.


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Cell: +31 (0)6 288 48 943
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@springsite.com - mtaal@elver.org
Web: www.springsite.com - www.elver.org
Re: TENEO: Problems with AttributeOverride [message #431163 is a reply to message #431162] Tue, 30 June 2009 22:20 Go to previous messageGo to next message
Roberto Leibman is currently offline Roberto LeibmanFriend
Messages: 6
Registered: July 2009
Junior Member
Hi Martin, Thanks for the quick response.
I'm not sure what it is that's failing, but what I see in the log is sql
with the wrong column name being used. I see bar.key instead of foo.key.

If I do a getMappingXml, I get something similar to the following (as
you can understand, I'm doing some heavy editing to give you sample code
without the complexities of the real code)

<hibernate-mapping package="com.example">
<class
name="FooImpl"
table="FOO"
dynamic-update="false"
dynamic-insert="false"
lazy="false">
<component
name="bar"
class="com.example.BarImpl">
<component
name="yoyo"
class="com.example.YoyoImpl">
<property
name="key"
column="BAR_KEY"/>
</component>
</component>
</class>
</hibernate-mapping>


Martin Taal wrote:
> Hi Roberto,
> To understand better, do the classes/mapping below work or fail (with
> the error you describe)?
>
> If it works, but Teneo fails, can you show the generated mapping for
> this case for Teneo? It can be retrieved from the datastore using the
> method getMappingXml.
>
> gr. Martin
>
> Roberto Leibman wrote:
>> I'm having a problem with an attribute override where the attribute I
>> want to override is in a doubly contained class.
>>
>> Long story, I'm using the hibernate eclipse plugin to reverse engineer
>> java classes from hibernate mapping files. From the Java classes I'll
>> get the necessary teneo annotations that I'll put in the xsd's, from
>> which I'll generate an emf model.
>>
>> Given the example below, for some reason, when I do a query the
>> persistence layer insists on using BAR_KEY instead of FOO_KEY.
>>
>> Thanks a lot
>>
>> Roberto Leibman
>>
>> ------------------------------------------------------------
>>
>> Code follows.
>>
>> The original mapping file looks something like this
>>
>> <hibernate-mapping package="com.example">
>> <class
>> name="Foo"
>> table="FOO"
>> dynamic-update="false"
>> dynamic-insert="false"
>> lazy="false">
>> <component
>> name="bar"
>> class="com.example.Bar">
>> <component
>> name="yoyo"
>> class="com.example.Yoyo">
>> <property
>> name="key"
>> column="FOO_KEY"/>
>> </component>
>> </component>
>> </class>
>> </hibernate-mapping>
>>
>> The generated classes, look like this:
>>
>> @Entity
>> @Table(name = "FOO")
>> public class Foo {
>> @Embedded
>> @AttributeOverrides( {@AttributeOverride(name = "yoyo.key", column =
>> @Column(name = "FOO_KEY")) })
>> public Bar getBar() {
>> return bar;
>> }
>>
>> public void setBar(Bar bar) {
>> this.bar = bar;
>> }
>>
>> private Bar bar;
>> }
>>
>>
>> @Embeddable
>> public class Bar {
>> private Yoyo yoyo;
>>
>> @Embedded
>> @AttributeOverrides( {@AttributeOverride(name = "key", column =
>> @Column(name = "BAR_KEY")) })
>> public Yoyo getYoyo() {
>> return yoyo;
>> }
>>
>> public void setYoyo(Yoyo yoyo) {
>> this.yoyo = yoyo;
>> }
>> }
>>
>> @Embeddable
>> public class Yoyo {
>> private String key;
>> @Column(name="KEY")
>> public String getKey() {
>> return key;
>> }
>>
>> public void setKey(String key) {
>> this.key = key;
>> }
>>
>> }
>>
>> The XSD files are direct translations of the classes.
>
>
Re: TENEO: Problems with AttributeOverride [message #431164 is a reply to message #431163] Tue, 30 June 2009 22:28 Go to previous message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Roberto,
I am pretty sure that Teneo does not support a path like construct (like yoyo.key) in the @AttributeOverride name
attribute, also in this case there is an order of resolving the overrides also. This can be added ofcourse, can you
enter a bugzilla for this? It would be best if you can also provide a test ecore model with annotations reflecting this
case...
Hopefully I have time around the weekend to add this behavior.

Also if you can let me know which version of Teneo you are using (tbe best is 1.1.1), as I prefer to limit the changes
to older releases.

gr. Martin

Roberto Leibman wrote:
> Hi Martin, Thanks for the quick response.
> I'm not sure what it is that's failing, but what I see in the log is sql
> with the wrong column name being used. I see bar.key instead of foo.key.
>
> If I do a getMappingXml, I get something similar to the following (as
> you can understand, I'm doing some heavy editing to give you sample code
> without the complexities of the real code)
>
> <hibernate-mapping package="com.example">
> <class
> name="FooImpl"
> table="FOO"
> dynamic-update="false"
> dynamic-insert="false"
> lazy="false">
> <component
> name="bar"
> class="com.example.BarImpl">
> <component
> name="yoyo"
> class="com.example.YoyoImpl">
> <property
> name="key"
> column="BAR_KEY"/>
> </component>
> </component>
> </class>
> </hibernate-mapping>
>
>
> Martin Taal wrote:
>> Hi Roberto,
>> To understand better, do the classes/mapping below work or fail (with
>> the error you describe)?
>>
>> If it works, but Teneo fails, can you show the generated mapping for
>> this case for Teneo? It can be retrieved from the datastore using the
>> method getMappingXml.
>>
>> gr. Martin
>>
>> Roberto Leibman wrote:
>>> I'm having a problem with an attribute override where the attribute I
>>> want to override is in a doubly contained class.
>>>
>>> Long story, I'm using the hibernate eclipse plugin to reverse engineer
>>> java classes from hibernate mapping files. From the Java classes I'll
>>> get the necessary teneo annotations that I'll put in the xsd's, from
>>> which I'll generate an emf model.
>>>
>>> Given the example below, for some reason, when I do a query the
>>> persistence layer insists on using BAR_KEY instead of FOO_KEY.
>>>
>>> Thanks a lot
>>>
>>> Roberto Leibman
>>>
>>> ------------------------------------------------------------
>>>
>>> Code follows.
>>>
>>> The original mapping file looks something like this
>>>
>>> <hibernate-mapping package="com.example">
>>> <class
>>> name="Foo"
>>> table="FOO"
>>> dynamic-update="false"
>>> dynamic-insert="false"
>>> lazy="false">
>>> <component
>>> name="bar"
>>> class="com.example.Bar">
>>> <component
>>> name="yoyo"
>>> class="com.example.Yoyo">
>>> <property
>>> name="key"
>>> column="FOO_KEY"/>
>>> </component>
>>> </component>
>>> </class>
>>> </hibernate-mapping>
>>>
>>> The generated classes, look like this:
>>>
>>> @Entity
>>> @Table(name = "FOO")
>>> public class Foo {
>>> @Embedded
>>> @AttributeOverrides( {@AttributeOverride(name = "yoyo.key", column =
>>> @Column(name = "FOO_KEY")) })
>>> public Bar getBar() {
>>> return bar;
>>> }
>>>
>>> public void setBar(Bar bar) {
>>> this.bar = bar;
>>> }
>>>
>>> private Bar bar;
>>> }
>>>
>>>
>>> @Embeddable
>>> public class Bar {
>>> private Yoyo yoyo;
>>>
>>> @Embedded
>>> @AttributeOverrides( {@AttributeOverride(name = "key", column =
>>> @Column(name = "BAR_KEY")) })
>>> public Yoyo getYoyo() {
>>> return yoyo;
>>> }
>>>
>>> public void setYoyo(Yoyo yoyo) {
>>> this.yoyo = yoyo;
>>> }
>>> }
>>>
>>> @Embeddable
>>> public class Yoyo {
>>> private String key;
>>> @Column(name="KEY")
>>> public String getKey() {
>>> return key;
>>> }
>>>
>>> public void setKey(String key) {
>>> this.key = key;
>>> }
>>>
>>> }
>>>
>>> The XSD files are direct translations of the classes.
>>


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Cell: +31 (0)6 288 48 943
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@springsite.com - mtaal@elver.org
Web: www.springsite.com - www.elver.org
Previous Topic:Proper namespace generation in document root
Next Topic:Copying EMF Mixed CData
Goto Forum:
  


Current Time: Mon Dec 09 01:46:46 GMT 2019

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

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

Back to the top