Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF "Technology" (Ecore Tools, EMFatic, etc)  » [teneo] unique/required java annotations
[teneo] unique/required java annotations [message #85624] Wed, 06 June 2007 15:19 Go to next message
Paul Gardiner is currently offline Paul GardinerFriend
Messages: 94
Registered: July 2009
Member
Are there annotations for uniqueness and required fields? I am using java
annotations, so I have interfaces like this:

/**
* @model
*/
public interface MyType extends EObject{
/**
* @model
*/
getId();
}

Then whenever I create a new "MyType", I check to see if one already exists
by using a query. After doing this a bunch of times, I figured there must
be an annotation for this, such as @model unique="true" required="true", or
something like that, but I can't find anything about it.

Thanks,
Paul
Re: [teneo] unique/required java annotations [message #85651 is a reply to message #85624] Wed, 06 June 2007 16:56 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: merks.ca.ibm.com

Paul,

Maybe you want @model id="true" to define an EAttribute with isID true,
which will require that the given attribute's value is unique within the
containing resource.


Paul Gardiner wrote:
> Are there annotations for uniqueness and required fields? I am using java
> annotations, so I have interfaces like this:
>
> /**
> * @model
> */
> public interface MyType extends EObject{
> /**
> * @model
> */
> getId();
> }
>
> Then whenever I create a new "MyType", I check to see if one already exists
> by using a query. After doing this a bunch of times, I figured there must
> be an annotation for this, such as @model unique="true" required="true", or
> something like that, but I can't find anything about it.
>
> Thanks,
> Paul
>
>
>
Re: [teneo] unique/required java annotations [message #85692 is a reply to message #85651] Wed, 06 June 2007 21:25 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Paul,
Yes, as Ed says, do you mean a primary key? Or just a general uniqueness, required constraint?

Here is an example on how to set required:
@Basic(optional=false)

Here is an example for setting uniqueconstraints using annotations in a xsd:

<xsd:complexType name="Item">
<xsd:annotation>
<xsd:appinfo source="teneo.jpa">
@Table(name="MYITEMTABLE"
uniqueConstraints={@UniqueConstraint(columnNames={"MYSTR", "MYINT","MYPROJECT"})})</xsd:appinfo>
</xsd:annotation>
<xsd:sequence>
<xsd:element name="name" type="xsd:string">
<xsd:annotation>
<xsd:appinfo source="teneo.jpa">@Column(name="MYSTR")</xsd:appinfo>
</xsd:annotation>
</xsd:element>
<xsd:element name="project" type="xsd:IDREF" ecore:reference="this:Project" minOccurs="0">
<xsd:annotation>
<xsd:appinfo source="teneo.jpa">@JoinColumn(name="MYPROJECT")</xsd:appinfo >
</xsd:annotation>
</xsd:element>
<xsd:element name="age" type="xsd:int">
<xsd:annotation>
<xsd:appinfo source="teneo.jpa">@Column(name="MYINT")</xsd:appinfo>
</xsd:annotation>
</xsd:element>
</xsd:sequence>
</xsd:complexType>

gr. Martin

Ed Merks wrote:
> Paul,
>
> Maybe you want @model id="true" to define an EAttribute with isID true,
> which will require that the given attribute's value is unique within the
> containing resource.
>
>
> Paul Gardiner wrote:
>> Are there annotations for uniqueness and required fields? I am using
>> java annotations, so I have interfaces like this:
>>
>> /**
>> * @model
>> */
>> public interface MyType extends EObject{
>> /**
>> * @model
>> */
>> getId();
>> }
>>
>> Then whenever I create a new "MyType", I check to see if one already
>> exists by using a query. After doing this a bunch of times, I figured
>> there must be an annotation for this, such as @model unique="true"
>> required="true", or something like that, but I can't find anything
>> about it.
>>
>> Thanks,
>> Paul
>>
>>


--

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] unique/required java annotations [message #85783 is a reply to message #85692] Thu, 07 June 2007 14:25 Go to previous messageGo to next message
Paul Gardiner is currently offline Paul GardinerFriend
Messages: 94
Registered: July 2009
Member
Thanks for the responses. I think it's working ok now. I misunderstood how
it worked. Now I have the collection (an EList) that holds "MyType"
annotated with @model type="..." unique="true", and I modified the equals
method of MyType to behave the way I want, and now everything is working
great.

"Martin Taal" <mtaal@elver.org> wrote in message
news:f478no$en4$1@build.eclipse.org...
> Hi Paul,
> Yes, as Ed says, do you mean a primary key? Or just a general uniqueness,
> required constraint?
>
> Here is an example on how to set required:
> @Basic(optional=false)
>
> Here is an example for setting uniqueconstraints using annotations in a
> xsd:
>
> <xsd:complexType name="Item">
> <xsd:annotation>
> <xsd:appinfo source="teneo.jpa">
> @Table(name="MYITEMTABLE"
> uniqueConstraints={@UniqueConstraint(columnNames={"MYSTR", "MYINT","MYPROJECT"})})</xsd:appinfo>
> </xsd:annotation>
> <xsd:sequence>
> <xsd:element name="name" type="xsd:string">
> <xsd:annotation>
> <xsd:appinfo source="teneo.jpa">@Column(name="MYSTR")</xsd:appinfo>
> </xsd:annotation>
> </xsd:element>
> <xsd:element name="project" type="xsd:IDREF"
> ecore:reference="this:Project" minOccurs="0">
> <xsd:annotation>
> <xsd:appinfo
> source="teneo.jpa">@JoinColumn(name="MYPROJECT")</xsd:appinfo >
> </xsd:annotation>
> </xsd:element>
> <xsd:element name="age" type="xsd:int">
> <xsd:annotation>
> <xsd:appinfo source="teneo.jpa">@Column(name="MYINT")</xsd:appinfo>
> </xsd:annotation>
> </xsd:element>
> </xsd:sequence>
> </xsd:complexType>
>
> gr. Martin
>
> Ed Merks wrote:
>> Paul,
>>
>> Maybe you want @model id="true" to define an EAttribute with isID true,
>> which will require that the given attribute's value is unique within the
>> containing resource.
>>
>>
>> Paul Gardiner wrote:
>>> Are there annotations for uniqueness and required fields? I am using
>>> java annotations, so I have interfaces like this:
>>>
>>> /**
>>> * @model
>>> */
>>> public interface MyType extends EObject{
>>> /**
>>> * @model
>>> */
>>> getId();
>>> }
>>>
>>> Then whenever I create a new "MyType", I check to see if one already
>>> exists by using a query. After doing this a bunch of times, I figured
>>> there must be an annotation for this, such as @model unique="true"
>>> required="true", or something like that, but I can't find anything about
>>> it.
>>>
>>> Thanks,
>>> Paul
>>>
>>>
>
>
> --
>
> 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] unique/required java annotations [message #85811 is a reply to message #85783] Thu, 07 June 2007 14:42 Go to previous message
Eclipse UserFriend
Originally posted by: merks.ca.ibm.com

This is a multi-part message in MIME format.
--------------010107040002090903070009
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

Paul,

Note that we strongly advise against changing the hashCode and equals
implementation for EObjects. The framework expects that == and .equals
will be equivalent for any EObject implementation, so violating that
assumption is likely to cause problems.


Paul Gardiner wrote:
> Thanks for the responses. I think it's working ok now. I misunderstood how
> it worked. Now I have the collection (an EList) that holds "MyType"
> annotated with @model type="..." unique="true", and I modified the equals
> method of MyType to behave the way I want, and now everything is working
> great.
>
> "Martin Taal" <mtaal@elver.org> wrote in message
> news:f478no$en4$1@build.eclipse.org...
>
>> Hi Paul,
>> Yes, as Ed says, do you mean a primary key? Or just a general uniqueness,
>> required constraint?
>>
>> Here is an example on how to set required:
>> @Basic(optional=false)
>>
>> Here is an example for setting uniqueconstraints using annotations in a
>> xsd:
>>
>> <xsd:complexType name="Item">
>> <xsd:annotation>
>> <xsd:appinfo source="teneo.jpa">
>> @Table(name="MYITEMTABLE"
>> uniqueConstraints={@UniqueConstraint(columnNames={"MYSTR", "MYINT","MYPROJECT"})})</xsd:appinfo>
>> </xsd:annotation>
>> <xsd:sequence>
>> <xsd:element name="name" type="xsd:string">
>> <xsd:annotation>
>> <xsd:appinfo source="teneo.jpa">@Column(name="MYSTR")</xsd:appinfo>
>> </xsd:annotation>
>> </xsd:element>
>> <xsd:element name="project" type="xsd:IDREF"
>> ecore:reference="this:Project" minOccurs="0">
>> <xsd:annotation>
>> <xsd:appinfo
>> source="teneo.jpa">@JoinColumn(name="MYPROJECT")</xsd:appinfo >
>> </xsd:annotation>
>> </xsd:element>
>> <xsd:element name="age" type="xsd:int">
>> <xsd:annotation>
>> <xsd:appinfo source="teneo.jpa">@Column(name="MYINT")</xsd:appinfo>
>> </xsd:annotation>
>> </xsd:element>
>> </xsd:sequence>
>> </xsd:complexType>
>>
>> gr. Martin
>>
>> Ed Merks wrote:
>>
>>> Paul,
>>>
>>> Maybe you want @model id="true" to define an EAttribute with isID true,
>>> which will require that the given attribute's value is unique within the
>>> containing resource.
>>>
>>>
>>> Paul Gardiner wrote:
>>>
>>>> Are there annotations for uniqueness and required fields? I am using
>>>> java annotations, so I have interfaces like this:
>>>>
>>>> /**
>>>> * @model
>>>> */
>>>> public interface MyType extends EObject{
>>>> /**
>>>> * @model
>>>> */
>>>> getId();
>>>> }
>>>>
>>>> Then whenever I create a new "MyType", I check to see if one already
>>>> exists by using a query. After doing this a bunch of times, I figured
>>>> there must be an annotation for this, such as @model unique="true"
>>>> required="true", or something like that, but I can't find anything about
>>>> it.
>>>>
>>>> Thanks,
>>>> Paul
>>>>
>>>>
>>>>
>> --
>>
>> 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
>>
>
>
>


--------------010107040002090903070009
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Paul,<br>
<br>
Note that we strongly advise against changing the hashCode and equals
implementation for EObjects.&nbsp; The framework expects that == and .equals
will be equivalent for any EObject implementation, so violating that
assumption is likely to cause problems.<br>
<br>
<br>
Paul Gardiner wrote:
<blockquote cite="mid:f494h2$tma$1@build.eclipse.org" type="cite">
<pre wrap="">Thanks for the responses. I think it's working ok now. I misunderstood how
it worked. Now I have the collection (an EList) that holds "MyType"
annotated with @model type="..." unique="true", and I modified the equals
method of MyType to behave the way I want, and now everything is working
great.

"Martin Taal" <a class="moz-txt-link-rfc2396E" href="mailto:mtaal@elver.org">&lt;mtaal@elver.org&gt;</a> wrote in message
<a class="moz-txt-link-freetext" href="news:f478no$en4$1@build.eclipse.org">news:f478no$en4$1@build.eclipse.org</a>...
</pre>
<blockquote type="cite">
<pre wrap="">Hi Paul,
Yes, as Ed says, do you mean a primary key? Or just a general uniqueness,
required constraint?

Here is an example on how to set required:
@Basic(optional=false)

Here is an example for setting uniqueconstraints using annotations in a
xsd:

&lt;xsd:complexType name="Item"&gt;
&lt;xsd:annotation&gt;
&lt;xsd:appinfo source="teneo.jpa"&gt;
@Table(name="MYITEMTABLE"
uniqueConstraints={@UniqueConstraint(columnNames={"MYSTR", "MYINT","MYPROJECT"})})&lt;/xsd:appinfo&gt;
&lt;/xsd:annotation&gt;
&lt;xsd:sequence&gt;
&lt;xsd:element name="name" type="xsd:string"&gt;
&lt;xsd:annotation&gt;
&lt;xsd:appinfo source="teneo.jpa"&gt;@Column(name="MYSTR")&lt;/xsd:appinfo&gt;
&lt;/xsd:annotation&gt;
&lt;/xsd:element&gt;
&lt;xsd:element name="project" type="xsd:IDREF"
ecore:reference="this:Project" minOccurs="0"&gt;
&lt;xsd:annotation&gt;
&lt;xsd:appinfo
source="teneo.jpa"&gt;@JoinColumn(name="MYPROJECT")&lt;/xsd:appinfo&gt;
&lt;/xsd:annotation&gt;
&lt;/xsd:element&gt;
&lt;xsd:element name="age" type="xsd:int"&gt;
&lt;xsd:annotation&gt;
&lt;xsd:appinfo source="teneo.jpa"&gt;@Column(name="MYINT")&lt;/xsd:appinfo&gt;
&lt;/xsd:annotation&gt;
&lt;/xsd:element&gt;
&lt;/xsd:sequence&gt;
&lt;/xsd:complexType&gt;

gr. Martin

Ed Merks wrote:
</pre>
<blockquote type="cite">
<pre wrap="">Paul,

Maybe you want @model id="true" to define an EAttribute with isID true,
which will require that the given attribute's value is unique within the
containing resource.


Paul Gardiner wrote:
</pre>
<blockquote type="cite">
<pre wrap="">Are there annotations for uniqueness and required fields? I am using
java annotations, so I have interfaces like this:

/**
* @model
*/
public interface MyType extends EObject{
/**
* @model
*/
getId();
}

Then whenever I create a new "MyType", I check to see if one already
exists by using a query. After doing this a bunch of times, I figured
there must be an annotation for this, such as @model unique="true"
required="true", or something like that, but I can't find anything about
it.

Thanks,
Paul


</pre>
</blockquote>
</blockquote>
<pre wrap="">
--

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: <a class="moz-txt-link-abbreviated" href="mailto:mtaal@springsite.com">mtaal@springsite.com</a> - <a class="moz-txt-link-abbreviated" href="mailto:mtaal@elver.org">mtaal@elver.org</a>
Web: <a class="moz-txt-link-abbreviated" href="http://www.springsite.com">www.springsite.com</a> - <a class="moz-txt-link-abbreviated" href="http://www.elver.org">www.elver.org</a>
</pre>
</blockquote>
<pre wrap=""><!---->

</pre>
</blockquote>
<br>
</body>
</html>

--------------010107040002090903070009--
Re: [teneo] unique/required java annotations [message #606876 is a reply to message #85624] Wed, 06 June 2007 16:56 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 31703
Registered: July 2009
Senior Member
Paul,

Maybe you want @model id="true" to define an EAttribute with isID true,
which will require that the given attribute's value is unique within the
containing resource.


Paul Gardiner wrote:
> Are there annotations for uniqueness and required fields? I am using java
> annotations, so I have interfaces like this:
>
> /**
> * @model
> */
> public interface MyType extends EObject{
> /**
> * @model
> */
> getId();
> }
>
> Then whenever I create a new "MyType", I check to see if one already exists
> by using a query. After doing this a bunch of times, I figured there must
> be an annotation for this, such as @model unique="true" required="true", or
> something like that, but I can't find anything about it.
>
> Thanks,
> Paul
>
>
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: [teneo] unique/required java annotations [message #606880 is a reply to message #85651] Wed, 06 June 2007 21:25 Go to previous message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Paul,
Yes, as Ed says, do you mean a primary key? Or just a general uniqueness, required constraint?

Here is an example on how to set required:
@Basic(optional=false)

Here is an example for setting uniqueconstraints using annotations in a xsd:

<xsd:complexType name="Item">
<xsd:annotation>
<xsd:appinfo source="teneo.jpa">
@Table(name="MYITEMTABLE"
uniqueConstraints={@UniqueConstraint(columnNames={"MYSTR", "MYINT","MYPROJECT"})})</xsd:appinfo>
</xsd:annotation>
<xsd:sequence>
<xsd:element name="name" type="xsd:string">
<xsd:annotation>
<xsd:appinfo source="teneo.jpa">@Column(name="MYSTR")</xsd:appinfo>
</xsd:annotation>
</xsd:element>
<xsd:element name="project" type="xsd:IDREF" ecore:reference="this:Project" minOccurs="0">
<xsd:annotation>
<xsd:appinfo source="teneo.jpa">@JoinColumn(name="MYPROJECT")</xsd:appinfo >
</xsd:annotation>
</xsd:element>
<xsd:element name="age" type="xsd:int">
<xsd:annotation>
<xsd:appinfo source="teneo.jpa">@Column(name="MYINT")</xsd:appinfo>
</xsd:annotation>
</xsd:element>
</xsd:sequence>
</xsd:complexType>

gr. Martin

Ed Merks wrote:
> Paul,
>
> Maybe you want @model id="true" to define an EAttribute with isID true,
> which will require that the given attribute's value is unique within the
> containing resource.
>
>
> Paul Gardiner wrote:
>> Are there annotations for uniqueness and required fields? I am using
>> java annotations, so I have interfaces like this:
>>
>> /**
>> * @model
>> */
>> public interface MyType extends EObject{
>> /**
>> * @model
>> */
>> getId();
>> }
>>
>> Then whenever I create a new "MyType", I check to see if one already
>> exists by using a query. After doing this a bunch of times, I figured
>> there must be an annotation for this, such as @model unique="true"
>> required="true", or something like that, but I can't find anything
>> about it.
>>
>> Thanks,
>> Paul
>>
>>


--

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] unique/required java annotations [message #606886 is a reply to message #85692] Thu, 07 June 2007 14:25 Go to previous message
Paul Gardiner is currently offline Paul GardinerFriend
Messages: 94
Registered: July 2009
Member
Thanks for the responses. I think it's working ok now. I misunderstood how
it worked. Now I have the collection (an EList) that holds "MyType"
annotated with @model type="..." unique="true", and I modified the equals
method of MyType to behave the way I want, and now everything is working
great.

"Martin Taal" <mtaal@elver.org> wrote in message
news:f478no$en4$1@build.eclipse.org...
> Hi Paul,
> Yes, as Ed says, do you mean a primary key? Or just a general uniqueness,
> required constraint?
>
> Here is an example on how to set required:
> @Basic(optional=false)
>
> Here is an example for setting uniqueconstraints using annotations in a
> xsd:
>
> <xsd:complexType name="Item">
> <xsd:annotation>
> <xsd:appinfo source="teneo.jpa">
> @Table(name="MYITEMTABLE"
> uniqueConstraints={@UniqueConstraint(columnNames={"MYSTR", "MYINT","MYPROJECT"})})</xsd:appinfo>
> </xsd:annotation>
> <xsd:sequence>
> <xsd:element name="name" type="xsd:string">
> <xsd:annotation>
> <xsd:appinfo source="teneo.jpa">@Column(name="MYSTR")</xsd:appinfo>
> </xsd:annotation>
> </xsd:element>
> <xsd:element name="project" type="xsd:IDREF"
> ecore:reference="this:Project" minOccurs="0">
> <xsd:annotation>
> <xsd:appinfo
> source="teneo.jpa">@JoinColumn(name="MYPROJECT")</xsd:appinfo >
> </xsd:annotation>
> </xsd:element>
> <xsd:element name="age" type="xsd:int">
> <xsd:annotation>
> <xsd:appinfo source="teneo.jpa">@Column(name="MYINT")</xsd:appinfo>
> </xsd:annotation>
> </xsd:element>
> </xsd:sequence>
> </xsd:complexType>
>
> gr. Martin
>
> Ed Merks wrote:
>> Paul,
>>
>> Maybe you want @model id="true" to define an EAttribute with isID true,
>> which will require that the given attribute's value is unique within the
>> containing resource.
>>
>>
>> Paul Gardiner wrote:
>>> Are there annotations for uniqueness and required fields? I am using
>>> java annotations, so I have interfaces like this:
>>>
>>> /**
>>> * @model
>>> */
>>> public interface MyType extends EObject{
>>> /**
>>> * @model
>>> */
>>> getId();
>>> }
>>>
>>> Then whenever I create a new "MyType", I check to see if one already
>>> exists by using a query. After doing this a bunch of times, I figured
>>> there must be an annotation for this, such as @model unique="true"
>>> required="true", or something like that, but I can't find anything about
>>> it.
>>>
>>> Thanks,
>>> Paul
>>>
>>>
>
>
> --
>
> 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] unique/required java annotations [message #606888 is a reply to message #85783] Thu, 07 June 2007 14:42 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 31703
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------010107040002090903070009
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

Paul,

Note that we strongly advise against changing the hashCode and equals
implementation for EObjects. The framework expects that == and .equals
will be equivalent for any EObject implementation, so violating that
assumption is likely to cause problems.


Paul Gardiner wrote:
> Thanks for the responses. I think it's working ok now. I misunderstood how
> it worked. Now I have the collection (an EList) that holds "MyType"
> annotated with @model type="..." unique="true", and I modified the equals
> method of MyType to behave the way I want, and now everything is working
> great.
>
> "Martin Taal" <mtaal@elver.org> wrote in message
> news:f478no$en4$1@build.eclipse.org...
>
>> Hi Paul,
>> Yes, as Ed says, do you mean a primary key? Or just a general uniqueness,
>> required constraint?
>>
>> Here is an example on how to set required:
>> @Basic(optional=false)
>>
>> Here is an example for setting uniqueconstraints using annotations in a
>> xsd:
>>
>> <xsd:complexType name="Item">
>> <xsd:annotation>
>> <xsd:appinfo source="teneo.jpa">
>> @Table(name="MYITEMTABLE"
>> uniqueConstraints={@UniqueConstraint(columnNames={"MYSTR", "MYINT","MYPROJECT"})})</xsd:appinfo>
>> </xsd:annotation>
>> <xsd:sequence>
>> <xsd:element name="name" type="xsd:string">
>> <xsd:annotation>
>> <xsd:appinfo source="teneo.jpa">@Column(name="MYSTR")</xsd:appinfo>
>> </xsd:annotation>
>> </xsd:element>
>> <xsd:element name="project" type="xsd:IDREF"
>> ecore:reference="this:Project" minOccurs="0">
>> <xsd:annotation>
>> <xsd:appinfo
>> source="teneo.jpa">@JoinColumn(name="MYPROJECT")</xsd:appinfo >
>> </xsd:annotation>
>> </xsd:element>
>> <xsd:element name="age" type="xsd:int">
>> <xsd:annotation>
>> <xsd:appinfo source="teneo.jpa">@Column(name="MYINT")</xsd:appinfo>
>> </xsd:annotation>
>> </xsd:element>
>> </xsd:sequence>
>> </xsd:complexType>
>>
>> gr. Martin
>>
>> Ed Merks wrote:
>>
>>> Paul,
>>>
>>> Maybe you want @model id="true" to define an EAttribute with isID true,
>>> which will require that the given attribute's value is unique within the
>>> containing resource.
>>>
>>>
>>> Paul Gardiner wrote:
>>>
>>>> Are there annotations for uniqueness and required fields? I am using
>>>> java annotations, so I have interfaces like this:
>>>>
>>>> /**
>>>> * @model
>>>> */
>>>> public interface MyType extends EObject{
>>>> /**
>>>> * @model
>>>> */
>>>> getId();
>>>> }
>>>>
>>>> Then whenever I create a new "MyType", I check to see if one already
>>>> exists by using a query. After doing this a bunch of times, I figured
>>>> there must be an annotation for this, such as @model unique="true"
>>>> required="true", or something like that, but I can't find anything about
>>>> it.
>>>>
>>>> Thanks,
>>>> Paul
>>>>
>>>>
>>>>
>> --
>>
>> 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
>>
>
>
>


--------------010107040002090903070009
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Paul,<br>
<br>
Note that we strongly advise against changing the hashCode and equals
implementation for EObjects.&nbsp; The framework expects that == and .equals
will be equivalent for any EObject implementation, so violating that
assumption is likely to cause problems.<br>
<br>
<br>
Paul Gardiner wrote:
<blockquote cite="mid:f494h2$tma$1@build.eclipse.org" type="cite">
<pre wrap="">Thanks for the responses. I think it's working ok now. I misunderstood how
it worked. Now I have the collection (an EList) that holds "MyType"
annotated with @model type="..." unique="true", and I modified the equals
method of MyType to behave the way I want, and now everything is working
great.

"Martin Taal" <a class="moz-txt-link-rfc2396E" href="mailto:mtaal@elver.org">&lt;mtaal@elver.org&gt;</a> wrote in message
<a class="moz-txt-link-freetext" href="news:f478no$en4$1@build.eclipse.org">news:f478no$en4$1@build.eclipse.org</a>...
</pre>
<blockquote type="cite">
<pre wrap="">Hi Paul,
Yes, as Ed says, do you mean a primary key? Or just a general uniqueness,
required constraint?

Here is an example on how to set required:
@Basic(optional=false)

Here is an example for setting uniqueconstraints using annotations in a
xsd:

&lt;xsd:complexType name="Item"&gt;
&lt;xsd:annotation&gt;
&lt;xsd:appinfo source="teneo.jpa"&gt;
@Table(name="MYITEMTABLE"
uniqueConstraints={@UniqueConstraint(columnNames={"MYSTR", "MYINT","MYPROJECT"})})&lt;/xsd:appinfo&gt;
&lt;/xsd:annotation&gt;
&lt;xsd:sequence&gt;
&lt;xsd:element name="name" type="xsd:string"&gt;
&lt;xsd:annotation&gt;
&lt;xsd:appinfo source="teneo.jpa"&gt;@Column(name="MYSTR")&lt;/xsd:appinfo&gt;
&lt;/xsd:annotation&gt;
&lt;/xsd:element&gt;
&lt;xsd:element name="project" type="xsd:IDREF"
ecore:reference="this:Project" minOccurs="0"&gt;
&lt;xsd:annotation&gt;
&lt;xsd:appinfo
source="teneo.jpa"&gt;@JoinColumn(name="MYPROJECT")&lt;/xsd:appinfo&gt;
&lt;/xsd:annotation&gt;
&lt;/xsd:element&gt;
&lt;xsd:element name="age" type="xsd:int"&gt;
&lt;xsd:annotation&gt;
&lt;xsd:appinfo source="teneo.jpa"&gt;@Column(name="MYINT")&lt;/xsd:appinfo&gt;
&lt;/xsd:annotation&gt;
&lt;/xsd:element&gt;
&lt;/xsd:sequence&gt;
&lt;/xsd:complexType&gt;

gr. Martin

Ed Merks wrote:
</pre>
<blockquote type="cite">
<pre wrap="">Paul,

Maybe you want @model id="true" to define an EAttribute with isID true,
which will require that the given attribute's value is unique within the
containing resource.


Paul Gardiner wrote:
</pre>
<blockquote type="cite">
<pre wrap="">Are there annotations for uniqueness and required fields? I am using
java annotations, so I have interfaces like this:

/**
* @model
*/
public interface MyType extends EObject{
/**
* @model
*/
getId();
}

Then whenever I create a new "MyType", I check to see if one already
exists by using a query. After doing this a bunch of times, I figured
there must be an annotation for this, such as @model unique="true"
required="true", or something like that, but I can't find anything about
it.

Thanks,
Paul


</pre>
</blockquote>
</blockquote>
<pre wrap="">
--

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: <a class="moz-txt-link-abbreviated" href="mailto:mtaal@springsite.com">mtaal@springsite.com</a> - <a class="moz-txt-link-abbreviated" href="mailto:mtaal@elver.org">mtaal@elver.org</a>
Web: <a class="moz-txt-link-abbreviated" href="http://www.springsite.com">www.springsite.com</a> - <a class="moz-txt-link-abbreviated" href="http://www.elver.org">www.elver.org</a>
</pre>
</blockquote>
<pre wrap=""><!---->

</pre>
</blockquote>
<br>
</body>
</html>

--------------010107040002090903070009--


Ed Merks
Professional Support: https://www.macromodeling.com/
Previous Topic:[Teneo] How to specify attribute 'generated' for property in hibernate mapping via annotation?
Next Topic:OutOfMemoryError in HbDataStore.initialize()
Goto Forum:
  


Current Time: Thu Jan 21 16:15:38 GMT 2021

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

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

Back to the top