Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF "Technology" (Ecore Tools, EMFatic, etc)  » [Teneo]foreign key element in jdo not generated properly?
[Teneo]foreign key element in jdo not generated properly? [message #100339] Tue, 30 October 2007 17:34 Go to next message
Eclipse UserFriend
Originally posted by: vnikolov.us.ibm.com

Hello,

I'm using Teneo/JPOX and I'm observing a behaviour which I'm not sure
that is quite correct and I want to make sure with you that I'm not
mistaken.

After I generated the jdo file with
org.eclipse.emf.teneo.jpox.mapper.GenerateJDO class I noticed that
delete-action and update-action attributes of foreign keys with
non-containment relationship are missing. I found out that only the
foreign keys which represent containment relationship have
delete-action="cascade" set. The element with non-containment(the
relationship is achieved with xs:IDREF->xs:ID) has no such attributes.
By looking in elver.org I realized that this is the default behavior so
I tried to override it by setting SET_DEFAULT_CASCADE_ON_NON_CONTAINMENT
to TRUE. However, that setting did not help. The generated jdo element
was the same.

Here is my ant for generating the jdo:
<java
classname="org.eclipse.emf.teneo.jpox.mapper.GenerateJDO"
classpathref="teneo.jpox.classpath" fork="true" failonerror="true">
<arg value="package.jdo"/>
<arg value="${dir.genModel}/library.ecore"/>
<arg value="${dir.genModel}/base.ecore"/>
<arg
value=" -com.mycompany.library.MyLibraryPackage,com.mycompany.base.B asePackage "/>
<arg value="+teneo.mapping.fetch_containment_eagerly,true"/>
<arg value="+teneo.naming.join_column_naming_strategy,simple"/>
<arg value="+teneo.naming.max_sql_name_length,18"/>
<arg
value="+teneo.mapping.set_default_cascade_on_non_containment, true"/>
</java>


Here is part of the XML schema:

<xs:complexType name="Book">
<xs:sequence>
<xs:element name="title" type="base:Text" minOccurs="0"/>
<xs:element name="description" type="base:Text" minOccurs="0"/>
</xs:sequence>
<xs:attribute name="uniqueName" type="xs:string" use="optional"/>
<xs:attribute name="authorRef" type="xs:IDREF" use="required"
ecore:reference="library:Author"/>
<xs:attribute name="keyword" type="xs:string" use="optional"/>
</xs:complexType>

<xs:complexType name="Author">
<xs:attribute name="uniqueName" type="xs:ID" use="required" />
<xs:attribute name="name" type="xs:string" use="required" />
</xs:complexType>


Here is how jdo elements are generated:

<class name="com.mycompany.library.impl.BookImpl" requires-extent="true"
persistence-modifier="persistence-capable" detachable="true"
table="book" identity-type="datastore">
<implements name="com.mycompany.library.Book"/>
<implements name="org.eclipse.emf.ecore.EObject"/>
<implements name="org.eclipse.emf.common.notify.Notifier"/>
<inheritance strategy="new-table">
<discriminator column="dtype" strategy="value-map"
value="Book"/>
</inheritance>
<version strategy="version-number" column="e_version"/>
<field name="title" persistence-modifier="persistent"
dependent="true" delete-action="restrict" null-value="none">
<foreign-key delete-action="cascade"
update-action="cascade" name="book_titl"/>
<column name="title" allows-null="true"/>
<extension vendor-name="jpox" key="implementation-classes"
value="com.mycompany.base.impl.TextImpl"/>
</field>
<field name="description" persistence-modifier="persistent"
dependent="true" delete-action="restrict" null-value="none">
<foreign-key delete-action="cascade"
update-action="cascade" name="book_dscrptn"/>
<column name="description" allows-null="true"/>
<extension vendor-name="jpox" key="implementation-classes"
value="com.mycompany.base.impl.TextImpl"/>
</field>
<field name="keyword" persistence-modifier="persistent"
null-value="none"/>
<field name="authorRef" persistence-modifier="persistent"
delete-action="restrict" null-value="exception">
<foreign-key name="book_authrr"/>
<column name="authorref" allows-null="false"/>
<extension vendor-name="jpox" key="implementation-classes"
value="com.mycompany.impl.AuthorImpl"/>
<extension vendor-name="jpox" key="implementation-classes"
value="com.mycompany.impl.AuthorImpl"/>
</field>
...
</class>

Do you have any idea why the foreign key element is not generated with
proper attributes?

Thanks,
Vladimir
Re: [Teneo]foreign key element in jdo not generated properly? [message #100369 is a reply to message #100339] Wed, 31 October 2007 07:57 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Vladimir,
The default cascade of a non-containment relation is merge, persist and refresh. So cascading
deletes are not part of this. I think the term cascade can be confusion, in jpa it is the annotation
name and it can have values like: delete, merge etc. In jpox for the delete-action attribute cascade
means cascading delete.

To accomplish this you have to set an @Cascade annotation on the efeature with the cascade values
you want, for example:
@ManyToOne(cascade={MERGE,PERSIST,REFRESH})
or
@ManyToOne(cascade=ALL)

gr. Martin

Vladimir Nikolov wrote:
> Hello,
>
> I'm using Teneo/JPOX and I'm observing a behaviour which I'm not sure
> that is quite correct and I want to make sure with you that I'm not
> mistaken.
>
> After I generated the jdo file with
> org.eclipse.emf.teneo.jpox.mapper.GenerateJDO class I noticed that
> delete-action and update-action attributes of foreign keys with
> non-containment relationship are missing. I found out that only the
> foreign keys which represent containment relationship have
> delete-action="cascade" set. The element with non-containment(the
> relationship is achieved with xs:IDREF->xs:ID) has no such attributes.
> By looking in elver.org I realized that this is the default behavior so
> I tried to override it by setting SET_DEFAULT_CASCADE_ON_NON_CONTAINMENT
> to TRUE. However, that setting did not help. The generated jdo element
> was the same.
>
> Here is my ant for generating the jdo:
> <java classname="org.eclipse.emf.teneo.jpox.mapper.GenerateJDO"
> classpathref="teneo.jpox.classpath" fork="true" failonerror="true">
> <arg value="package.jdo"/>
> <arg value="${dir.genModel}/library.ecore"/>
> <arg value="${dir.genModel}/base.ecore"/>
> <arg
> value=" -com.mycompany.library.MyLibraryPackage,com.mycompany.base.B asePackage "/>
>
> <arg value="+teneo.mapping.fetch_containment_eagerly,true"/>
> <arg value="+teneo.naming.join_column_naming_strategy,simple"/>
> <arg value="+teneo.naming.max_sql_name_length,18"/>
> <arg
> value="+teneo.mapping.set_default_cascade_on_non_containment, true"/>
> </java>
>
>
> Here is part of the XML schema:
>
> <xs:complexType name="Book">
> <xs:sequence>
> <xs:element name="title" type="base:Text" minOccurs="0"/>
> <xs:element name="description" type="base:Text" minOccurs="0"/>
> </xs:sequence>
> <xs:attribute name="uniqueName" type="xs:string" use="optional"/>
> <xs:attribute name="authorRef" type="xs:IDREF" use="required"
> ecore:reference="library:Author"/>
> <xs:attribute name="keyword" type="xs:string" use="optional"/>
> </xs:complexType>
>
> <xs:complexType name="Author">
> <xs:attribute name="uniqueName" type="xs:ID" use="required" />
> <xs:attribute name="name" type="xs:string" use="required" />
> </xs:complexType>
>
>
> Here is how jdo elements are generated:
>
> <class name="com.mycompany.library.impl.BookImpl" requires-extent="true"
> persistence-modifier="persistence-capable" detachable="true"
> table="book" identity-type="datastore">
> <implements name="com.mycompany.library.Book"/>
> <implements name="org.eclipse.emf.ecore.EObject"/>
> <implements name="org.eclipse.emf.common.notify.Notifier"/>
> <inheritance strategy="new-table">
> <discriminator column="dtype" strategy="value-map"
> value="Book"/>
> </inheritance>
> <version strategy="version-number" column="e_version"/>
> <field name="title" persistence-modifier="persistent"
> dependent="true" delete-action="restrict" null-value="none">
> <foreign-key delete-action="cascade" update-action="cascade"
> name="book_titl"/>
> <column name="title" allows-null="true"/>
> <extension vendor-name="jpox" key="implementation-classes"
> value="com.mycompany.base.impl.TextImpl"/>
> </field>
> <field name="description" persistence-modifier="persistent"
> dependent="true" delete-action="restrict" null-value="none">
> <foreign-key delete-action="cascade" update-action="cascade"
> name="book_dscrptn"/>
> <column name="description" allows-null="true"/>
> <extension vendor-name="jpox" key="implementation-classes"
> value="com.mycompany.base.impl.TextImpl"/>
> </field>
> <field name="keyword" persistence-modifier="persistent"
> null-value="none"/>
> <field name="authorRef" persistence-modifier="persistent"
> delete-action="restrict" null-value="exception">
> <foreign-key name="book_authrr"/>
> <column name="authorref" allows-null="false"/>
> <extension vendor-name="jpox" key="implementation-classes"
> value="com.mycompany.impl.AuthorImpl"/>
> <extension vendor-name="jpox" key="implementation-classes"
> value="com.mycompany.impl.AuthorImpl"/>
> </field>
> ...
> </class>
>
> Do you have any idea why the foreign key element is not generated with
> proper attributes?
>
> Thanks,
> Vladimir


--

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]foreign key element in jdo not generated properly? [message #100423 is a reply to message #100369] Wed, 31 October 2007 12:05 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: vnikolov.us.ibm.com

Hello Martin,

Thanks for the response!

I'm using java 1.4 so I can't use annotations. Is there any other way of
setting this options?

Thanks,
Vladimir


Martin Taal wrote:
> Hi Vladimir,
> The default cascade of a non-containment relation is merge, persist and
> refresh. So cascading deletes are not part of this. I think the term
> cascade can be confusion, in jpa it is the annotation name and it can
> have values like: delete, merge etc. In jpox for the delete-action
> attribute cascade means cascading delete.
>
> To accomplish this you have to set an @Cascade annotation on the
> efeature with the cascade values you want, for example:
> @ManyToOne(cascade={MERGE,PERSIST,REFRESH})
> or
> @ManyToOne(cascade=ALL)
>
> gr. Martin
>
> Vladimir Nikolov wrote:
>> Hello,
>>
>> I'm using Teneo/JPOX and I'm observing a behaviour which I'm not sure
>> that is quite correct and I want to make sure with you that I'm not
>> mistaken.
>>
>> After I generated the jdo file with
>> org.eclipse.emf.teneo.jpox.mapper.GenerateJDO class I noticed that
>> delete-action and update-action attributes of foreign keys with
>> non-containment relationship are missing. I found out that only the
>> foreign keys which represent containment relationship have
>> delete-action="cascade" set. The element with non-containment(the
>> relationship is achieved with xs:IDREF->xs:ID) has no such attributes.
>> By looking in elver.org I realized that this is the default behavior
>> so I tried to override it by setting
>> SET_DEFAULT_CASCADE_ON_NON_CONTAINMENT to TRUE. However, that setting
>> did not help. The generated jdo element was the same.
>>
>> Here is my ant for generating the jdo:
>> <java
>> classname="org.eclipse.emf.teneo.jpox.mapper.GenerateJDO"
>> classpathref="teneo.jpox.classpath" fork="true" failonerror="true">
>> <arg value="package.jdo"/>
>> <arg value="${dir.genModel}/library.ecore"/>
>> <arg value="${dir.genModel}/base.ecore"/>
>> <arg
>> value=" -com.mycompany.library.MyLibraryPackage,com.mycompany.base.B asePackage "/>
>>
>> <arg value="+teneo.mapping.fetch_containment_eagerly,true"/>
>> <arg
>> value="+teneo.naming.join_column_naming_strategy,simple"/>
>> <arg value="+teneo.naming.max_sql_name_length,18"/>
>> <arg
>> value="+teneo.mapping.set_default_cascade_on_non_containment, true"/>
>> </java>
>>
>>
>> Here is part of the XML schema:
>>
>> <xs:complexType name="Book">
>> <xs:sequence>
>> <xs:element name="title" type="base:Text" minOccurs="0"/>
>> <xs:element name="description" type="base:Text"
>> minOccurs="0"/>
>> </xs:sequence>
>> <xs:attribute name="uniqueName" type="xs:string" use="optional"/>
>> <xs:attribute name="authorRef" type="xs:IDREF" use="required"
>> ecore:reference="library:Author"/>
>> <xs:attribute name="keyword" type="xs:string" use="optional"/>
>> </xs:complexType>
>>
>> <xs:complexType name="Author">
>> <xs:attribute name="uniqueName" type="xs:ID" use="required" />
>> <xs:attribute name="name" type="xs:string" use="required" />
>> </xs:complexType>
>>
>>
>> Here is how jdo elements are generated:
>>
>> <class name="com.mycompany.library.impl.BookImpl"
>> requires-extent="true" persistence-modifier="persistence-capable"
>> detachable="true" table="book" identity-type="datastore">
>> <implements name="com.mycompany.library.Book"/>
>> <implements name="org.eclipse.emf.ecore.EObject"/>
>> <implements name="org.eclipse.emf.common.notify.Notifier"/>
>> <inheritance strategy="new-table">
>> <discriminator column="dtype" strategy="value-map"
>> value="Book"/>
>> </inheritance>
>> <version strategy="version-number" column="e_version"/>
>> <field name="title" persistence-modifier="persistent"
>> dependent="true" delete-action="restrict" null-value="none">
>> <foreign-key delete-action="cascade"
>> update-action="cascade" name="book_titl"/>
>> <column name="title" allows-null="true"/>
>> <extension vendor-name="jpox" key="implementation-classes"
>> value="com.mycompany.base.impl.TextImpl"/>
>> </field>
>> <field name="description" persistence-modifier="persistent"
>> dependent="true" delete-action="restrict" null-value="none">
>> <foreign-key delete-action="cascade"
>> update-action="cascade" name="book_dscrptn"/>
>> <column name="description" allows-null="true"/>
>> <extension vendor-name="jpox" key="implementation-classes"
>> value="com.mycompany.base.impl.TextImpl"/>
>> </field>
>> <field name="keyword" persistence-modifier="persistent"
>> null-value="none"/>
>> <field name="authorRef" persistence-modifier="persistent"
>> delete-action="restrict" null-value="exception">
>> <foreign-key name="book_authrr"/>
>> <column name="authorref" allows-null="false"/>
>> <extension vendor-name="jpox" key="implementation-classes"
>> value="com.mycompany.impl.AuthorImpl"/>
>> <extension vendor-name="jpox" key="implementation-classes"
>> value="com.mycompany.impl.AuthorImpl"/>
>> </field>
>> ...
>> </class>
>>
>> Do you have any idea why the foreign key element is not generated with
>> proper attributes?
>>
>> Thanks,
>> Vladimir
>
>
Re: [Teneo]foreign key element in jdo not generated properly? [message #100437 is a reply to message #100423] Wed, 31 October 2007 12:10 Go to previous message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Vladimir,
With Teneo the annotations are not in the code but in the model itself either as eannotation or in a
separate xml file.

See here:
http://www.elver.org/jpox/ejb3_format.html

gr. Martin

Vladimir Nikolov wrote:
> Hello Martin,
>
> Thanks for the response!
>
> I'm using java 1.4 so I can't use annotations. Is there any other way of
> setting this options?
>
> Thanks,
> Vladimir
>
>
> Martin Taal wrote:
>> Hi Vladimir,
>> The default cascade of a non-containment relation is merge, persist
>> and refresh. So cascading deletes are not part of this. I think the
>> term cascade can be confusion, in jpa it is the annotation name and it
>> can have values like: delete, merge etc. In jpox for the delete-action
>> attribute cascade means cascading delete.
>>
>> To accomplish this you have to set an @Cascade annotation on the
>> efeature with the cascade values you want, for example:
>> @ManyToOne(cascade={MERGE,PERSIST,REFRESH})
>> or
>> @ManyToOne(cascade=ALL)
>>
>> gr. Martin
>>
>> Vladimir Nikolov wrote:
>>> Hello,
>>>
>>> I'm using Teneo/JPOX and I'm observing a behaviour which I'm not sure
>>> that is quite correct and I want to make sure with you that I'm not
>>> mistaken.
>>>
>>> After I generated the jdo file with
>>> org.eclipse.emf.teneo.jpox.mapper.GenerateJDO class I noticed that
>>> delete-action and update-action attributes of foreign keys with
>>> non-containment relationship are missing. I found out that only the
>>> foreign keys which represent containment relationship have
>>> delete-action="cascade" set. The element with non-containment(the
>>> relationship is achieved with xs:IDREF->xs:ID) has no such
>>> attributes. By looking in elver.org I realized that this is the
>>> default behavior so I tried to override it by setting
>>> SET_DEFAULT_CASCADE_ON_NON_CONTAINMENT to TRUE. However, that setting
>>> did not help. The generated jdo element was the same.
>>>
>>> Here is my ant for generating the jdo:
>>> <java
>>> classname="org.eclipse.emf.teneo.jpox.mapper.GenerateJDO"
>>> classpathref="teneo.jpox.classpath" fork="true" failonerror="true">
>>> <arg value="package.jdo"/>
>>> <arg value="${dir.genModel}/library.ecore"/>
>>> <arg value="${dir.genModel}/base.ecore"/>
>>> <arg
>>> value=" -com.mycompany.library.MyLibraryPackage,com.mycompany.base.B asePackage "/>
>>>
>>> <arg value="+teneo.mapping.fetch_containment_eagerly,true"/>
>>> <arg
>>> value="+teneo.naming.join_column_naming_strategy,simple"/>
>>> <arg value="+teneo.naming.max_sql_name_length,18"/>
>>> <arg
>>> value="+teneo.mapping.set_default_cascade_on_non_containment, true"/>
>>> </java>
>>>
>>>
>>> Here is part of the XML schema:
>>>
>>> <xs:complexType name="Book">
>>> <xs:sequence>
>>> <xs:element name="title" type="base:Text" minOccurs="0"/>
>>> <xs:element name="description" type="base:Text"
>>> minOccurs="0"/>
>>> </xs:sequence>
>>> <xs:attribute name="uniqueName" type="xs:string"
>>> use="optional"/>
>>> <xs:attribute name="authorRef" type="xs:IDREF" use="required"
>>> ecore:reference="library:Author"/>
>>> <xs:attribute name="keyword" type="xs:string" use="optional"/>
>>> </xs:complexType>
>>>
>>> <xs:complexType name="Author">
>>> <xs:attribute name="uniqueName" type="xs:ID" use="required" />
>>> <xs:attribute name="name" type="xs:string" use="required" />
>>> </xs:complexType>
>>>
>>>
>>> Here is how jdo elements are generated:
>>>
>>> <class name="com.mycompany.library.impl.BookImpl"
>>> requires-extent="true" persistence-modifier="persistence-capable"
>>> detachable="true" table="book" identity-type="datastore">
>>> <implements name="com.mycompany.library.Book"/>
>>> <implements name="org.eclipse.emf.ecore.EObject"/>
>>> <implements name="org.eclipse.emf.common.notify.Notifier"/>
>>> <inheritance strategy="new-table">
>>> <discriminator column="dtype" strategy="value-map"
>>> value="Book"/>
>>> </inheritance>
>>> <version strategy="version-number" column="e_version"/>
>>> <field name="title" persistence-modifier="persistent"
>>> dependent="true" delete-action="restrict" null-value="none">
>>> <foreign-key delete-action="cascade"
>>> update-action="cascade" name="book_titl"/>
>>> <column name="title" allows-null="true"/>
>>> <extension vendor-name="jpox"
>>> key="implementation-classes" value="com.mycompany.base.impl.TextImpl"/>
>>> </field>
>>> <field name="description" persistence-modifier="persistent"
>>> dependent="true" delete-action="restrict" null-value="none">
>>> <foreign-key delete-action="cascade"
>>> update-action="cascade" name="book_dscrptn"/>
>>> <column name="description" allows-null="true"/>
>>> <extension vendor-name="jpox"
>>> key="implementation-classes" value="com.mycompany.base.impl.TextImpl"/>
>>> </field>
>>> <field name="keyword" persistence-modifier="persistent"
>>> null-value="none"/>
>>> <field name="authorRef" persistence-modifier="persistent"
>>> delete-action="restrict" null-value="exception">
>>> <foreign-key name="book_authrr"/>
>>> <column name="authorref" allows-null="false"/>
>>> <extension vendor-name="jpox"
>>> key="implementation-classes" value="com.mycompany.impl.AuthorImpl"/>
>>> <extension vendor-name="jpox"
>>> key="implementation-classes" value="com.mycompany.impl.AuthorImpl"/>
>>> </field>
>>> ...
>>> </class>
>>>
>>> Do you have any idea why the foreign key element is not generated
>>> with proper attributes?
>>>
>>> Thanks,
>>> Vladimir
>>
>>


--

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]foreign key element in jdo not generated properly? [message #610175 is a reply to message #100339] Wed, 31 October 2007 07:57 Go to previous message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Vladimir,
The default cascade of a non-containment relation is merge, persist and refresh. So cascading
deletes are not part of this. I think the term cascade can be confusion, in jpa it is the annotation
name and it can have values like: delete, merge etc. In jpox for the delete-action attribute cascade
means cascading delete.

To accomplish this you have to set an @Cascade annotation on the efeature with the cascade values
you want, for example:
@ManyToOne(cascade={MERGE,PERSIST,REFRESH})
or
@ManyToOne(cascade=ALL)

gr. Martin

Vladimir Nikolov wrote:
> Hello,
>
> I'm using Teneo/JPOX and I'm observing a behaviour which I'm not sure
> that is quite correct and I want to make sure with you that I'm not
> mistaken.
>
> After I generated the jdo file with
> org.eclipse.emf.teneo.jpox.mapper.GenerateJDO class I noticed that
> delete-action and update-action attributes of foreign keys with
> non-containment relationship are missing. I found out that only the
> foreign keys which represent containment relationship have
> delete-action="cascade" set. The element with non-containment(the
> relationship is achieved with xs:IDREF->xs:ID) has no such attributes.
> By looking in elver.org I realized that this is the default behavior so
> I tried to override it by setting SET_DEFAULT_CASCADE_ON_NON_CONTAINMENT
> to TRUE. However, that setting did not help. The generated jdo element
> was the same.
>
> Here is my ant for generating the jdo:
> <java classname="org.eclipse.emf.teneo.jpox.mapper.GenerateJDO"
> classpathref="teneo.jpox.classpath" fork="true" failonerror="true">
> <arg value="package.jdo"/>
> <arg value="${dir.genModel}/library.ecore"/>
> <arg value="${dir.genModel}/base.ecore"/>
> <arg
> value=" -com.mycompany.library.MyLibraryPackage,com.mycompany.base.B asePackage "/>
>
> <arg value="+teneo.mapping.fetch_containment_eagerly,true"/>
> <arg value="+teneo.naming.join_column_naming_strategy,simple"/>
> <arg value="+teneo.naming.max_sql_name_length,18"/>
> <arg
> value="+teneo.mapping.set_default_cascade_on_non_containment, true"/>
> </java>
>
>
> Here is part of the XML schema:
>
> <xs:complexType name="Book">
> <xs:sequence>
> <xs:element name="title" type="base:Text" minOccurs="0"/>
> <xs:element name="description" type="base:Text" minOccurs="0"/>
> </xs:sequence>
> <xs:attribute name="uniqueName" type="xs:string" use="optional"/>
> <xs:attribute name="authorRef" type="xs:IDREF" use="required"
> ecore:reference="library:Author"/>
> <xs:attribute name="keyword" type="xs:string" use="optional"/>
> </xs:complexType>
>
> <xs:complexType name="Author">
> <xs:attribute name="uniqueName" type="xs:ID" use="required" />
> <xs:attribute name="name" type="xs:string" use="required" />
> </xs:complexType>
>
>
> Here is how jdo elements are generated:
>
> <class name="com.mycompany.library.impl.BookImpl" requires-extent="true"
> persistence-modifier="persistence-capable" detachable="true"
> table="book" identity-type="datastore">
> <implements name="com.mycompany.library.Book"/>
> <implements name="org.eclipse.emf.ecore.EObject"/>
> <implements name="org.eclipse.emf.common.notify.Notifier"/>
> <inheritance strategy="new-table">
> <discriminator column="dtype" strategy="value-map"
> value="Book"/>
> </inheritance>
> <version strategy="version-number" column="e_version"/>
> <field name="title" persistence-modifier="persistent"
> dependent="true" delete-action="restrict" null-value="none">
> <foreign-key delete-action="cascade" update-action="cascade"
> name="book_titl"/>
> <column name="title" allows-null="true"/>
> <extension vendor-name="jpox" key="implementation-classes"
> value="com.mycompany.base.impl.TextImpl"/>
> </field>
> <field name="description" persistence-modifier="persistent"
> dependent="true" delete-action="restrict" null-value="none">
> <foreign-key delete-action="cascade" update-action="cascade"
> name="book_dscrptn"/>
> <column name="description" allows-null="true"/>
> <extension vendor-name="jpox" key="implementation-classes"
> value="com.mycompany.base.impl.TextImpl"/>
> </field>
> <field name="keyword" persistence-modifier="persistent"
> null-value="none"/>
> <field name="authorRef" persistence-modifier="persistent"
> delete-action="restrict" null-value="exception">
> <foreign-key name="book_authrr"/>
> <column name="authorref" allows-null="false"/>
> <extension vendor-name="jpox" key="implementation-classes"
> value="com.mycompany.impl.AuthorImpl"/>
> <extension vendor-name="jpox" key="implementation-classes"
> value="com.mycompany.impl.AuthorImpl"/>
> </field>
> ...
> </class>
>
> Do you have any idea why the foreign key element is not generated with
> proper attributes?
>
> Thanks,
> Vladimir


--

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]foreign key element in jdo not generated properly? [message #610182 is a reply to message #100369] Wed, 31 October 2007 12:05 Go to previous message
Vladimir Nikolov is currently offline Vladimir NikolovFriend
Messages: 10
Registered: July 2009
Junior Member
Hello Martin,

Thanks for the response!

I'm using java 1.4 so I can't use annotations. Is there any other way of
setting this options?

Thanks,
Vladimir


Martin Taal wrote:
> Hi Vladimir,
> The default cascade of a non-containment relation is merge, persist and
> refresh. So cascading deletes are not part of this. I think the term
> cascade can be confusion, in jpa it is the annotation name and it can
> have values like: delete, merge etc. In jpox for the delete-action
> attribute cascade means cascading delete.
>
> To accomplish this you have to set an @Cascade annotation on the
> efeature with the cascade values you want, for example:
> @ManyToOne(cascade={MERGE,PERSIST,REFRESH})
> or
> @ManyToOne(cascade=ALL)
>
> gr. Martin
>
> Vladimir Nikolov wrote:
>> Hello,
>>
>> I'm using Teneo/JPOX and I'm observing a behaviour which I'm not sure
>> that is quite correct and I want to make sure with you that I'm not
>> mistaken.
>>
>> After I generated the jdo file with
>> org.eclipse.emf.teneo.jpox.mapper.GenerateJDO class I noticed that
>> delete-action and update-action attributes of foreign keys with
>> non-containment relationship are missing. I found out that only the
>> foreign keys which represent containment relationship have
>> delete-action="cascade" set. The element with non-containment(the
>> relationship is achieved with xs:IDREF->xs:ID) has no such attributes.
>> By looking in elver.org I realized that this is the default behavior
>> so I tried to override it by setting
>> SET_DEFAULT_CASCADE_ON_NON_CONTAINMENT to TRUE. However, that setting
>> did not help. The generated jdo element was the same.
>>
>> Here is my ant for generating the jdo:
>> <java
>> classname="org.eclipse.emf.teneo.jpox.mapper.GenerateJDO"
>> classpathref="teneo.jpox.classpath" fork="true" failonerror="true">
>> <arg value="package.jdo"/>
>> <arg value="${dir.genModel}/library.ecore"/>
>> <arg value="${dir.genModel}/base.ecore"/>
>> <arg
>> value=" -com.mycompany.library.MyLibraryPackage,com.mycompany.base.B asePackage "/>
>>
>> <arg value="+teneo.mapping.fetch_containment_eagerly,true"/>
>> <arg
>> value="+teneo.naming.join_column_naming_strategy,simple"/>
>> <arg value="+teneo.naming.max_sql_name_length,18"/>
>> <arg
>> value="+teneo.mapping.set_default_cascade_on_non_containment, true"/>
>> </java>
>>
>>
>> Here is part of the XML schema:
>>
>> <xs:complexType name="Book">
>> <xs:sequence>
>> <xs:element name="title" type="base:Text" minOccurs="0"/>
>> <xs:element name="description" type="base:Text"
>> minOccurs="0"/>
>> </xs:sequence>
>> <xs:attribute name="uniqueName" type="xs:string" use="optional"/>
>> <xs:attribute name="authorRef" type="xs:IDREF" use="required"
>> ecore:reference="library:Author"/>
>> <xs:attribute name="keyword" type="xs:string" use="optional"/>
>> </xs:complexType>
>>
>> <xs:complexType name="Author">
>> <xs:attribute name="uniqueName" type="xs:ID" use="required" />
>> <xs:attribute name="name" type="xs:string" use="required" />
>> </xs:complexType>
>>
>>
>> Here is how jdo elements are generated:
>>
>> <class name="com.mycompany.library.impl.BookImpl"
>> requires-extent="true" persistence-modifier="persistence-capable"
>> detachable="true" table="book" identity-type="datastore">
>> <implements name="com.mycompany.library.Book"/>
>> <implements name="org.eclipse.emf.ecore.EObject"/>
>> <implements name="org.eclipse.emf.common.notify.Notifier"/>
>> <inheritance strategy="new-table">
>> <discriminator column="dtype" strategy="value-map"
>> value="Book"/>
>> </inheritance>
>> <version strategy="version-number" column="e_version"/>
>> <field name="title" persistence-modifier="persistent"
>> dependent="true" delete-action="restrict" null-value="none">
>> <foreign-key delete-action="cascade"
>> update-action="cascade" name="book_titl"/>
>> <column name="title" allows-null="true"/>
>> <extension vendor-name="jpox" key="implementation-classes"
>> value="com.mycompany.base.impl.TextImpl"/>
>> </field>
>> <field name="description" persistence-modifier="persistent"
>> dependent="true" delete-action="restrict" null-value="none">
>> <foreign-key delete-action="cascade"
>> update-action="cascade" name="book_dscrptn"/>
>> <column name="description" allows-null="true"/>
>> <extension vendor-name="jpox" key="implementation-classes"
>> value="com.mycompany.base.impl.TextImpl"/>
>> </field>
>> <field name="keyword" persistence-modifier="persistent"
>> null-value="none"/>
>> <field name="authorRef" persistence-modifier="persistent"
>> delete-action="restrict" null-value="exception">
>> <foreign-key name="book_authrr"/>
>> <column name="authorref" allows-null="false"/>
>> <extension vendor-name="jpox" key="implementation-classes"
>> value="com.mycompany.impl.AuthorImpl"/>
>> <extension vendor-name="jpox" key="implementation-classes"
>> value="com.mycompany.impl.AuthorImpl"/>
>> </field>
>> ...
>> </class>
>>
>> Do you have any idea why the foreign key element is not generated with
>> proper attributes?
>>
>> Thanks,
>> Vladimir
>
>
Re: [Teneo]foreign key element in jdo not generated properly? [message #610183 is a reply to message #100423] Wed, 31 October 2007 12:10 Go to previous message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Vladimir,
With Teneo the annotations are not in the code but in the model itself either as eannotation or in a
separate xml file.

See here:
http://www.elver.org/jpox/ejb3_format.html

gr. Martin

Vladimir Nikolov wrote:
> Hello Martin,
>
> Thanks for the response!
>
> I'm using java 1.4 so I can't use annotations. Is there any other way of
> setting this options?
>
> Thanks,
> Vladimir
>
>
> Martin Taal wrote:
>> Hi Vladimir,
>> The default cascade of a non-containment relation is merge, persist
>> and refresh. So cascading deletes are not part of this. I think the
>> term cascade can be confusion, in jpa it is the annotation name and it
>> can have values like: delete, merge etc. In jpox for the delete-action
>> attribute cascade means cascading delete.
>>
>> To accomplish this you have to set an @Cascade annotation on the
>> efeature with the cascade values you want, for example:
>> @ManyToOne(cascade={MERGE,PERSIST,REFRESH})
>> or
>> @ManyToOne(cascade=ALL)
>>
>> gr. Martin
>>
>> Vladimir Nikolov wrote:
>>> Hello,
>>>
>>> I'm using Teneo/JPOX and I'm observing a behaviour which I'm not sure
>>> that is quite correct and I want to make sure with you that I'm not
>>> mistaken.
>>>
>>> After I generated the jdo file with
>>> org.eclipse.emf.teneo.jpox.mapper.GenerateJDO class I noticed that
>>> delete-action and update-action attributes of foreign keys with
>>> non-containment relationship are missing. I found out that only the
>>> foreign keys which represent containment relationship have
>>> delete-action="cascade" set. The element with non-containment(the
>>> relationship is achieved with xs:IDREF->xs:ID) has no such
>>> attributes. By looking in elver.org I realized that this is the
>>> default behavior so I tried to override it by setting
>>> SET_DEFAULT_CASCADE_ON_NON_CONTAINMENT to TRUE. However, that setting
>>> did not help. The generated jdo element was the same.
>>>
>>> Here is my ant for generating the jdo:
>>> <java
>>> classname="org.eclipse.emf.teneo.jpox.mapper.GenerateJDO"
>>> classpathref="teneo.jpox.classpath" fork="true" failonerror="true">
>>> <arg value="package.jdo"/>
>>> <arg value="${dir.genModel}/library.ecore"/>
>>> <arg value="${dir.genModel}/base.ecore"/>
>>> <arg
>>> value=" -com.mycompany.library.MyLibraryPackage,com.mycompany.base.B asePackage "/>
>>>
>>> <arg value="+teneo.mapping.fetch_containment_eagerly,true"/>
>>> <arg
>>> value="+teneo.naming.join_column_naming_strategy,simple"/>
>>> <arg value="+teneo.naming.max_sql_name_length,18"/>
>>> <arg
>>> value="+teneo.mapping.set_default_cascade_on_non_containment, true"/>
>>> </java>
>>>
>>>
>>> Here is part of the XML schema:
>>>
>>> <xs:complexType name="Book">
>>> <xs:sequence>
>>> <xs:element name="title" type="base:Text" minOccurs="0"/>
>>> <xs:element name="description" type="base:Text"
>>> minOccurs="0"/>
>>> </xs:sequence>
>>> <xs:attribute name="uniqueName" type="xs:string"
>>> use="optional"/>
>>> <xs:attribute name="authorRef" type="xs:IDREF" use="required"
>>> ecore:reference="library:Author"/>
>>> <xs:attribute name="keyword" type="xs:string" use="optional"/>
>>> </xs:complexType>
>>>
>>> <xs:complexType name="Author">
>>> <xs:attribute name="uniqueName" type="xs:ID" use="required" />
>>> <xs:attribute name="name" type="xs:string" use="required" />
>>> </xs:complexType>
>>>
>>>
>>> Here is how jdo elements are generated:
>>>
>>> <class name="com.mycompany.library.impl.BookImpl"
>>> requires-extent="true" persistence-modifier="persistence-capable"
>>> detachable="true" table="book" identity-type="datastore">
>>> <implements name="com.mycompany.library.Book"/>
>>> <implements name="org.eclipse.emf.ecore.EObject"/>
>>> <implements name="org.eclipse.emf.common.notify.Notifier"/>
>>> <inheritance strategy="new-table">
>>> <discriminator column="dtype" strategy="value-map"
>>> value="Book"/>
>>> </inheritance>
>>> <version strategy="version-number" column="e_version"/>
>>> <field name="title" persistence-modifier="persistent"
>>> dependent="true" delete-action="restrict" null-value="none">
>>> <foreign-key delete-action="cascade"
>>> update-action="cascade" name="book_titl"/>
>>> <column name="title" allows-null="true"/>
>>> <extension vendor-name="jpox"
>>> key="implementation-classes" value="com.mycompany.base.impl.TextImpl"/>
>>> </field>
>>> <field name="description" persistence-modifier="persistent"
>>> dependent="true" delete-action="restrict" null-value="none">
>>> <foreign-key delete-action="cascade"
>>> update-action="cascade" name="book_dscrptn"/>
>>> <column name="description" allows-null="true"/>
>>> <extension vendor-name="jpox"
>>> key="implementation-classes" value="com.mycompany.base.impl.TextImpl"/>
>>> </field>
>>> <field name="keyword" persistence-modifier="persistent"
>>> null-value="none"/>
>>> <field name="authorRef" persistence-modifier="persistent"
>>> delete-action="restrict" null-value="exception">
>>> <foreign-key name="book_authrr"/>
>>> <column name="authorref" allows-null="false"/>
>>> <extension vendor-name="jpox"
>>> key="implementation-classes" value="com.mycompany.impl.AuthorImpl"/>
>>> <extension vendor-name="jpox"
>>> key="implementation-classes" value="com.mycompany.impl.AuthorImpl"/>
>>> </field>
>>> ...
>>> </class>
>>>
>>> Do you have any idea why the foreign key element is not generated
>>> with proper attributes?
>>>
>>> Thanks,
>>> Vladimir
>>
>>


--

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
Previous Topic:[Teneo] comparison byte[] with Byte[]
Next Topic:[TENEO] Issues when loading models from an already existing Teneo database or deleting them
Goto Forum:
  


Current Time: Sat Apr 13 01:51:07 GMT 2024

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

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

Back to the top