Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Effect of Ecore properties on generated hiberante mapping
Effect of Ecore properties on generated hiberante mapping [message #427678] Wed, 25 February 2009 22:21 Go to next message
Rachna Bakhru is currently offline Rachna BakhruFriend
Messages: 45
Registered: July 2009
Member
This is a multi-part message in MIME format.

------=_NextPart_000_0101_01C99754.60022490
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

I was trying to understand its effect on=20

1) unique identifier fields.

=20

When I create an id field using the ecore property iD=3Dtrue. (Case1)

<eClassifiers xsi:type=3D"ecore:EClass" name=3D"Book">
<eAnnotations source=3D"teneo.jpa">
<details key=3D"appinfo" =
value=3D" @Inheritance(strategy=3DJOINED)&#xD;&#xA;@Table(name =3D&quot;myb=
ooktable&quot;)"/>
</eAnnotations>
<eStructuralFeatures xsi:type=3D"ecore:EAttribute" name=3D"id" =
eType=3D"ecore:EDataType =
http://www.eclipse.org/emf/2002/Ecore#//EIntegerObject"
iD=3D"true"/>
<eStructuralFeatures xsi:type=3D"ecore:EAttribute" name=3D"title" =
lowerBound=3D"1" eType=3D"ecore:EDataType =
http://www.eclipse.org/emf/2002/Ecore#//EString">
<eAnnotations source=3D"teneo.jpa">
<details key=3D"appinfo" =
value=3D"@Column(name=3D&quot;book_title&quot;)"/>
</eAnnotations>
</eStructuralFeatures>

=20

It creates a mapping like this:

<class name=3D"com.library.impl.BookImpl" entity-name=3D"Book" =
abstract=3D"false" lazy=3D"false" table=3D"`mybooktable`">
<meta attribute=3D"eclassName">Book</meta>
<meta attribute=3D"epackage">library.ecore</meta>
<id name=3D"id" type=3D"java.lang.Integer">
<column not-null=3D"true" unique=3D"false" name=3D"`id`"/>
<generator class=3D"native"/>
</id>

=20

But when I create an id field with the tag @Id (Case2)

<eClassifiers xsi:type=3D"ecore:EClass" name=3D"Writer">
<eStructuralFeatures xsi:type=3D"ecore:EAttribute" name=3D"id" =
eType=3D"ecore:EDataType =
http://www.eclipse.org/emf/2002/Ecore#//EIntegerObject">
<eAnnotations source=3D"teneo.jpa">
<details key=3D"appinfo" value=3D"@Id"/>
</eAnnotations>
</eStructuralFeatures>
<eStructuralFeatures xsi:type=3D"ecore:EAttribute" name=3D"name" =
lowerBound=3D"1" eType=3D"ecore:EDataType =
http://www.eclipse.org/emf/2002/Ecore#//EString"/>
=20

=20

It creates a mapping like this

<class name=3D"com.library.impl.WriterImpl" entity-name=3D"Writer" =
abstract=3D"false" lazy=3D"false" discriminator-value=3D"Writer" =
table=3D"`writer`">
<meta attribute=3D"eclassName">Writer</meta>
<meta attribute=3D"epackage">library.ecore</meta>
<id name=3D"id" type=3D"java.lang.Integer">
<column not-null=3D"true" unique=3D"false" name=3D"`id`"/>
</id>

=20

Why doesn't it add <generator class=3D"native"/> in Case 2.

=20

I know I can add that using =
@GeneratedVale(strategy=3DGenerationType.AUTO)

=20

2) Ordering

<eStructuralFeatures xsi:type=3D"ecore:EReference" name=3D"books" =
ordered=3D"false"
upperBound=3D"-1" eType=3D"#//Book" =
eOpposite=3D"#//Book/author">
<eAnnotations source=3D"teneo.jpa">
<details key=3D"appinfo" =
value=3D"@OneToMany(cascade=3D{MERGE,PERSIST} =
targetEntity=3D&quot;Book&quot; mappedBy=3D&quot;author&quot;)"/>
</eAnnotations>
</eStructuralFeatures>

=20

When I use ordered=3D"false"

It changes the books collection from list to bag, but doesn't get rid of =
the <list-index column=3D"`writer_books_idx`"/>
<bag name=3D"books" lazy=3D"true" =
cascade=3D"merge,persist,save-update,lock">
<key update=3D"true">
<column name=3D"`myauthor_id`" not-null=3D"false" unique=3D"false"/>
</key>
<list-index column=3D"`writer_books_idx`"/>
<one-to-many entity-name=3D"Book"/>
</bag>

=20

only when I add indexed=3Dfalse does it do that.

@OneToMany(cascade=3D{MERGE,PERSIST} targetEntity=3D"Book" =
mappedBy=3D"author", indexed=3D"false")

Is it a good idea to use ecore properties?

=20

------=_NextPart_000_0101_01C99754.60022490
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 6.00.6000.16788" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY>
<DIV><FONT face=3DArial size=3D2>
<P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><SPAN=20
style=3D"FONT-SIZE: 10pt; FONT-FAMILY: 'Arial','sans-serif'">I was =
trying to=20
understand its effect on </SPAN><?xml:namespace prefix =3D o ns =3D=20
"urn:schemas-microsoft-com:office:office" /><o:p></o:p></P>
<P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><SPAN=20
style=3D"FONT-SIZE: 10pt; FONT-FAMILY: 'Arial','sans-serif'">1) unique =
identifier=20
fields.</SPAN><o:p></o:p></P>
<P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><FONT size=3D3><FONT=20
face=3DCalibri>&nbsp;<o:p></o:p></FONT></FONT></P>
<P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><SPAN=20
style=3D"FONT-SIZE: 10pt; FONT-FAMILY: 'Arial','sans-serif'">When I =
create an id=20
field using the ecore property iD=3Dtrue. (Case1)</SPAN><o:p></o:p></P>
<P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><SPAN=20
style=3D"FONT-SIZE: 10pt; FONT-FAMILY: =
'Arial','sans-serif'">&lt;eClassifiers=20
xsi:type=3D"ecore:EClass" name=3D"Book"&gt;<BR>&nbsp;&nbsp;&nbsp; =
&lt;eAnnotations=20
source=3D"teneo.jpa"&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;details=20
key=3D"appinfo"=20
value=3D" @Inheritance(strategy=3DJOINED)&amp;#xD;&amp;#xA;@Ta ble(name=3D&=
amp;quot;mybooktable&amp;quot;)"/&gt;<BR>&nbsp;&nbsp;&nbsp;=20
&lt;/eAnnotations&gt;<BR>&nbsp;&nbsp;&nbsp; &lt;eStructuralFeatures=20
xsi:type=3D"ecore:EAttribute" name=3D"id" eType=3D"ecore:EDataType =
</SPAN><A=20
href=3D"http://www.eclipse.org/emf/2002/Ecore#//EIntegerObject"><SPAN=20
style=3D"FONT-SIZE: 10pt; FONT-FAMILY: =
'Arial','sans-serif'">http://www.eclipse.org/emf/2002/Ecore#//EIntegerObj=
ect</SPAN></A><SPAN=20
style=3D"FONT-SIZE: 10pt; FONT-FAMILY: =
'Arial','sans-serif'">"<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; <STR=
ONG><SPAN=20
style=3D"FONT-FAMILY: 'Arial','sans-serif'">=20
iD=3D"true"/</SPAN></STRONG>&gt;<BR>&nbsp;&nbsp;&nbsp; =
&lt;eStructuralFeatures=20
xsi:type=3D"ecore:EAttribute" name=3D"title" lowerBound=3D"1" =
eType=3D"ecore:EDataType=20
</SPAN><A href=3D"http://www.eclipse.org/emf/2002/Ecore#//EString"><SPAN =

style=3D"FONT-SIZE: 10pt; FONT-FAMILY: =
'Arial','sans-serif'">http://www.eclipse.org/emf/2002/Ecore#//EString</SP=
AN></A><SPAN=20
style=3D"FONT-SIZE: 10pt; FONT-FAMILY: =
'Arial','sans-serif'">"&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
&lt;eAnnotations=20
source=3D"teneo.jpa"&gt;<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; =
&lt;details=20
key=3D"appinfo"=20
value=3D"@Column(name=3D&amp;quot;book_title&amp;quot;) "/&gt;<BR>&nbsp;&n=
bsp;&nbsp;&nbsp;&nbsp;=20
&lt;/eAnnotations&gt;<BR>&nbsp;&nbsp;&nbsp;=20
&lt;/eStructuralFeatures&gt;</SPAN><o:p></o:p></P >
<P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><FONT size=3D3><FONT=20
face=3DCalibri>&nbsp;<o:p></o:p></FONT></FONT></P>
<P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><SPAN=20
style=3D"FONT-SIZE: 10pt; FONT-FAMILY: 'Arial','sans-serif'">It creates =
a mapping=20
like this:</SPAN><o:p></o:p></P>
<P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><SPAN=20
style=3D"FONT-SIZE: 10pt; FONT-FAMILY: 'Arial','sans-serif'">&lt;class=20
name=3D"com.library.impl.BookImpl" entity-name=3D"Book" =
abstract=3D"false"=20
lazy=3D"false" table=3D"`mybooktable`"&gt;<BR>&nbsp;&nbsp;&lt;meta=20
attribute=3D"eclassName"&gt;Book&lt;/meta&gt;<BR >&nbsp;&nbsp;&lt;meta=20
attribute=3D"epackage"&gt;library.ecore&lt;/meta&gt; <BR>&nbsp;&nbsp;&lt;i=
d=20
name=3D"id" =
type=3D"java.lang.Integer"&gt;<BR>&nbsp;&nbsp;&nbsp;&lt;column=20
not-null=3D"true" unique=3D"false"=20
name=3D"`id`"/&gt;<BR>&nbsp;&nbsp;&nbsp; <STRONG><SPAN=20
style=3D"FONT-FAMILY: 'Arial','sans-serif'">&lt;generator=20
class=3D"native"/&gt;</SPAN></STRONG><B><BR></B>&nbsp;&nbsp;&lt;/id&gt; </=
SPAN><o:p></o:p></P>
<P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><FONT size=3D3><FONT=20
face=3DCalibri>&nbsp;<o:p></o:p></FONT></FONT></P>
<P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><SPAN=20
style=3D"FONT-SIZE: 10pt; FONT-FAMILY: 'Arial','sans-serif'">But when I =
create an=20
id field with the tag @Id (Case2)</SPAN><o:p></o:p></P>
<P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><SPAN=20
style=3D"FONT-SIZE: 10pt; FONT-FAMILY: =
'Arial','sans-serif'">&lt;eClassifiers=20
xsi:type=3D"ecore:EClass" name=3D"Writer"&gt;<BR>&nbsp;&nbsp;&nbsp;=20
&lt;eStructuralFeatures xsi:type=3D"ecore:EAttribute" name=3D"id"=20
eType=3D"ecore:EDataType <A=20
href=3D"http://www.eclipse.org/emf/2002/Ecore#//EIntegerObject">http://ww=
w.eclipse.org/emf/2002/Ecore#//EIntegerObject</A>"&gt; <BR>&nbsp;&nbsp;&nb=
sp;&nbsp;&nbsp;=20
&lt;eAnnotations=20
source=3D"teneo.jpa"&gt;<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; =
&lt;details=20
key=3D"appinfo" value=3D"@Id"/&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
&lt;/eAnnotations&gt;<BR>&nbsp;&nbsp;&nbsp;=20
&lt;/eStructuralFeatures&gt;<BR>&nbsp;&nbsp;&nbsp; =
&lt;eStructuralFeatures=20
xsi:type=3D"ecore:EAttribute" name=3D"name" lowerBound=3D"1" =
eType=3D"ecore:EDataType <A=20
href=3D"http://www.eclipse.org/emf/2002/Ecore#//EString">http://www.eclip=
se.org/emf/2002/Ecore#//EString"/</A>&gt;<BR>&nbsp;&nbsp;&nbsp;=20
</SPAN><o:p></o:p></P>
<P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><FONT size=3D3><FONT=20
face=3DCalibri>&nbsp;<o:p></o:p></FONT></FONT></P>
<P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><SPAN=20
style=3D"FONT-SIZE: 10pt; FONT-FAMILY: 'Arial','sans-serif'">It creates =
a mapping=20
like this</SPAN><o:p></o:p></P>
<P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><SPAN=20
style=3D"FONT-SIZE: 10pt; FONT-FAMILY: 'Arial','sans-serif'">&lt;class=20
name=3D"com.library.impl.WriterImpl" entity-name=3D"Writer" =
abstract=3D"false"=20
lazy=3D"false" discriminator-value=3D"Writer"=20
table=3D"`writer`"&gt;<BR>&nbsp;&nbsp;&lt;meta=20
attribute=3D"eclassName"&gt;Writer&lt;/meta&gt; <BR>&nbsp;&nbsp;&lt;meta=20
attribute=3D"epackage"&gt;library.ecore&lt;/meta&gt; <BR>&nbsp;&nbsp;&lt;i=
d=20
name=3D"id" =
type=3D"java.lang.Integer"&gt;<BR>&nbsp;&nbsp;&nbsp;&lt;column=20
not-null=3D"true" unique=3D"false"=20
name=3D"`id`"/&gt;<BR>&nbsp;&nbsp;&lt;/id&gt; </SPAN><o:p></o:p></P>
<P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><FONT size=3D3><FONT=20
face=3DCalibri>&nbsp;<o:p></o:p></FONT></FONT></P>
<P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><SPAN=20
style=3D"FONT-SIZE: 10pt; FONT-FAMILY: 'Arial','sans-serif'">Why doesn't =
it=20
add&nbsp;&nbsp;<STRONG><SPAN=20
style=3D"FONT-FAMILY: 'Arial','sans-serif'">&lt;generator =
class=3D"native"/&gt;=20
</SPAN></STRONG>in<STRONG><SPAN style=3D"FONT-FAMILY: =
'Arial','sans-serif'"> Case=20
2.</SPAN></STRONG></SPAN><o:p></o:p></P>
<P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><FONT size=3D3><FONT=20
face=3DCalibri>&nbsp;<o:p></o:p></FONT></FONT></P>
<P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><SPAN=20
style=3D"FONT-SIZE: 10pt; FONT-FAMILY: 'Arial','sans-serif'">I know I =
can add that=20
using =
@GeneratedVale(strategy=3DGenerationType.AUTO)</SPAN><o:p> </o:p></P>
<P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><FONT size=3D3><FONT=20
face=3DCalibri>&nbsp;<o:p></o:p></FONT></FONT></P>
<P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><SPAN=20
style=3D"FONT-SIZE: 10pt; FONT-FAMILY: 'Arial','sans-serif'">2)=20
Ordering</SPAN><o:p></o:p></P>
<P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><SPAN=20
style=3D"FONT-SIZE: 10pt; FONT-FAMILY: =
'Arial','sans-serif'">&lt;eStructuralFeatures=20
xsi:type=3D"ecore:EReference" name=3D"books" <STRONG><SPAN=20
style=3D"FONT-FAMILY: =
'Arial','sans-serif'">ordered=3D"false"</SPAN></STRONG><BR >&nbsp;&nbsp;&n=
bsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
upperBound=3D"-1" eType=3D"#//Book"=20
eOpposite=3D"#//Book/author"&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
&lt;eAnnotations=20
source=3D"teneo.jpa"&gt;<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; =
&lt;details=20
key=3D"appinfo" value=3D"@OneToMany(cascade=3D{MERGE,PERSIST}=20
targetEntity=3D&amp;quot;Book&amp;quot;=20
mappedBy=3D&amp;quot;author&amp;quot;)"/&gt;<BR >&nbsp;&nbsp;&nbsp;&nbsp;&=
nbsp;=20
&lt;/eAnnotations&gt;<BR>&nbsp;&nbsp;&nbsp;=20
&lt;/eStructuralFeatures&gt;</SPAN><o:p></o:p></P >
<P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><FONT size=3D3><FONT=20
face=3DCalibri>&nbsp;<o:p></o:p></FONT></FONT></P>
<P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><SPAN=20
style=3D"FONT-SIZE: 10pt; FONT-FAMILY: 'Arial','sans-serif'">When I use=20
ordered=3D"false"</SPAN><o:p></o:p></P>
<P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><SPAN=20
style=3D"FONT-SIZE: 10pt; FONT-FAMILY: 'Arial','sans-serif'">It changes =
the books=20
collection from list to bag, but doesn=92t get rid of=20
the&nbsp;&nbsp;&lt;list-index =
column=3D"`writer_books_idx`"/&gt;<BR>&lt;bag=20
name=3D"books" lazy=3D"true"=20
cascade=3D"merge,persist,save-update,lock"&gt;<BR>&nbsp;&nbsp;&nbsp;&lt;k=
ey=20
update=3D"true"&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&lt;column =
name=3D"`myauthor_id`"=20
not-null=3D"false"=20
unique=3D"false"/&gt;<BR>&nbsp;&nbsp;&nbsp;&lt;/key&gt; <BR>&nbsp;&nbsp;&n=
bsp;&lt;list-index=20
column=3D"`writer_books_idx`"/&gt;<BR>&nbsp;&nbsp;&nbsp;&lt;one-to-many=20
entity-name=3D"Book"/&gt;<BR>&nbsp;&nbsp;&lt;/bag&gt; </SPAN><o:p></o:p></=
P>
<P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><FONT size=3D3><FONT=20
face=3DCalibri>&nbsp;<o:p></o:p></FONT></FONT></P>
<P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><SPAN=20
style=3D"FONT-SIZE: 10pt; FONT-FAMILY: 'Arial','sans-serif'">only when I =
add=20
indexed=3Dfalse does it do that.</SPAN><o:p></o:p></P>
<P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><SPAN=20
style=3D"FONT-SIZE: 10pt; FONT-FAMILY: =
'Arial','sans-serif'">@OneToMany(cascade=3D{MERGE,PERSIST}=20
targetEntity=3D"Book" mappedBy=3D"author", <STRONG><SPAN=20
style=3D"FONT-FAMILY: =
'Arial','sans-serif'">indexed=3D"false")</SPAN></STRONG ></SPAN><o:p></o:p=
></P>
<P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><SPAN=20
style=3D"FONT-SIZE: 10pt; FONT-FAMILY: 'Arial','sans-serif'">Is it a =
good idea to=20
use ecore properties?</SPAN><o:p></o:p></P>
<P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><o:p><FONT =
face=3DCalibri=20
size=3D3>&nbsp;</FONT></o:p></P></FONT></DIV></BODY ></HTML>

------=_NextPart_000_0101_01C99754.60022490--
Re: Effect of Ecore properties on generated hiberante mapping [message #427679 is a reply to message #427678] Wed, 25 February 2009 22:36 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi RJ,
These are valid remarks!

1) you are correct that this difference should not be there, can you enter a bugzilla for this? If id=true then it
should not automatically add generator class="native", that can be controlled by a generator.

2) again a correct statement, the order="false" should make it a bag (that's correct) but the list-index should not be
there, can you enter a bugzilla for this to?

Overall I would use annotations more than use ecore properties to control persistence. With annotations you have much
more control and it is much more precise.

gr. Martin

RJDAG wrote:
>
>
> I was trying to understand its effect on
>
> 1) unique identifier fields.
>
>
>
> When I create an id field using the ecore property iD=true. (Case1)
>
> <eClassifiers xsi:type="ecore:EClass" name="Book">
> <eAnnotations source="teneo.jpa">
> <details key="appinfo"
> value=" @Inheritance(strategy=JOINED)&#xD;&#xA;@Table(name=& amp;quot;mybooktable&quot;) "/>
> </eAnnotations>
> <eStructuralFeatures xsi:type="ecore:EAttribute" name="id"
> eType="ecore:EDataType
> http://www.eclipse.org/emf/2002/Ecore#//EIntegerObject"
> * iD="true"/*>
> <eStructuralFeatures xsi:type="ecore:EAttribute" name="title"
> lowerBound="1" eType="ecore:EDataType
> http://www.eclipse.org/emf/2002/Ecore#//EString">
> <eAnnotations source="teneo.jpa">
> <details key="appinfo"
> value="@Column(name=&quot;book_title&quot;)"/>
> </eAnnotations>
> </eStructuralFeatures>
>
>
>
> It creates a mapping like this:
>
> <class name="com.library.impl.BookImpl" entity-name="Book"
> abstract="false" lazy="false" table="`mybooktable`">
> <meta attribute="eclassName">Book</meta>
> <meta attribute="epackage">library.ecore</meta>
> <id name="id" type="java.lang.Integer">
> <column not-null="true" unique="false" name="`id`"/>
> *<generator class="native"/>**
> * </id>
>
>
>
> But when I create an id field with the tag @Id (Case2)
>
> <eClassifiers xsi:type="ecore:EClass" name="Writer">
> <eStructuralFeatures xsi:type="ecore:EAttribute" name="id"
> eType="ecore:EDataType
> http://www.eclipse.org/emf/2002/Ecore#//EIntegerObject">
> <eAnnotations source="teneo.jpa">
> <details key="appinfo" value="@Id"/>
> </eAnnotations>
> </eStructuralFeatures>
> <eStructuralFeatures xsi:type="ecore:EAttribute" name="name"
> lowerBound="1" eType="ecore:EDataType
> http://www.eclipse.org/emf/2002/Ecore#//EString"/>
>
>
>
>
> It creates a mapping like this
>
> <class name="com.library.impl.WriterImpl" entity-name="Writer"
> abstract="false" lazy="false" discriminator-value="Writer" table="`writer`">
> <meta attribute="eclassName">Writer</meta>
> <meta attribute="epackage">library.ecore</meta>
> <id name="id" type="java.lang.Integer">
> <column not-null="true" unique="false" name="`id`"/>
> </id>
>
>
>
> Why doesn't it add *<generator class="native"/> *in* Case 2.*
>
>
>
> I know I can add that using @GeneratedVale(strategy=GenerationType.AUTO)
>
>
>
> 2) Ordering
>
> <eStructuralFeatures xsi:type="ecore:EReference" name="books"
> *ordered="false"*
> upperBound="-1" eType="#//Book" eOpposite="#//Book/author">
> <eAnnotations source="teneo.jpa">
> <details key="appinfo" value="@OneToMany(cascade={MERGE,PERSIST}
> targetEntity=&quot;Book&quot; mappedBy=&quot;author&quot;)"/>
> </eAnnotations>
> </eStructuralFeatures>
>
>
>
> When I use ordered="false"
>
> It changes the books collection from list to bag, but doesn’t get rid of
> the <list-index column="`writer_books_idx`"/>
> <bag name="books" lazy="true" cascade="merge,persist,save-update,lock">
> <key update="true">
> <column name="`myauthor_id`" not-null="false" unique="false"/>
> </key>
> <list-index column="`writer_books_idx`"/>
> <one-to-many entity-name="Book"/>
> </bag>
>
>
>
> only when I add indexed=false does it do that.
>
> @OneToMany(cascade={MERGE,PERSIST} targetEntity="Book"
> mappedBy="author", *indexed="false")*
>
> Is it a good idea to use ecore properties?
>
>
>


--

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: Effect of Ecore properties on generated hiberante mapping [message #427680 is a reply to message #427679] Thu, 26 February 2009 00:58 Go to previous messageGo to next message
Rachna Bakhru is currently offline Rachna BakhruFriend
Messages: 45
Registered: July 2009
Member
Thank you for the clarifications.
I will enter the bugs as soon as I setup a bugzilla account.

"Martin Taal" <mtaal@elver.org> wrote in message
news:go4h4r$sdm$1@build.eclipse.org...
> Hi RJ,
> These are valid remarks!
>
> 1) you are correct that this difference should not be there, can you enter
> a bugzilla for this? If id=true then it should not automatically add
> generator class="native", that can be controlled by a generator.
>
> 2) again a correct statement, the order="false" should make it a bag
> (that's correct) but the list-index should not be there, can you enter a
> bugzilla for this to?
>
> Overall I would use annotations more than use ecore properties to control
> persistence. With annotations you have much more control and it is much
> more precise.
>
> gr. Martin
>
> RJDAG wrote:
>>
>>
>> I was trying to understand its effect on
>>
>> 1) unique identifier fields.
>>
>> When I create an id field using the ecore property iD=true. (Case1)
>>
>> <eClassifiers xsi:type="ecore:EClass" name="Book">
>> <eAnnotations source="teneo.jpa">
>> <details key="appinfo"
>> value=" @Inheritance(strategy=JOINED)&#xD;&#xA;@Table(name=& amp;quot;mybooktable&quot;) "/>
>> </eAnnotations>
>> <eStructuralFeatures xsi:type="ecore:EAttribute" name="id"
>> eType="ecore:EDataType
>> http://www.eclipse.org/emf/2002/Ecore#//EIntegerObject"
>> * iD="true"/*>
>> <eStructuralFeatures xsi:type="ecore:EAttribute" name="title"
>> lowerBound="1" eType="ecore:EDataType
>> http://www.eclipse.org/emf/2002/Ecore#//EString">
>> <eAnnotations source="teneo.jpa">
>> <details key="appinfo"
>> value="@Column(name=&quot;book_title&quot;)"/>
>> </eAnnotations>
>> </eStructuralFeatures>
>>
>> It creates a mapping like this:
>>
>> <class name="com.library.impl.BookImpl" entity-name="Book"
>> abstract="false" lazy="false" table="`mybooktable`">
>> <meta attribute="eclassName">Book</meta>
>> <meta attribute="epackage">library.ecore</meta>
>> <id name="id" type="java.lang.Integer">
>> <column not-null="true" unique="false" name="`id`"/>
>> *<generator class="native"/>**
>> * </id>
>>
>> But when I create an id field with the tag @Id (Case2)
>>
>> <eClassifiers xsi:type="ecore:EClass" name="Writer">
>> <eStructuralFeatures xsi:type="ecore:EAttribute" name="id"
>> eType="ecore:EDataType
>> http://www.eclipse.org/emf/2002/Ecore#//EIntegerObject">
>> <eAnnotations source="teneo.jpa">
>> <details key="appinfo" value="@Id"/>
>> </eAnnotations>
>> </eStructuralFeatures>
>> <eStructuralFeatures xsi:type="ecore:EAttribute" name="name"
>> lowerBound="1" eType="ecore:EDataType
>> http://www.eclipse.org/emf/2002/Ecore#//EString"/>
>> It creates a mapping like this
>>
>> <class name="com.library.impl.WriterImpl" entity-name="Writer"
>> abstract="false" lazy="false" discriminator-value="Writer"
>> table="`writer`">
>> <meta attribute="eclassName">Writer</meta>
>> <meta attribute="epackage">library.ecore</meta>
>> <id name="id" type="java.lang.Integer">
>> <column not-null="true" unique="false" name="`id`"/>
>> </id>
>>
>> Why doesn't it add *<generator class="native"/> *in* Case 2.*
>>
>> I know I can add that using @GeneratedVale(strategy=GenerationType.AUTO)
>>
>> 2) Ordering
>>
>> <eStructuralFeatures xsi:type="ecore:EReference" name="books"
>> *ordered="false"*
>> upperBound="-1" eType="#//Book" eOpposite="#//Book/author">
>> <eAnnotations source="teneo.jpa">
>> <details key="appinfo" value="@OneToMany(cascade={MERGE,PERSIST}
>> targetEntity=&quot;Book&quot; mappedBy=&quot;author&quot;)"/>
>> </eAnnotations>
>> </eStructuralFeatures>
>>
>> When I use ordered="false"
>>
>> It changes the books collection from list to bag, but doesn
Re: Effect of Ecore properties on generated hiberante mapping [message #427743 is a reply to message #427680] Fri, 27 February 2009 23:00 Go to previous message
Rachna Bakhru is currently offline Rachna BakhruFriend
Messages: 45
Registered: July 2009
Member
Bugs created:
https://bugs.eclipse.org/bugs/show_bug.cgi?id=266572
https://bugs.eclipse.org/bugs/show_bug.cgi?id=266573

"RJDAG" <rjotwani@dag.com> wrote in message
news:go4pi3$9bh$1@build.eclipse.org...
> Thank you for the clarifications.
> I will enter the bugs as soon as I setup a bugzilla account.
>
> "Martin Taal" <mtaal@elver.org> wrote in message
> news:go4h4r$sdm$1@build.eclipse.org...
>> Hi RJ,
>> These are valid remarks!
>>
>> 1) you are correct that this difference should not be there, can you
>> enter a bugzilla for this? If id=true then it should not automatically
>> add generator class="native", that can be controlled by a generator.
>>
>> 2) again a correct statement, the order="false" should make it a bag
>> (that's correct) but the list-index should not be there, can you enter a
>> bugzilla for this to?
>>
>> Overall I would use annotations more than use ecore properties to control
>> persistence. With annotations you have much more control and it is much
>> more precise.
>>
>> gr. Martin
>>
>> RJDAG wrote:
>>>
>>>
>>> I was trying to understand its effect on
>>>
>>> 1) unique identifier fields.
>>>
>>> When I create an id field using the ecore property iD=true. (Case1)
>>>
>>> <eClassifiers xsi:type="ecore:EClass" name="Book">
>>> <eAnnotations source="teneo.jpa">
>>> <details key="appinfo"
>>> value=" @Inheritance(strategy=JOINED)&#xD;&#xA;@Table(name=& amp;quot;mybooktable&quot;) "/>
>>> </eAnnotations>
>>> <eStructuralFeatures xsi:type="ecore:EAttribute" name="id"
>>> eType="ecore:EDataType
>>> http://www.eclipse.org/emf/2002/Ecore#//EIntegerObject"
>>> * iD="true"/*>
>>> <eStructuralFeatures xsi:type="ecore:EAttribute" name="title"
>>> lowerBound="1" eType="ecore:EDataType
>>> http://www.eclipse.org/emf/2002/Ecore#//EString">
>>> <eAnnotations source="teneo.jpa">
>>> <details key="appinfo"
>>> value="@Column(name=&quot;book_title&quot;)"/>
>>> </eAnnotations>
>>> </eStructuralFeatures>
>>>
>>> It creates a mapping like this:
>>>
>>> <class name="com.library.impl.BookImpl" entity-name="Book"
>>> abstract="false" lazy="false" table="`mybooktable`">
>>> <meta attribute="eclassName">Book</meta>
>>> <meta attribute="epackage">library.ecore</meta>
>>> <id name="id" type="java.lang.Integer">
>>> <column not-null="true" unique="false" name="`id`"/>
>>> *<generator class="native"/>**
>>> * </id>
>>>
>>> But when I create an id field with the tag @Id (Case2)
>>>
>>> <eClassifiers xsi:type="ecore:EClass" name="Writer">
>>> <eStructuralFeatures xsi:type="ecore:EAttribute" name="id"
>>> eType="ecore:EDataType
>>> http://www.eclipse.org/emf/2002/Ecore#//EIntegerObject">
>>> <eAnnotations source="teneo.jpa">
>>> <details key="appinfo" value="@Id"/>
>>> </eAnnotations>
>>> </eStructuralFeatures>
>>> <eStructuralFeatures xsi:type="ecore:EAttribute" name="name"
>>> lowerBound="1" eType="ecore:EDataType
>>> http://www.eclipse.org/emf/2002/Ecore#//EString"/>
>>> It creates a mapping like this
>>>
>>> <class name="com.library.impl.WriterImpl" entity-name="Writer"
>>> abstract="false" lazy="false" discriminator-value="Writer"
>>> table="`writer`">
>>> <meta attribute="eclassName">Writer</meta>
>>> <meta attribute="epackage">library.ecore</meta>
>>> <id name="id" type="java.lang.Integer">
>>> <column not-null="true" unique="false" name="`id`"/>
>>> </id>
>>>
>>> Why doesn't it add *<generator class="native"/> *in* Case 2.*
>>>
>>> I know I can add that using
>>> @GeneratedVale(strategy=GenerationType.AUTO)
>>>
>>> 2) Ordering
>>>
>>> <eStructuralFeatures xsi:type="ecore:EReference" name="books"
>>> *ordered="false"*
>>> upperBound="-1" eType="#//Book" eOpposite="#//Book/author">
>>> <eAnnotations source="teneo.jpa">
>>> <details key="appinfo" value="@OneToMany(cascade={MERGE,PERSIST}
>>> targetEntity=&quot;Book&quot; mappedBy=&quot;author&quot;)"/>
>>> </eAnnotations>
>>> </eStructuralFeatures>
>>>
>>> When I use ordered="false"
>>>
>>> It changes the books collection from list to bag, but doesn't get rid of
>>> the <list-index column="`writer_books_idx`"/>
>>> <bag name="books" lazy="true" cascade="merge,persist,save-update,lock">
>>> <key update="true">
>>> <column name="`myauthor_id`" not-null="false" unique="false"/>
>>> </key>
>>> <list-index column="`writer_books_idx`"/>
>>> <one-to-many entity-name="Book"/>
>>> </bag>
>>>
>>> only when I add indexed=false does it do that.
>>>
>>> @OneToMany(cascade={MERGE,PERSIST} targetEntity="Book"
>>> mappedBy="author", *indexed="false")*
>>>
>>> Is it a good idea to use ecore properties?
>>>
>>>
>>
>>
>> --
>>
>> 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:Ordering collections in a one-to-many association
Next Topic:Re: Best practice: Modifying model in ok/cancel dialog.
Goto Forum:
  


Current Time: Fri Apr 26 04:32:58 GMT 2024

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

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

Back to the top