Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF "Technology" (Ecore Tools, EMFatic, etc)  » [teneo] primary key in java code
[teneo] primary key in java code [message #86229] Wed, 13 June 2007 16:44 Go to next message
Paul Gardiner is currently offline Paul GardinerFriend
Messages: 94
Registered: July 2009
Member
This has likely been answered, but I can't seem to find it.

I am unsure how to set a primary key using annotations in the java source --
not in an external xml file. I tried something like this

/**
* @model
*/
public interface A {
/**
* @model changeable="false"
*/
@Id
String getUniqueName();
}

Then I create a genmodel/ecore model from the code, generate the model, and
the uniquename property doesn't end up as the primary key. It's set to
changeable="false" because I am creating the value from other data, and that
gets stored find in the database.

Thanks,
Paul
Re: [teneo] primary key in java code [message #86244 is a reply to message #86229] Wed, 13 June 2007 17:58 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Paul,
Just for the id I would try the annotation id="true" in the java source. For other annotations: I
don't think that they will work, at least I don't think that eannotations can be specified in java
source. But maybe Ed can answer this question.

gr. Martin

Paul Gardiner wrote:
> This has likely been answered, but I can't seem to find it.
>
> I am unsure how to set a primary key using annotations in the java source --
> not in an external xml file. I tried something like this
>
> /**
> * @model
> */
> public interface A {
> /**
> * @model changeable="false"
> */
> @Id
> String getUniqueName();
> }
>
> Then I create a genmodel/ecore model from the code, generate the model, and
> the uniquename property doesn't end up as the primary key. It's set to
> changeable="false" because I am creating the value from other data, and that
> gets stored find in the database.
>
> 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] primary key in java code [message #86274 is a reply to message #86244] Wed, 13 June 2007 18:36 Go to previous messageGo to next message
Paul Gardiner is currently offline Paul GardinerFriend
Messages: 94
Registered: July 2009
Member
do you mean by using @model id="true", or something else?

"Martin Taal" <mtaal@elver.org> wrote in message
news:f4pb7n$eaj$1@build.eclipse.org...
> Hi Paul,
> Just for the id I would try the annotation id="true" in the java source.
> For other annotations: I don't think that they will work, at least I don't
> think that eannotations can be specified in java source. But maybe Ed can
> answer this question.
>
> gr. Martin
>
> Paul Gardiner wrote:
>> This has likely been answered, but I can't seem to find it.
>>
>> I am unsure how to set a primary key using annotations in the java
>> source -- not in an external xml file. I tried something like this
>>
>> /**
>> * @model
>> */
>> public interface A {
>> /**
>> * @model changeable="false"
>> */
>> @Id
>> String getUniqueName();
>> }
>>
>> Then I create a genmodel/ecore model from the code, generate the model,
>> and the uniquename property doesn't end up as the primary key. It's set
>> to changeable="false" because I am creating the value from other data,
>> and that gets stored find in the database.
>>
>> 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] primary key in java code [message #86289 is a reply to message #86274] Wed, 13 June 2007 18:44 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Yes, that's what I mean.

gr. Martin

Paul Gardiner wrote:
> do you mean by using @model id="true", or something else?
>
> "Martin Taal" <mtaal@elver.org> wrote in message
> news:f4pb7n$eaj$1@build.eclipse.org...
>> Hi Paul,
>> Just for the id I would try the annotation id="true" in the java source.
>> For other annotations: I don't think that they will work, at least I don't
>> think that eannotations can be specified in java source. But maybe Ed can
>> answer this question.
>>
>> gr. Martin
>>
>> Paul Gardiner wrote:
>>> This has likely been answered, but I can't seem to find it.
>>>
>>> I am unsure how to set a primary key using annotations in the java
>>> source -- not in an external xml file. I tried something like this
>>>
>>> /**
>>> * @model
>>> */
>>> public interface A {
>>> /**
>>> * @model changeable="false"
>>> */
>>> @Id
>>> String getUniqueName();
>>> }
>>>
>>> Then I create a genmodel/ecore model from the code, generate the model,
>>> and the uniquename property doesn't end up as the primary key. It's set
>>> to changeable="false" because I am creating the value from other data,
>>> and that gets stored find in the database.
>>>
>>> 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
>
>


--

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] primary key in java code [message #86320 is a reply to message #86244] Wed, 13 June 2007 19:02 Go to previous messageGo to next message
Paul Gardiner is currently offline Paul GardinerFriend
Messages: 94
Registered: July 2009
Member
It's working. I set @model id="true", and it becomes the primary key. It
did have a problem with my method name, though. I had declared the getter
as "getFQName()", and it complained that the impl class didn't have a get
method for property fQName. I changed it to "getFqname()", and it works
fine.

Thanks,
Paul

"Martin Taal" <mtaal@elver.org> wrote in message
news:f4pb7n$eaj$1@build.eclipse.org...
> Hi Paul,
> Just for the id I would try the annotation id="true" in the java source.
> For other annotations: I don't think that they will work, at least I don't
> think that eannotations can be specified in java source. But maybe Ed can
> answer this question.
>
> gr. Martin
>
> Paul Gardiner wrote:
>> This has likely been answered, but I can't seem to find it.
>>
>> I am unsure how to set a primary key using annotations in the java
>> source -- not in an external xml file. I tried something like this
>>
>> /**
>> * @model
>> */
>> public interface A {
>> /**
>> * @model changeable="false"
>> */
>> @Id
>> String getUniqueName();
>> }
>>
>> Then I create a genmodel/ecore model from the code, generate the model,
>> and the uniquename property doesn't end up as the primary key. It's set
>> to changeable="false" because I am creating the value from other data,
>> and that gets stored find in the database.
>>
>> 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] primary key in java code [message #86335 is a reply to message #86244] Wed, 13 June 2007 19:37 Go to previous message
Eclipse UserFriend
Originally posted by: merks.ca.ibm.com

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

Martin,

Yes they can. :-) Like this:

* @model annotation="http://www.example.com foo='bar'"

So the syntax is {<source-URI> {<key>='<value>}*}* and you can use \ to
escape characters with special meaning.


Martin Taal wrote:
> Hi Paul,
> Just for the id I would try the annotation id="true" in the java
> source. For other annotations: I don't think that they will work, at
> least I don't think that eannotations can be specified in java source.
> But maybe Ed can answer this question.
>
> gr. Martin
>
> Paul Gardiner wrote:
>> This has likely been answered, but I can't seem to find it.
>>
>> I am unsure how to set a primary key using annotations in the java
>> source -- not in an external xml file. I tried something like this
>>
>> /**
>> * @model
>> */
>> public interface A {
>> /**
>> * @model changeable="false"
>> */
>> @Id
>> String getUniqueName();
>> }
>>
>> Then I create a genmodel/ecore model from the code, generate the
>> model, and the uniquename property doesn't end up as the primary
>> key. It's set to changeable="false" because I am creating the value
>> from other data, and that gets stored find in the database.
>>
>> Thanks,
>> Paul
>>
>
>


--------------090604030608040903010006
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">
Martin,<br>
<br>
Yes they can.&nbsp; :-)&nbsp; Like this:<br>
<blockquote>* @model annotation=<a class="moz-txt-link-rfc2396E" href="http://www.example.comfoo='bar'">"http://www.example.com foo='bar'"</a><br>
</blockquote>
So the syntax is {&lt;source-URI&gt; {&lt;key&gt;='&lt;value&gt;}*}*&nbsp;
and you can use \ to escape characters with special meaning.<br>
<br>
<br>
Martin Taal wrote:
<blockquote cite="mid:f4pb7n$eaj$1@build.eclipse.org" type="cite">Hi
Paul,
<br>
Just for the id I would try the annotation id="true" in the java
source. For other annotations: I don't think that they will work, at
least I don't think that eannotations can be specified in java source.
But maybe Ed can answer this question.
<br>
<br>
gr. Martin
<br>
<br>
Paul Gardiner wrote:
<br>
<blockquote type="cite">This has likely been answered, but I can't
seem to find it.
<br>
<br>
I am unsure how to set a primary key using annotations in the java
source --&nbsp; not in an external xml file.&nbsp; I tried something like this
<br>
<br>
/**
<br>
* @model
<br>
*/
<br>
public interface A {
<br>
&nbsp; /**
<br>
&nbsp; * @model changeable="false"
<br>
&nbsp; */
<br>
&nbsp; @Id
<br>
&nbsp; String getUniqueName();
<br>
}
<br>
<br>
Then I create a genmodel/ecore model from the code, generate the model,
and the uniquename property doesn't end up as the primary key.&nbsp; It's
set to changeable="false" because I am creating the value from other
data, and that gets stored find in the database.
<br>
<br>
Thanks,
<br>
Paul <br>
<br>
</blockquote>
<br>
<br>
</blockquote>
<br>
</body>
</html>

--------------090604030608040903010006--
Re: [teneo] primary key in java code [message #606946 is a reply to message #86229] Wed, 13 June 2007 17:58 Go to previous message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Paul,
Just for the id I would try the annotation id="true" in the java source. For other annotations: I
don't think that they will work, at least I don't think that eannotations can be specified in java
source. But maybe Ed can answer this question.

gr. Martin

Paul Gardiner wrote:
> This has likely been answered, but I can't seem to find it.
>
> I am unsure how to set a primary key using annotations in the java source --
> not in an external xml file. I tried something like this
>
> /**
> * @model
> */
> public interface A {
> /**
> * @model changeable="false"
> */
> @Id
> String getUniqueName();
> }
>
> Then I create a genmodel/ecore model from the code, generate the model, and
> the uniquename property doesn't end up as the primary key. It's set to
> changeable="false" because I am creating the value from other data, and that
> gets stored find in the database.
>
> 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] primary key in java code [message #606952 is a reply to message #86244] Wed, 13 June 2007 18:36 Go to previous message
Paul Gardiner is currently offline Paul GardinerFriend
Messages: 94
Registered: July 2009
Member
do you mean by using @model id="true", or something else?

"Martin Taal" <mtaal@elver.org> wrote in message
news:f4pb7n$eaj$1@build.eclipse.org...
> Hi Paul,
> Just for the id I would try the annotation id="true" in the java source.
> For other annotations: I don't think that they will work, at least I don't
> think that eannotations can be specified in java source. But maybe Ed can
> answer this question.
>
> gr. Martin
>
> Paul Gardiner wrote:
>> This has likely been answered, but I can't seem to find it.
>>
>> I am unsure how to set a primary key using annotations in the java
>> source -- not in an external xml file. I tried something like this
>>
>> /**
>> * @model
>> */
>> public interface A {
>> /**
>> * @model changeable="false"
>> */
>> @Id
>> String getUniqueName();
>> }
>>
>> Then I create a genmodel/ecore model from the code, generate the model,
>> and the uniquename property doesn't end up as the primary key. It's set
>> to changeable="false" because I am creating the value from other data,
>> and that gets stored find in the database.
>>
>> 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] primary key in java code [message #606954 is a reply to message #86274] Wed, 13 June 2007 18:44 Go to previous message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Yes, that's what I mean.

gr. Martin

Paul Gardiner wrote:
> do you mean by using @model id="true", or something else?
>
> "Martin Taal" <mtaal@elver.org> wrote in message
> news:f4pb7n$eaj$1@build.eclipse.org...
>> Hi Paul,
>> Just for the id I would try the annotation id="true" in the java source.
>> For other annotations: I don't think that they will work, at least I don't
>> think that eannotations can be specified in java source. But maybe Ed can
>> answer this question.
>>
>> gr. Martin
>>
>> Paul Gardiner wrote:
>>> This has likely been answered, but I can't seem to find it.
>>>
>>> I am unsure how to set a primary key using annotations in the java
>>> source -- not in an external xml file. I tried something like this
>>>
>>> /**
>>> * @model
>>> */
>>> public interface A {
>>> /**
>>> * @model changeable="false"
>>> */
>>> @Id
>>> String getUniqueName();
>>> }
>>>
>>> Then I create a genmodel/ecore model from the code, generate the model,
>>> and the uniquename property doesn't end up as the primary key. It's set
>>> to changeable="false" because I am creating the value from other data,
>>> and that gets stored find in the database.
>>>
>>> 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
>
>


--

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] primary key in java code [message #606958 is a reply to message #86244] Wed, 13 June 2007 19:02 Go to previous message
Paul Gardiner is currently offline Paul GardinerFriend
Messages: 94
Registered: July 2009
Member
It's working. I set @model id="true", and it becomes the primary key. It
did have a problem with my method name, though. I had declared the getter
as "getFQName()", and it complained that the impl class didn't have a get
method for property fQName. I changed it to "getFqname()", and it works
fine.

Thanks,
Paul

"Martin Taal" <mtaal@elver.org> wrote in message
news:f4pb7n$eaj$1@build.eclipse.org...
> Hi Paul,
> Just for the id I would try the annotation id="true" in the java source.
> For other annotations: I don't think that they will work, at least I don't
> think that eannotations can be specified in java source. But maybe Ed can
> answer this question.
>
> gr. Martin
>
> Paul Gardiner wrote:
>> This has likely been answered, but I can't seem to find it.
>>
>> I am unsure how to set a primary key using annotations in the java
>> source -- not in an external xml file. I tried something like this
>>
>> /**
>> * @model
>> */
>> public interface A {
>> /**
>> * @model changeable="false"
>> */
>> @Id
>> String getUniqueName();
>> }
>>
>> Then I create a genmodel/ecore model from the code, generate the model,
>> and the uniquename property doesn't end up as the primary key. It's set
>> to changeable="false" because I am creating the value from other data,
>> and that gets stored find in the database.
>>
>> 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] primary key in java code [message #606963 is a reply to message #86244] Wed, 13 June 2007 19:37 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33113
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------090604030608040903010006
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

Martin,

Yes they can. :-) Like this:

* @model annotation="http://www.example.com foo='bar'"

So the syntax is {<source-URI> {<key>='<value>}*}* and you can use \ to
escape characters with special meaning.


Martin Taal wrote:
> Hi Paul,
> Just for the id I would try the annotation id="true" in the java
> source. For other annotations: I don't think that they will work, at
> least I don't think that eannotations can be specified in java source.
> But maybe Ed can answer this question.
>
> gr. Martin
>
> Paul Gardiner wrote:
>> This has likely been answered, but I can't seem to find it.
>>
>> I am unsure how to set a primary key using annotations in the java
>> source -- not in an external xml file. I tried something like this
>>
>> /**
>> * @model
>> */
>> public interface A {
>> /**
>> * @model changeable="false"
>> */
>> @Id
>> String getUniqueName();
>> }
>>
>> Then I create a genmodel/ecore model from the code, generate the
>> model, and the uniquename property doesn't end up as the primary
>> key. It's set to changeable="false" because I am creating the value
>> from other data, and that gets stored find in the database.
>>
>> Thanks,
>> Paul
>>
>
>


--------------090604030608040903010006
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">
Martin,<br>
<br>
Yes they can.&nbsp; :-)&nbsp; Like this:<br>
<blockquote>* @model annotation=<a class="moz-txt-link-rfc2396E" href="http://www.example.comfoo='bar'">"http://www.example.com foo='bar'"</a><br>
</blockquote>
So the syntax is {&lt;source-URI&gt; {&lt;key&gt;='&lt;value&gt;}*}*&nbsp;
and you can use \ to escape characters with special meaning.<br>
<br>
<br>
Martin Taal wrote:
<blockquote cite="mid:f4pb7n$eaj$1@build.eclipse.org" type="cite">Hi
Paul,
<br>
Just for the id I would try the annotation id="true" in the java
source. For other annotations: I don't think that they will work, at
least I don't think that eannotations can be specified in java source.
But maybe Ed can answer this question.
<br>
<br>
gr. Martin
<br>
<br>
Paul Gardiner wrote:
<br>
<blockquote type="cite">This has likely been answered, but I can't
seem to find it.
<br>
<br>
I am unsure how to set a primary key using annotations in the java
source --&nbsp; not in an external xml file.&nbsp; I tried something like this
<br>
<br>
/**
<br>
* @model
<br>
*/
<br>
public interface A {
<br>
&nbsp; /**
<br>
&nbsp; * @model changeable="false"
<br>
&nbsp; */
<br>
&nbsp; @Id
<br>
&nbsp; String getUniqueName();
<br>
}
<br>
<br>
Then I create a genmodel/ecore model from the code, generate the model,
and the uniquename property doesn't end up as the primary key.&nbsp; It's
set to changeable="false" because I am creating the value from other
data, and that gets stored find in the database.
<br>
<br>
Thanks,
<br>
Paul <br>
<br>
</blockquote>
<br>
<br>
</blockquote>
<br>
</body>
</html>

--------------090604030608040903010006--


Ed Merks
Professional Support: https://www.macromodeling.com/
Previous Topic:[teneo] primary key in java code
Next Topic:Issue with JPA Annotations
Goto Forum:
  


Current Time: Fri Mar 29 01:27:47 GMT 2024

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

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

Back to the top