Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF "Technology" (Ecore Tools, EMFatic, etc)  » [Teneo]Custom primary key column is not being defined correctly.
[Teneo]Custom primary key column is not being defined correctly. [message #78746] Fri, 06 April 2007 18:41 Go to next message
Michael Kanaley is currently offline Michael KanaleyFriend
Messages: 89
Registered: July 2009
Member
Hi Martin,
According to the page http://www.elver.org/hibernate/ejb3_features.html:
When an eattribute has its ID property set to true and there is no @Id
annotated eattribute in the eclass then the ID eattribute is used. This
default behavior can be changed using the option: ID_FEATURE_AS_PRIMARY_KEY.

When I follow the instructions above and set the ID property (and I don't
set the option), I get a mapping of the form:
<id name="id" type="long">
<column not-null="true" unique="false" name="`id`"/>
</id>

But this mapping does not generate the primary key (and does not set the
unique constraint).

Back in Teneo v200610261350, it generated the mapping below which works
fine.
I am not sure in which specific Teneo version introduced the problem.

<id name="id" type="long" column="`ID`">
<generator class="native"/>
</id>

Let me know if this is a bug or if there is some other setting that I am
missing.

Attached is a plugin (like the others) that duplicates this problem - it
throws a NonUniqueObjectException.
Thanks,
-mike


Re: [Teneo]Custom primary key column is not being defined correctly. [message #78764 is a reply to message #78746] Fri, 06 April 2007 18:57 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: christian.donhofer.net

On Fri, 06 Apr 2007 13:41:24 -0500 Michael Kanaley wrote:

> Hi Martin,
> According to the page http://www.elver.org/hibernate/ejb3_features.html:
> When an eattribute has its ID property set to true and there is no @Id
> annotated eattribute in the eclass then the ID eattribute is used. This
> default behavior can be changed using the option: ID_FEATURE_AS_PRIMARY_KEY.
>

hi michael,

please output your persistenceoptions and post them here - maybe the
feature isn't set to true by default anymore?

chris
Re: [Teneo]Custom primary key column is not being defined correctly. [message #78778 is a reply to message #78764] Fri, 06 April 2007 20:14 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Mike,
Good that you provided an easy to reproduce test case. The issue is not with the option.
First I would say that the column tag should have unique="true", so this seems a mistake in the
mapping but this mistake does not seem to give a problem.

I tested this with both hsqldb and mysql. With mysql a primary key is created (I tested two sql
insert statements with the same id and the second one failed). The value of the unique="true|false"
attribute (the mapping mistake I mention above) did not make a difference, for both true and false I
got a pk.
Testing using hsqldb showed that I could not insert an object with the same id twice (got:
java.sql.BatchUpdateException: failed batch). So I assume that also hsqldb creates a pk (at least
with me).

When I run the testcase as you send me I get the following nonuniqueobjectexception:
Caused by: org.hibernate.NonUniqueObjectException: a different object with the same identifier value
was already associated with the session: [StringCollection#0]

Afaiu this is not related to a database constraint violation, it happens earlier (before the
database inserts take place) as hibernate already notices that two objects with the same id are
associated with the session. This seems a correct exception as there are two objects with the same
id (0 in your case) associated with the session.

gr. Martin

Christian Donhofer wrote:
> On Fri, 06 Apr 2007 13:41:24 -0500 Michael Kanaley wrote:
>
>> Hi Martin,
>> According to the page http://www.elver.org/hibernate/ejb3_features.html:
>> When an eattribute has its ID property set to true and there is no @Id
>> annotated eattribute in the eclass then the ID eattribute is used. This
>> default behavior can be changed using the option: ID_FEATURE_AS_PRIMARY_KEY.
>>
>
> hi michael,
>
> please output your persistenceoptions and post them here - maybe the
> feature isn't set to true by default anymore?
>
> chris
>


--

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]Custom primary key column is not being defined correctly. [message #78886 is a reply to message #78778] Sun, 08 April 2007 10:28 Go to previous messageGo to next message
Michael Kanaley is currently offline Michael KanaleyFriend
Messages: 89
Registered: July 2009
Member
Hi Martin,
I agree that unique="false" is not a major problem, although I think the
default should be changed to unique="true" - should I file a bugzilla?

The real problem I am having is that in Teneo v200610261350, a primary key
generator was automatically being inserted into the id mapping like:
<generator class="native"/>
In the latest Teneo, this no longer happens but I would like it to.
Is there a way to make this happen?
Thanks,
-mike

"Martin Taal" <mtaal@elver.org> wrote in message
news:ev69nk$79o$1@build.eclipse.org...
> Hi Mike,
> Good that you provided an easy to reproduce test case. The issue is not
> with the option.
> First I would say that the column tag should have unique="true", so this
> seems a mistake in the mapping but this mistake does not seem to give a
> problem.
>
> I tested this with both hsqldb and mysql. With mysql a primary key is
> created (I tested two sql insert statements with the same id and the
> second one failed). The value of the unique="true|false" attribute (the
> mapping mistake I mention above) did not make a difference, for both true
> and false I got a pk.
> Testing using hsqldb showed that I could not insert an object with the
> same id twice (got: java.sql.BatchUpdateException: failed batch). So I
> assume that also hsqldb creates a pk (at least with me).
>
> When I run the testcase as you send me I get the following
> nonuniqueobjectexception:
> Caused by: org.hibernate.NonUniqueObjectException: a different object with
> the same identifier value was already associated with the session:
> [StringCollection#0]
>
> Afaiu this is not related to a database constraint violation, it happens
> earlier (before the database inserts take place) as hibernate already
> notices that two objects with the same id are associated with the session.
> This seems a correct exception as there are two objects with the same id
> (0 in your case) associated with the session.
>
> gr. Martin
>
> Christian Donhofer wrote:
>> On Fri, 06 Apr 2007 13:41:24 -0500 Michael Kanaley wrote:
>>
>>> Hi Martin,
>>> According to the page http://www.elver.org/hibernate/ejb3_features.html:
>>> When an eattribute has its ID property set to true and there is no @Id
>>> annotated eattribute in the eclass then the ID eattribute is used. This
>>> default behavior can be changed using the option:
>>> ID_FEATURE_AS_PRIMARY_KEY.
>>>
>>
>> hi michael,
>>
>> please output your persistenceoptions and post them here - maybe the
>> feature isn't set to true by default anymore?
>>
>> chris
>>
>
>
> --
>
> 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]Custom primary key column is not being defined correctly. [message #78898 is a reply to message #78886] Sun, 08 April 2007 20:31 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Mike,
I have already changed the behavior to unique=true (for the 0,8,0 build) and have added a bugzilla
for this.

No there is currently no way to let Teneo automatically create the generator tag for an id. One way
is to use an edatatype for the id attributes and set a generator annotation on the edatatype.
I also thought about automatic adding this behavior (option driven) to id attributes of type long.
If you are interested can you enter a bugzilla for this?

gr. Martin

Michael Kanaley wrote:
> Hi Martin,
> I agree that unique="false" is not a major problem, although I think the
> default should be changed to unique="true" - should I file a bugzilla?
>
> The real problem I am having is that in Teneo v200610261350, a primary key
> generator was automatically being inserted into the id mapping like:
> <generator class="native"/>
> In the latest Teneo, this no longer happens but I would like it to.
> Is there a way to make this happen?
> Thanks,
> -mike
>
> "Martin Taal" <mtaal@elver.org> wrote in message
> news:ev69nk$79o$1@build.eclipse.org...
>> Hi Mike,
>> Good that you provided an easy to reproduce test case. The issue is not
>> with the option.
>> First I would say that the column tag should have unique="true", so this
>> seems a mistake in the mapping but this mistake does not seem to give a
>> problem.
>>
>> I tested this with both hsqldb and mysql. With mysql a primary key is
>> created (I tested two sql insert statements with the same id and the
>> second one failed). The value of the unique="true|false" attribute (the
>> mapping mistake I mention above) did not make a difference, for both true
>> and false I got a pk.
>> Testing using hsqldb showed that I could not insert an object with the
>> same id twice (got: java.sql.BatchUpdateException: failed batch). So I
>> assume that also hsqldb creates a pk (at least with me).
>>
>> When I run the testcase as you send me I get the following
>> nonuniqueobjectexception:
>> Caused by: org.hibernate.NonUniqueObjectException: a different object with
>> the same identifier value was already associated with the session:
>> [StringCollection#0]
>>
>> Afaiu this is not related to a database constraint violation, it happens
>> earlier (before the database inserts take place) as hibernate already
>> notices that two objects with the same id are associated with the session.
>> This seems a correct exception as there are two objects with the same id
>> (0 in your case) associated with the session.
>>
>> gr. Martin
>>
>> Christian Donhofer wrote:
>>> On Fri, 06 Apr 2007 13:41:24 -0500 Michael Kanaley wrote:
>>>
>>>> Hi Martin,
>>>> According to the page http://www.elver.org/hibernate/ejb3_features.html:
>>>> When an eattribute has its ID property set to true and there is no @Id
>>>> annotated eattribute in the eclass then the ID eattribute is used. This
>>>> default behavior can be changed using the option:
>>>> ID_FEATURE_AS_PRIMARY_KEY.
>>>>
>>> hi michael,
>>>
>>> please output your persistenceoptions and post them here - maybe the
>>> feature isn't set to true by default anymore?
>>>
>>> chris
>>>
>>
>> --
>>
>> 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]Custom primary key column is not being defined correctly. [message #78936 is a reply to message #78898] Mon, 09 April 2007 17:43 Go to previous messageGo to next message
Michael Kanaley is currently offline Michael KanaleyFriend
Messages: 89
Registered: July 2009
Member
Filed 181631. I am also experimenting using EDataTypes to set the generator.
Thanks,
-mike

"Martin Taal" <mtaal@elver.org> wrote in message
news:evbjg1$ujj$1@build.eclipse.org...
> Hi Mike,
> I have already changed the behavior to unique=true (for the 0,8,0 build)
> and have added a bugzilla for this.
>
> No there is currently no way to let Teneo automatically create the
> generator tag for an id. One way is to use an edatatype for the id
> attributes and set a generator annotation on the edatatype.
> I also thought about automatic adding this behavior (option driven) to id
> attributes of type long. If you are interested can you enter a bugzilla
> for this?
>
> gr. Martin
>
> Michael Kanaley wrote:
>> Hi Martin,
>> I agree that unique="false" is not a major problem, although I think
>> the default should be changed to unique="true" - should I file a
>> bugzilla?
>>
>> The real problem I am having is that in Teneo v200610261350, a primary
>> key generator was automatically being inserted into the id mapping like:
>> <generator class="native"/>
>> In the latest Teneo, this no longer happens but I would like it to.
>> Is there a way to make this happen?
>> Thanks,
>> -mike
>>
>> "Martin Taal" <mtaal@elver.org> wrote in message
>> news:ev69nk$79o$1@build.eclipse.org...
>>> Hi Mike,
>>> Good that you provided an easy to reproduce test case. The issue is not
>>> with the option.
>>> First I would say that the column tag should have unique="true", so this
>>> seems a mistake in the mapping but this mistake does not seem to give a
>>> problem.
>>>
>>> I tested this with both hsqldb and mysql. With mysql a primary key is
>>> created (I tested two sql insert statements with the same id and the
>>> second one failed). The value of the unique="true|false" attribute (the
>>> mapping mistake I mention above) did not make a difference, for both
>>> true and false I got a pk.
>>> Testing using hsqldb showed that I could not insert an object with the
>>> same id twice (got: java.sql.BatchUpdateException: failed batch). So I
>>> assume that also hsqldb creates a pk (at least with me).
>>>
>>> When I run the testcase as you send me I get the following
>>> nonuniqueobjectexception:
>>> Caused by: org.hibernate.NonUniqueObjectException: a different object
>>> with the same identifier value was already associated with the session:
>>> [StringCollection#0]
>>>
>>> Afaiu this is not related to a database constraint violation, it happens
>>> earlier (before the database inserts take place) as hibernate already
>>> notices that two objects with the same id are associated with the
>>> session. This seems a correct exception as there are two objects with
>>> the same id (0 in your case) associated with the session.
>>>
>>> gr. Martin
>>>
>>> Christian Donhofer wrote:
>>>> On Fri, 06 Apr 2007 13:41:24 -0500 Michael Kanaley wrote:
>>>>
>>>>> Hi Martin,
>>>>> According to the page
>>>>> http://www.elver.org/hibernate/ejb3_features.html:
>>>>> When an eattribute has its ID property set to true and there is no @Id
>>>>> annotated eattribute in the eclass then the ID eattribute is used.
>>>>> This default behavior can be changed using the option:
>>>>> ID_FEATURE_AS_PRIMARY_KEY.
>>>>>
>>>> hi michael,
>>>>
>>>> please output your persistenceoptions and post them here - maybe the
>>>> feature isn't set to true by default anymore?
>>>>
>>>> chris
>>>>
>>>
>>> --
>>>
>>> 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]Custom primary key column is not being defined correctly. [message #78964 is a reply to message #78936] Tue, 10 April 2007 04:11 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
I saw it.
btw, the reason that I mention EDataTypes is that then you don't need to add the annotation on each
EAttribute but can maintain them in one location (the EDataType). The annotations on EDataType also
work on EAttributes (and vice versa).

gr. Martin

Michael Kanaley wrote:
> Filed 181631. I am also experimenting using EDataTypes to set the generator.
> Thanks,
> -mike
>
> "Martin Taal" <mtaal@elver.org> wrote in message
> news:evbjg1$ujj$1@build.eclipse.org...
>> Hi Mike,
>> I have already changed the behavior to unique=true (for the 0,8,0 build)
>> and have added a bugzilla for this.
>>
>> No there is currently no way to let Teneo automatically create the
>> generator tag for an id. One way is to use an edatatype for the id
>> attributes and set a generator annotation on the edatatype.
>> I also thought about automatic adding this behavior (option driven) to id
>> attributes of type long. If you are interested can you enter a bugzilla
>> for this?
>>
>> gr. Martin
>>
>> Michael Kanaley wrote:
>>> Hi Martin,
>>> I agree that unique="false" is not a major problem, although I think
>>> the default should be changed to unique="true" - should I file a
>>> bugzilla?
>>>
>>> The real problem I am having is that in Teneo v200610261350, a primary
>>> key generator was automatically being inserted into the id mapping like:
>>> <generator class="native"/>
>>> In the latest Teneo, this no longer happens but I would like it to.
>>> Is there a way to make this happen?
>>> Thanks,
>>> -mike
>>>
>>> "Martin Taal" <mtaal@elver.org> wrote in message
>>> news:ev69nk$79o$1@build.eclipse.org...
>>>> Hi Mike,
>>>> Good that you provided an easy to reproduce test case. The issue is not
>>>> with the option.
>>>> First I would say that the column tag should have unique="true", so this
>>>> seems a mistake in the mapping but this mistake does not seem to give a
>>>> problem.
>>>>
>>>> I tested this with both hsqldb and mysql. With mysql a primary key is
>>>> created (I tested two sql insert statements with the same id and the
>>>> second one failed). The value of the unique="true|false" attribute (the
>>>> mapping mistake I mention above) did not make a difference, for both
>>>> true and false I got a pk.
>>>> Testing using hsqldb showed that I could not insert an object with the
>>>> same id twice (got: java.sql.BatchUpdateException: failed batch). So I
>>>> assume that also hsqldb creates a pk (at least with me).
>>>>
>>>> When I run the testcase as you send me I get the following
>>>> nonuniqueobjectexception:
>>>> Caused by: org.hibernate.NonUniqueObjectException: a different object
>>>> with the same identifier value was already associated with the session:
>>>> [StringCollection#0]
>>>>
>>>> Afaiu this is not related to a database constraint violation, it happens
>>>> earlier (before the database inserts take place) as hibernate already
>>>> notices that two objects with the same id are associated with the
>>>> session. This seems a correct exception as there are two objects with
>>>> the same id (0 in your case) associated with the session.
>>>>
>>>> gr. Martin
>>>>
>>>> Christian Donhofer wrote:
>>>>> On Fri, 06 Apr 2007 13:41:24 -0500 Michael Kanaley wrote:
>>>>>
>>>>>> Hi Martin,
>>>>>> According to the page
>>>>>> http://www.elver.org/hibernate/ejb3_features.html:
>>>>>> When an eattribute has its ID property set to true and there is no @Id
>>>>>> annotated eattribute in the eclass then the ID eattribute is used.
>>>>>> This default behavior can be changed using the option:
>>>>>> ID_FEATURE_AS_PRIMARY_KEY.
>>>>>>
>>>>> hi michael,
>>>>>
>>>>> please output your persistenceoptions and post them here - maybe the
>>>>> feature isn't set to true by default anymore?
>>>>>
>>>>> chris
>>>>>
>>>> --
>>>>
>>>> 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
>
>


--

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]Custom primary key column is not being defined correctly. [message #79498 is a reply to message #78964] Wed, 11 April 2007 21:50 Go to previous messageGo to next message
Michael Kanaley is currently offline Michael KanaleyFriend
Messages: 89
Registered: July 2009
Member
Hi Martin,
I defined an EDataType and assigned it the following annotations:
@Id
@GeneratedValue(generator="IdentitySeq")
@SequenceGenerator(name="IdentitySeq",sequenceName="IDENTITY_SEQ ")
@Column(unique="true")

when I did this, my attribute of this EDataType got mapping:
<id name="id" type="java.lang.Long">

<column not-null="false" unique="true" name="`id`"/>

<generator class="native"/>

</id>

Is that right?

I like the mapping, I don't care about the annotations.
I am just not sure about the most concise way of defining the annotations to
achieve this mapping.
If you know offhand, that would help me.
Thanks for all the help,
-mike

"Martin Taal" <mtaal@elver.org> wrote in message
news:evf2on$ui3$1@build.eclipse.org...
>I saw it.
> btw, the reason that I mention EDataTypes is that then you don't need to
> add the annotation on each EAttribute but can maintain them in one
> location (the EDataType). The annotations on EDataType also work on
> EAttributes (and vice versa).
>
> gr. Martin
>
> Michael Kanaley wrote:
>> Filed 181631. I am also experimenting using EDataTypes to set the
>> generator.
>> Thanks,
>> -mike
>>
>> "Martin Taal" <mtaal@elver.org> wrote in message
>> news:evbjg1$ujj$1@build.eclipse.org...
>>> Hi Mike,
>>> I have already changed the behavior to unique=true (for the 0,8,0 build)
>>> and have added a bugzilla for this.
>>>
>>> No there is currently no way to let Teneo automatically create the
>>> generator tag for an id. One way is to use an edatatype for the id
>>> attributes and set a generator annotation on the edatatype.
>>> I also thought about automatic adding this behavior (option driven) to
>>> id attributes of type long. If you are interested can you enter a
>>> bugzilla for this?
>>>
>>> gr. Martin
>>>
>>> Michael Kanaley wrote:
>>>> Hi Martin,
>>>> I agree that unique="false" is not a major problem, although I think
>>>> the default should be changed to unique="true" - should I file a
>>>> bugzilla?
>>>>
>>>> The real problem I am having is that in Teneo v200610261350, a primary
>>>> key generator was automatically being inserted into the id mapping
>>>> like:
>>>> <generator class="native"/>
>>>> In the latest Teneo, this no longer happens but I would like it to.
>>>> Is there a way to make this happen?
>>>> Thanks,
>>>> -mike
>>>>
>>>> "Martin Taal" <mtaal@elver.org> wrote in message
>>>> news:ev69nk$79o$1@build.eclipse.org...
>>>>> Hi Mike,
>>>>> Good that you provided an easy to reproduce test case. The issue is
>>>>> not with the option.
>>>>> First I would say that the column tag should have unique="true", so
>>>>> this seems a mistake in the mapping but this mistake does not seem to
>>>>> give a problem.
>>>>>
>>>>> I tested this with both hsqldb and mysql. With mysql a primary key is
>>>>> created (I tested two sql insert statements with the same id and the
>>>>> second one failed). The value of the unique="true|false" attribute
>>>>> (the mapping mistake I mention above) did not make a difference, for
>>>>> both true and false I got a pk.
>>>>> Testing using hsqldb showed that I could not insert an object with the
>>>>> same id twice (got: java.sql.BatchUpdateException: failed batch). So I
>>>>> assume that also hsqldb creates a pk (at least with me).
>>>>>
>>>>> When I run the testcase as you send me I get the following
>>>>> nonuniqueobjectexception:
>>>>> Caused by: org.hibernate.NonUniqueObjectException: a different object
>>>>> with the same identifier value was already associated with the
>>>>> session: [StringCollection#0]
>>>>>
>>>>> Afaiu this is not related to a database constraint violation, it
>>>>> happens earlier (before the database inserts take place) as hibernate
>>>>> already notices that two objects with the same id are associated with
>>>>> the session. This seems a correct exception as there are two objects
>>>>> with the same id (0 in your case) associated with the session.
>>>>>
>>>>> gr. Martin
>>>>>
>>>>> Christian Donhofer wrote:
>>>>>> On Fri, 06 Apr 2007 13:41:24 -0500 Michael Kanaley wrote:
>>>>>>
>>>>>>> Hi Martin,
>>>>>>> According to the page
>>>>>>> http://www.elver.org/hibernate/ejb3_features.html:
>>>>>>> When an eattribute has its ID property set to true and there is no
>>>>>>> @Id annotated eattribute in the eclass then the ID eattribute is
>>>>>>> used. This default behavior can be changed using the option:
>>>>>>> ID_FEATURE_AS_PRIMARY_KEY.
>>>>>>>
>>>>>> hi michael,
>>>>>>
>>>>>> please output your persistenceoptions and post them here - maybe the
>>>>>> feature isn't set to true by default anymore?
>>>>>>
>>>>>> chris
>>>>>>
>>>>> --
>>>>>
>>>>> 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
>>
>>
>
>
> --
>
> 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]Custom primary key column is not being defined correctly. [message #79511 is a reply to message #79498] Wed, 11 April 2007 22:11 Go to previous message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Mike,
These annotations should give the same mapping:
@Id
@GeneratedValue(strategy="AUTO")

Your annotations do not correspond with the mapping. To use the sequencegenerator you need to change
two things:
- define the sequencegenerator ann. on epackage level (support for this on estructuralfeature level
should be added to Teneo, you can enter a bugzilla for this if you want)
- also define a strategy attribute in GeneratedValue, the value should be: strategy="SEQUENCE"

But if the mapping below is allright then you only need to specify the Id and the GeneratedValue
annotations as above.

gr. Martin

Michael Kanaley wrote:
> Hi Martin,
> I defined an EDataType and assigned it the following annotations:
> @Id
> @GeneratedValue(generator="IdentitySeq")
> @SequenceGenerator(name="IdentitySeq",sequenceName="IDENTITY_SEQ ")
> @Column(unique="true")
>
> when I did this, my attribute of this EDataType got mapping:
> <id name="id" type="java.lang.Long">
>
> <column not-null="false" unique="true" name="`id`"/>
>
> <generator class="native"/>
>
> </id>
>
> Is that right?
>
> I like the mapping, I don't care about the annotations.
> I am just not sure about the most concise way of defining the annotations to
> achieve this mapping.
> If you know offhand, that would help me.
> Thanks for all the help,
> -mike
>
> "Martin Taal" <mtaal@elver.org> wrote in message
> news:evf2on$ui3$1@build.eclipse.org...
>> I saw it.
>> btw, the reason that I mention EDataTypes is that then you don't need to
>> add the annotation on each EAttribute but can maintain them in one
>> location (the EDataType). The annotations on EDataType also work on
>> EAttributes (and vice versa).
>>
>> gr. Martin
>>
>> Michael Kanaley wrote:
>>> Filed 181631. I am also experimenting using EDataTypes to set the
>>> generator.
>>> Thanks,
>>> -mike
>>>
>>> "Martin Taal" <mtaal@elver.org> wrote in message
>>> news:evbjg1$ujj$1@build.eclipse.org...
>>>> Hi Mike,
>>>> I have already changed the behavior to unique=true (for the 0,8,0 build)
>>>> and have added a bugzilla for this.
>>>>
>>>> No there is currently no way to let Teneo automatically create the
>>>> generator tag for an id. One way is to use an edatatype for the id
>>>> attributes and set a generator annotation on the edatatype.
>>>> I also thought about automatic adding this behavior (option driven) to
>>>> id attributes of type long. If you are interested can you enter a
>>>> bugzilla for this?
>>>>
>>>> gr. Martin
>>>>
>>>> Michael Kanaley wrote:
>>>>> Hi Martin,
>>>>> I agree that unique="false" is not a major problem, although I think
>>>>> the default should be changed to unique="true" - should I file a
>>>>> bugzilla?
>>>>>
>>>>> The real problem I am having is that in Teneo v200610261350, a primary
>>>>> key generator was automatically being inserted into the id mapping
>>>>> like:
>>>>> <generator class="native"/>
>>>>> In the latest Teneo, this no longer happens but I would like it to.
>>>>> Is there a way to make this happen?
>>>>> Thanks,
>>>>> -mike
>>>>>
>>>>> "Martin Taal" <mtaal@elver.org> wrote in message
>>>>> news:ev69nk$79o$1@build.eclipse.org...
>>>>>> Hi Mike,
>>>>>> Good that you provided an easy to reproduce test case. The issue is
>>>>>> not with the option.
>>>>>> First I would say that the column tag should have unique="true", so
>>>>>> this seems a mistake in the mapping but this mistake does not seem to
>>>>>> give a problem.
>>>>>>
>>>>>> I tested this with both hsqldb and mysql. With mysql a primary key is
>>>>>> created (I tested two sql insert statements with the same id and the
>>>>>> second one failed). The value of the unique="true|false" attribute
>>>>>> (the mapping mistake I mention above) did not make a difference, for
>>>>>> both true and false I got a pk.
>>>>>> Testing using hsqldb showed that I could not insert an object with the
>>>>>> same id twice (got: java.sql.BatchUpdateException: failed batch). So I
>>>>>> assume that also hsqldb creates a pk (at least with me).
>>>>>>
>>>>>> When I run the testcase as you send me I get the following
>>>>>> nonuniqueobjectexception:
>>>>>> Caused by: org.hibernate.NonUniqueObjectException: a different object
>>>>>> with the same identifier value was already associated with the
>>>>>> session: [StringCollection#0]
>>>>>>
>>>>>> Afaiu this is not related to a database constraint violation, it
>>>>>> happens earlier (before the database inserts take place) as hibernate
>>>>>> already notices that two objects with the same id are associated with
>>>>>> the session. This seems a correct exception as there are two objects
>>>>>> with the same id (0 in your case) associated with the session.
>>>>>>
>>>>>> gr. Martin
>>>>>>
>>>>>> Christian Donhofer wrote:
>>>>>>> On Fri, 06 Apr 2007 13:41:24 -0500 Michael Kanaley wrote:
>>>>>>>
>>>>>>>> Hi Martin,
>>>>>>>> According to the page
>>>>>>>> http://www.elver.org/hibernate/ejb3_features.html:
>>>>>>>> When an eattribute has its ID property set to true and there is no
>>>>>>>> @Id annotated eattribute in the eclass then the ID eattribute is
>>>>>>>> used. This default behavior can be changed using the option:
>>>>>>>> ID_FEATURE_AS_PRIMARY_KEY.
>>>>>>>>
>>>>>>> hi michael,
>>>>>>>
>>>>>>> please output your persistenceoptions and post them here - maybe the
>>>>>>> feature isn't set to true by default anymore?
>>>>>>>
>>>>>>> chris
>>>>>>>
>>>>>> --
>>>>>>
>>>>>> 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
>>>
>>
>> --
>>
>> 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]Custom primary key column is not being defined correctly. [message #604446 is a reply to message #78746] Fri, 06 April 2007 18:57 Go to previous message
Christian Donhofer is currently offline Christian DonhoferFriend
Messages: 94
Registered: July 2009
Member
On Fri, 06 Apr 2007 13:41:24 -0500 Michael Kanaley wrote:

> Hi Martin,
> According to the page http://www.elver.org/hibernate/ejb3_features.html:
> When an eattribute has its ID property set to true and there is no @Id
> annotated eattribute in the eclass then the ID eattribute is used. This
> default behavior can be changed using the option: ID_FEATURE_AS_PRIMARY_KEY.
>

hi michael,

please output your persistenceoptions and post them here - maybe the
feature isn't set to true by default anymore?

chris
Re: [Teneo]Custom primary key column is not being defined correctly. [message #604449 is a reply to message #78764] Fri, 06 April 2007 20:14 Go to previous message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Mike,
Good that you provided an easy to reproduce test case. The issue is not with the option.
First I would say that the column tag should have unique="true", so this seems a mistake in the
mapping but this mistake does not seem to give a problem.

I tested this with both hsqldb and mysql. With mysql a primary key is created (I tested two sql
insert statements with the same id and the second one failed). The value of the unique="true|false"
attribute (the mapping mistake I mention above) did not make a difference, for both true and false I
got a pk.
Testing using hsqldb showed that I could not insert an object with the same id twice (got:
java.sql.BatchUpdateException: failed batch). So I assume that also hsqldb creates a pk (at least
with me).

When I run the testcase as you send me I get the following nonuniqueobjectexception:
Caused by: org.hibernate.NonUniqueObjectException: a different object with the same identifier value
was already associated with the session: [StringCollection#0]

Afaiu this is not related to a database constraint violation, it happens earlier (before the
database inserts take place) as hibernate already notices that two objects with the same id are
associated with the session. This seems a correct exception as there are two objects with the same
id (0 in your case) associated with the session.

gr. Martin

Christian Donhofer wrote:
> On Fri, 06 Apr 2007 13:41:24 -0500 Michael Kanaley wrote:
>
>> Hi Martin,
>> According to the page http://www.elver.org/hibernate/ejb3_features.html:
>> When an eattribute has its ID property set to true and there is no @Id
>> annotated eattribute in the eclass then the ID eattribute is used. This
>> default behavior can be changed using the option: ID_FEATURE_AS_PRIMARY_KEY.
>>
>
> hi michael,
>
> please output your persistenceoptions and post them here - maybe the
> feature isn't set to true by default anymore?
>
> chris
>


--

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]Custom primary key column is not being defined correctly. [message #604478 is a reply to message #78778] Sun, 08 April 2007 10:28 Go to previous message
Michael Kanaley is currently offline Michael KanaleyFriend
Messages: 89
Registered: July 2009
Member
Hi Martin,
I agree that unique="false" is not a major problem, although I think the
default should be changed to unique="true" - should I file a bugzilla?

The real problem I am having is that in Teneo v200610261350, a primary key
generator was automatically being inserted into the id mapping like:
<generator class="native"/>
In the latest Teneo, this no longer happens but I would like it to.
Is there a way to make this happen?
Thanks,
-mike

"Martin Taal" <mtaal@elver.org> wrote in message
news:ev69nk$79o$1@build.eclipse.org...
> Hi Mike,
> Good that you provided an easy to reproduce test case. The issue is not
> with the option.
> First I would say that the column tag should have unique="true", so this
> seems a mistake in the mapping but this mistake does not seem to give a
> problem.
>
> I tested this with both hsqldb and mysql. With mysql a primary key is
> created (I tested two sql insert statements with the same id and the
> second one failed). The value of the unique="true|false" attribute (the
> mapping mistake I mention above) did not make a difference, for both true
> and false I got a pk.
> Testing using hsqldb showed that I could not insert an object with the
> same id twice (got: java.sql.BatchUpdateException: failed batch). So I
> assume that also hsqldb creates a pk (at least with me).
>
> When I run the testcase as you send me I get the following
> nonuniqueobjectexception:
> Caused by: org.hibernate.NonUniqueObjectException: a different object with
> the same identifier value was already associated with the session:
> [StringCollection#0]
>
> Afaiu this is not related to a database constraint violation, it happens
> earlier (before the database inserts take place) as hibernate already
> notices that two objects with the same id are associated with the session.
> This seems a correct exception as there are two objects with the same id
> (0 in your case) associated with the session.
>
> gr. Martin
>
> Christian Donhofer wrote:
>> On Fri, 06 Apr 2007 13:41:24 -0500 Michael Kanaley wrote:
>>
>>> Hi Martin,
>>> According to the page http://www.elver.org/hibernate/ejb3_features.html:
>>> When an eattribute has its ID property set to true and there is no @Id
>>> annotated eattribute in the eclass then the ID eattribute is used. This
>>> default behavior can be changed using the option:
>>> ID_FEATURE_AS_PRIMARY_KEY.
>>>
>>
>> hi michael,
>>
>> please output your persistenceoptions and post them here - maybe the
>> feature isn't set to true by default anymore?
>>
>> chris
>>
>
>
> --
>
> 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]Custom primary key column is not being defined correctly. [message #604482 is a reply to message #78886] Sun, 08 April 2007 20:31 Go to previous message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Mike,
I have already changed the behavior to unique=true (for the 0,8,0 build) and have added a bugzilla
for this.

No there is currently no way to let Teneo automatically create the generator tag for an id. One way
is to use an edatatype for the id attributes and set a generator annotation on the edatatype.
I also thought about automatic adding this behavior (option driven) to id attributes of type long.
If you are interested can you enter a bugzilla for this?

gr. Martin

Michael Kanaley wrote:
> Hi Martin,
> I agree that unique="false" is not a major problem, although I think the
> default should be changed to unique="true" - should I file a bugzilla?
>
> The real problem I am having is that in Teneo v200610261350, a primary key
> generator was automatically being inserted into the id mapping like:
> <generator class="native"/>
> In the latest Teneo, this no longer happens but I would like it to.
> Is there a way to make this happen?
> Thanks,
> -mike
>
> "Martin Taal" <mtaal@elver.org> wrote in message
> news:ev69nk$79o$1@build.eclipse.org...
>> Hi Mike,
>> Good that you provided an easy to reproduce test case. The issue is not
>> with the option.
>> First I would say that the column tag should have unique="true", so this
>> seems a mistake in the mapping but this mistake does not seem to give a
>> problem.
>>
>> I tested this with both hsqldb and mysql. With mysql a primary key is
>> created (I tested two sql insert statements with the same id and the
>> second one failed). The value of the unique="true|false" attribute (the
>> mapping mistake I mention above) did not make a difference, for both true
>> and false I got a pk.
>> Testing using hsqldb showed that I could not insert an object with the
>> same id twice (got: java.sql.BatchUpdateException: failed batch). So I
>> assume that also hsqldb creates a pk (at least with me).
>>
>> When I run the testcase as you send me I get the following
>> nonuniqueobjectexception:
>> Caused by: org.hibernate.NonUniqueObjectException: a different object with
>> the same identifier value was already associated with the session:
>> [StringCollection#0]
>>
>> Afaiu this is not related to a database constraint violation, it happens
>> earlier (before the database inserts take place) as hibernate already
>> notices that two objects with the same id are associated with the session.
>> This seems a correct exception as there are two objects with the same id
>> (0 in your case) associated with the session.
>>
>> gr. Martin
>>
>> Christian Donhofer wrote:
>>> On Fri, 06 Apr 2007 13:41:24 -0500 Michael Kanaley wrote:
>>>
>>>> Hi Martin,
>>>> According to the page http://www.elver.org/hibernate/ejb3_features.html:
>>>> When an eattribute has its ID property set to true and there is no @Id
>>>> annotated eattribute in the eclass then the ID eattribute is used. This
>>>> default behavior can be changed using the option:
>>>> ID_FEATURE_AS_PRIMARY_KEY.
>>>>
>>> hi michael,
>>>
>>> please output your persistenceoptions and post them here - maybe the
>>> feature isn't set to true by default anymore?
>>>
>>> chris
>>>
>>
>> --
>>
>> 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]Custom primary key column is not being defined correctly. [message #604499 is a reply to message #78898] Mon, 09 April 2007 17:43 Go to previous message
Michael Kanaley is currently offline Michael KanaleyFriend
Messages: 89
Registered: July 2009
Member
Filed 181631. I am also experimenting using EDataTypes to set the generator.
Thanks,
-mike

"Martin Taal" <mtaal@elver.org> wrote in message
news:evbjg1$ujj$1@build.eclipse.org...
> Hi Mike,
> I have already changed the behavior to unique=true (for the 0,8,0 build)
> and have added a bugzilla for this.
>
> No there is currently no way to let Teneo automatically create the
> generator tag for an id. One way is to use an edatatype for the id
> attributes and set a generator annotation on the edatatype.
> I also thought about automatic adding this behavior (option driven) to id
> attributes of type long. If you are interested can you enter a bugzilla
> for this?
>
> gr. Martin
>
> Michael Kanaley wrote:
>> Hi Martin,
>> I agree that unique="false" is not a major problem, although I think
>> the default should be changed to unique="true" - should I file a
>> bugzilla?
>>
>> The real problem I am having is that in Teneo v200610261350, a primary
>> key generator was automatically being inserted into the id mapping like:
>> <generator class="native"/>
>> In the latest Teneo, this no longer happens but I would like it to.
>> Is there a way to make this happen?
>> Thanks,
>> -mike
>>
>> "Martin Taal" <mtaal@elver.org> wrote in message
>> news:ev69nk$79o$1@build.eclipse.org...
>>> Hi Mike,
>>> Good that you provided an easy to reproduce test case. The issue is not
>>> with the option.
>>> First I would say that the column tag should have unique="true", so this
>>> seems a mistake in the mapping but this mistake does not seem to give a
>>> problem.
>>>
>>> I tested this with both hsqldb and mysql. With mysql a primary key is
>>> created (I tested two sql insert statements with the same id and the
>>> second one failed). The value of the unique="true|false" attribute (the
>>> mapping mistake I mention above) did not make a difference, for both
>>> true and false I got a pk.
>>> Testing using hsqldb showed that I could not insert an object with the
>>> same id twice (got: java.sql.BatchUpdateException: failed batch). So I
>>> assume that also hsqldb creates a pk (at least with me).
>>>
>>> When I run the testcase as you send me I get the following
>>> nonuniqueobjectexception:
>>> Caused by: org.hibernate.NonUniqueObjectException: a different object
>>> with the same identifier value was already associated with the session:
>>> [StringCollection#0]
>>>
>>> Afaiu this is not related to a database constraint violation, it happens
>>> earlier (before the database inserts take place) as hibernate already
>>> notices that two objects with the same id are associated with the
>>> session. This seems a correct exception as there are two objects with
>>> the same id (0 in your case) associated with the session.
>>>
>>> gr. Martin
>>>
>>> Christian Donhofer wrote:
>>>> On Fri, 06 Apr 2007 13:41:24 -0500 Michael Kanaley wrote:
>>>>
>>>>> Hi Martin,
>>>>> According to the page
>>>>> http://www.elver.org/hibernate/ejb3_features.html:
>>>>> When an eattribute has its ID property set to true and there is no @Id
>>>>> annotated eattribute in the eclass then the ID eattribute is used.
>>>>> This default behavior can be changed using the option:
>>>>> ID_FEATURE_AS_PRIMARY_KEY.
>>>>>
>>>> hi michael,
>>>>
>>>> please output your persistenceoptions and post them here - maybe the
>>>> feature isn't set to true by default anymore?
>>>>
>>>> chris
>>>>
>>>
>>> --
>>>
>>> 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]Custom primary key column is not being defined correctly. [message #604513 is a reply to message #78936] Tue, 10 April 2007 04:11 Go to previous message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
I saw it.
btw, the reason that I mention EDataTypes is that then you don't need to add the annotation on each
EAttribute but can maintain them in one location (the EDataType). The annotations on EDataType also
work on EAttributes (and vice versa).

gr. Martin

Michael Kanaley wrote:
> Filed 181631. I am also experimenting using EDataTypes to set the generator.
> Thanks,
> -mike
>
> "Martin Taal" <mtaal@elver.org> wrote in message
> news:evbjg1$ujj$1@build.eclipse.org...
>> Hi Mike,
>> I have already changed the behavior to unique=true (for the 0,8,0 build)
>> and have added a bugzilla for this.
>>
>> No there is currently no way to let Teneo automatically create the
>> generator tag for an id. One way is to use an edatatype for the id
>> attributes and set a generator annotation on the edatatype.
>> I also thought about automatic adding this behavior (option driven) to id
>> attributes of type long. If you are interested can you enter a bugzilla
>> for this?
>>
>> gr. Martin
>>
>> Michael Kanaley wrote:
>>> Hi Martin,
>>> I agree that unique="false" is not a major problem, although I think
>>> the default should be changed to unique="true" - should I file a
>>> bugzilla?
>>>
>>> The real problem I am having is that in Teneo v200610261350, a primary
>>> key generator was automatically being inserted into the id mapping like:
>>> <generator class="native"/>
>>> In the latest Teneo, this no longer happens but I would like it to.
>>> Is there a way to make this happen?
>>> Thanks,
>>> -mike
>>>
>>> "Martin Taal" <mtaal@elver.org> wrote in message
>>> news:ev69nk$79o$1@build.eclipse.org...
>>>> Hi Mike,
>>>> Good that you provided an easy to reproduce test case. The issue is not
>>>> with the option.
>>>> First I would say that the column tag should have unique="true", so this
>>>> seems a mistake in the mapping but this mistake does not seem to give a
>>>> problem.
>>>>
>>>> I tested this with both hsqldb and mysql. With mysql a primary key is
>>>> created (I tested two sql insert statements with the same id and the
>>>> second one failed). The value of the unique="true|false" attribute (the
>>>> mapping mistake I mention above) did not make a difference, for both
>>>> true and false I got a pk.
>>>> Testing using hsqldb showed that I could not insert an object with the
>>>> same id twice (got: java.sql.BatchUpdateException: failed batch). So I
>>>> assume that also hsqldb creates a pk (at least with me).
>>>>
>>>> When I run the testcase as you send me I get the following
>>>> nonuniqueobjectexception:
>>>> Caused by: org.hibernate.NonUniqueObjectException: a different object
>>>> with the same identifier value was already associated with the session:
>>>> [StringCollection#0]
>>>>
>>>> Afaiu this is not related to a database constraint violation, it happens
>>>> earlier (before the database inserts take place) as hibernate already
>>>> notices that two objects with the same id are associated with the
>>>> session. This seems a correct exception as there are two objects with
>>>> the same id (0 in your case) associated with the session.
>>>>
>>>> gr. Martin
>>>>
>>>> Christian Donhofer wrote:
>>>>> On Fri, 06 Apr 2007 13:41:24 -0500 Michael Kanaley wrote:
>>>>>
>>>>>> Hi Martin,
>>>>>> According to the page
>>>>>> http://www.elver.org/hibernate/ejb3_features.html:
>>>>>> When an eattribute has its ID property set to true and there is no @Id
>>>>>> annotated eattribute in the eclass then the ID eattribute is used.
>>>>>> This default behavior can be changed using the option:
>>>>>> ID_FEATURE_AS_PRIMARY_KEY.
>>>>>>
>>>>> hi michael,
>>>>>
>>>>> please output your persistenceoptions and post them here - maybe the
>>>>> feature isn't set to true by default anymore?
>>>>>
>>>>> chris
>>>>>
>>>> --
>>>>
>>>> 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
>
>


--

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]Custom primary key column is not being defined correctly. [message #604652 is a reply to message #78964] Wed, 11 April 2007 21:50 Go to previous message
Michael Kanaley is currently offline Michael KanaleyFriend
Messages: 89
Registered: July 2009
Member
Hi Martin,
I defined an EDataType and assigned it the following annotations:
@Id
@GeneratedValue(generator="IdentitySeq")
@SequenceGenerator(name="IdentitySeq",sequenceName="IDENTITY_SEQ ")
@Column(unique="true")

when I did this, my attribute of this EDataType got mapping:
<id name="id" type="java.lang.Long">

<column not-null="false" unique="true" name="`id`"/>

<generator class="native"/>

</id>

Is that right?

I like the mapping, I don't care about the annotations.
I am just not sure about the most concise way of defining the annotations to
achieve this mapping.
If you know offhand, that would help me.
Thanks for all the help,
-mike

"Martin Taal" <mtaal@elver.org> wrote in message
news:evf2on$ui3$1@build.eclipse.org...
>I saw it.
> btw, the reason that I mention EDataTypes is that then you don't need to
> add the annotation on each EAttribute but can maintain them in one
> location (the EDataType). The annotations on EDataType also work on
> EAttributes (and vice versa).
>
> gr. Martin
>
> Michael Kanaley wrote:
>> Filed 181631. I am also experimenting using EDataTypes to set the
>> generator.
>> Thanks,
>> -mike
>>
>> "Martin Taal" <mtaal@elver.org> wrote in message
>> news:evbjg1$ujj$1@build.eclipse.org...
>>> Hi Mike,
>>> I have already changed the behavior to unique=true (for the 0,8,0 build)
>>> and have added a bugzilla for this.
>>>
>>> No there is currently no way to let Teneo automatically create the
>>> generator tag for an id. One way is to use an edatatype for the id
>>> attributes and set a generator annotation on the edatatype.
>>> I also thought about automatic adding this behavior (option driven) to
>>> id attributes of type long. If you are interested can you enter a
>>> bugzilla for this?
>>>
>>> gr. Martin
>>>
>>> Michael Kanaley wrote:
>>>> Hi Martin,
>>>> I agree that unique="false" is not a major problem, although I think
>>>> the default should be changed to unique="true" - should I file a
>>>> bugzilla?
>>>>
>>>> The real problem I am having is that in Teneo v200610261350, a primary
>>>> key generator was automatically being inserted into the id mapping
>>>> like:
>>>> <generator class="native"/>
>>>> In the latest Teneo, this no longer happens but I would like it to.
>>>> Is there a way to make this happen?
>>>> Thanks,
>>>> -mike
>>>>
>>>> "Martin Taal" <mtaal@elver.org> wrote in message
>>>> news:ev69nk$79o$1@build.eclipse.org...
>>>>> Hi Mike,
>>>>> Good that you provided an easy to reproduce test case. The issue is
>>>>> not with the option.
>>>>> First I would say that the column tag should have unique="true", so
>>>>> this seems a mistake in the mapping but this mistake does not seem to
>>>>> give a problem.
>>>>>
>>>>> I tested this with both hsqldb and mysql. With mysql a primary key is
>>>>> created (I tested two sql insert statements with the same id and the
>>>>> second one failed). The value of the unique="true|false" attribute
>>>>> (the mapping mistake I mention above) did not make a difference, for
>>>>> both true and false I got a pk.
>>>>> Testing using hsqldb showed that I could not insert an object with the
>>>>> same id twice (got: java.sql.BatchUpdateException: failed batch). So I
>>>>> assume that also hsqldb creates a pk (at least with me).
>>>>>
>>>>> When I run the testcase as you send me I get the following
>>>>> nonuniqueobjectexception:
>>>>> Caused by: org.hibernate.NonUniqueObjectException: a different object
>>>>> with the same identifier value was already associated with the
>>>>> session: [StringCollection#0]
>>>>>
>>>>> Afaiu this is not related to a database constraint violation, it
>>>>> happens earlier (before the database inserts take place) as hibernate
>>>>> already notices that two objects with the same id are associated with
>>>>> the session. This seems a correct exception as there are two objects
>>>>> with the same id (0 in your case) associated with the session.
>>>>>
>>>>> gr. Martin
>>>>>
>>>>> Christian Donhofer wrote:
>>>>>> On Fri, 06 Apr 2007 13:41:24 -0500 Michael Kanaley wrote:
>>>>>>
>>>>>>> Hi Martin,
>>>>>>> According to the page
>>>>>>> http://www.elver.org/hibernate/ejb3_features.html:
>>>>>>> When an eattribute has its ID property set to true and there is no
>>>>>>> @Id annotated eattribute in the eclass then the ID eattribute is
>>>>>>> used. This default behavior can be changed using the option:
>>>>>>> ID_FEATURE_AS_PRIMARY_KEY.
>>>>>>>
>>>>>> hi michael,
>>>>>>
>>>>>> please output your persistenceoptions and post them here - maybe the
>>>>>> feature isn't set to true by default anymore?
>>>>>>
>>>>>> chris
>>>>>>
>>>>> --
>>>>>
>>>>> 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
>>
>>
>
>
> --
>
> 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]Custom primary key column is not being defined correctly. [message #604656 is a reply to message #79498] Wed, 11 April 2007 22:11 Go to previous message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Mike,
These annotations should give the same mapping:
@Id
@GeneratedValue(strategy="AUTO")

Your annotations do not correspond with the mapping. To use the sequencegenerator you need to change
two things:
- define the sequencegenerator ann. on epackage level (support for this on estructuralfeature level
should be added to Teneo, you can enter a bugzilla for this if you want)
- also define a strategy attribute in GeneratedValue, the value should be: strategy="SEQUENCE"

But if the mapping below is allright then you only need to specify the Id and the GeneratedValue
annotations as above.

gr. Martin

Michael Kanaley wrote:
> Hi Martin,
> I defined an EDataType and assigned it the following annotations:
> @Id
> @GeneratedValue(generator="IdentitySeq")
> @SequenceGenerator(name="IdentitySeq",sequenceName="IDENTITY_SEQ ")
> @Column(unique="true")
>
> when I did this, my attribute of this EDataType got mapping:
> <id name="id" type="java.lang.Long">
>
> <column not-null="false" unique="true" name="`id`"/>
>
> <generator class="native"/>
>
> </id>
>
> Is that right?
>
> I like the mapping, I don't care about the annotations.
> I am just not sure about the most concise way of defining the annotations to
> achieve this mapping.
> If you know offhand, that would help me.
> Thanks for all the help,
> -mike
>
> "Martin Taal" <mtaal@elver.org> wrote in message
> news:evf2on$ui3$1@build.eclipse.org...
>> I saw it.
>> btw, the reason that I mention EDataTypes is that then you don't need to
>> add the annotation on each EAttribute but can maintain them in one
>> location (the EDataType). The annotations on EDataType also work on
>> EAttributes (and vice versa).
>>
>> gr. Martin
>>
>> Michael Kanaley wrote:
>>> Filed 181631. I am also experimenting using EDataTypes to set the
>>> generator.
>>> Thanks,
>>> -mike
>>>
>>> "Martin Taal" <mtaal@elver.org> wrote in message
>>> news:evbjg1$ujj$1@build.eclipse.org...
>>>> Hi Mike,
>>>> I have already changed the behavior to unique=true (for the 0,8,0 build)
>>>> and have added a bugzilla for this.
>>>>
>>>> No there is currently no way to let Teneo automatically create the
>>>> generator tag for an id. One way is to use an edatatype for the id
>>>> attributes and set a generator annotation on the edatatype.
>>>> I also thought about automatic adding this behavior (option driven) to
>>>> id attributes of type long. If you are interested can you enter a
>>>> bugzilla for this?
>>>>
>>>> gr. Martin
>>>>
>>>> Michael Kanaley wrote:
>>>>> Hi Martin,
>>>>> I agree that unique="false" is not a major problem, although I think
>>>>> the default should be changed to unique="true" - should I file a
>>>>> bugzilla?
>>>>>
>>>>> The real problem I am having is that in Teneo v200610261350, a primary
>>>>> key generator was automatically being inserted into the id mapping
>>>>> like:
>>>>> <generator class="native"/>
>>>>> In the latest Teneo, this no longer happens but I would like it to.
>>>>> Is there a way to make this happen?
>>>>> Thanks,
>>>>> -mike
>>>>>
>>>>> "Martin Taal" <mtaal@elver.org> wrote in message
>>>>> news:ev69nk$79o$1@build.eclipse.org...
>>>>>> Hi Mike,
>>>>>> Good that you provided an easy to reproduce test case. The issue is
>>>>>> not with the option.
>>>>>> First I would say that the column tag should have unique="true", so
>>>>>> this seems a mistake in the mapping but this mistake does not seem to
>>>>>> give a problem.
>>>>>>
>>>>>> I tested this with both hsqldb and mysql. With mysql a primary key is
>>>>>> created (I tested two sql insert statements with the same id and the
>>>>>> second one failed). The value of the unique="true|false" attribute
>>>>>> (the mapping mistake I mention above) did not make a difference, for
>>>>>> both true and false I got a pk.
>>>>>> Testing using hsqldb showed that I could not insert an object with the
>>>>>> same id twice (got: java.sql.BatchUpdateException: failed batch). So I
>>>>>> assume that also hsqldb creates a pk (at least with me).
>>>>>>
>>>>>> When I run the testcase as you send me I get the following
>>>>>> nonuniqueobjectexception:
>>>>>> Caused by: org.hibernate.NonUniqueObjectException: a different object
>>>>>> with the same identifier value was already associated with the
>>>>>> session: [StringCollection#0]
>>>>>>
>>>>>> Afaiu this is not related to a database constraint violation, it
>>>>>> happens earlier (before the database inserts take place) as hibernate
>>>>>> already notices that two objects with the same id are associated with
>>>>>> the session. This seems a correct exception as there are two objects
>>>>>> with the same id (0 in your case) associated with the session.
>>>>>>
>>>>>> gr. Martin
>>>>>>
>>>>>> Christian Donhofer wrote:
>>>>>>> On Fri, 06 Apr 2007 13:41:24 -0500 Michael Kanaley wrote:
>>>>>>>
>>>>>>>> Hi Martin,
>>>>>>>> According to the page
>>>>>>>> http://www.elver.org/hibernate/ejb3_features.html:
>>>>>>>> When an eattribute has its ID property set to true and there is no
>>>>>>>> @Id annotated eattribute in the eclass then the ID eattribute is
>>>>>>>> used. This default behavior can be changed using the option:
>>>>>>>> ID_FEATURE_AS_PRIMARY_KEY.
>>>>>>>>
>>>>>>> hi michael,
>>>>>>>
>>>>>>> please output your persistenceoptions and post them here - maybe the
>>>>>>> feature isn't set to true by default anymore?
>>>>>>>
>>>>>>> chris
>>>>>>>
>>>>>> --
>>>>>>
>>>>>> 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
>>>
>>
>> --
>>
>> 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
Previous Topic:[Teneo] single ref table for many-to-many
Next Topic:[Teneo] Incremental initialize capability in Teneo
Goto Forum:
  


Current Time: Thu Mar 28 10:07:23 GMT 2024

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

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

Back to the top