Home » Modeling » EMF "Technology" (Ecore Tools, EMFatic, etc) » [Teneo] Unexpected repeated column error
[Teneo] Unexpected repeated column error [message #122399] |
Tue, 13 May 2008 22:36 |
David Wynter Messages: 4624 Registered: July 2009 |
Senior Member |
|
|
Hi,
I am getting and error I cannot see an obvious cause for .
Based on the ecore generated from this
<xsd:complexType name="StatusChangeSubclass">
<xsd:sequence>
<xsd:element minOccurs="0" maxOccurs="1" ref="gensec:meetingType" />
<xsd:element minOccurs="0" maxOccurs="1" ref="gensec:agent" />
<xsd:element minOccurs="0" maxOccurs="1"
ref="gensec:caeLifecycleType" />
<xsd:element minOccurs="0" maxOccurs="1"
ref="gensec:caeStatusType" />
<xsd:element ref="gensec:caeType" />
<xsd:element minOccurs="0" maxOccurs="1"
ref="gensec:entityIdentifier" />
<xsd:element minOccurs="0" maxOccurs="1"
ref="gensec:indicatorsType" />
<xsd:element minOccurs="0" maxOccurs="1"
ref="gensec:instrumentIdentifier" />
<xsd:element minOccurs="0" maxOccurs="1" ref="gensec:issuerRef" />
<xsd:element minOccurs="0" maxOccurs="1"
ref="gensec:dataValueChange" />
<xsd:element minOccurs="0" maxOccurs="1" ref="gensec:source" />
<xsd:element minOccurs="0" maxOccurs="1" ref="gensec:relatedTo" />
</xsd:sequence>
<xsd:attribute name="id" type="xsd:int" use="optional" />
<xsd:attribute name="effectiveDate" type="xsd:dateTime"
use="optional" />
<xsd:attribute name="announcementDate" type="xsd:dateTime"
use="optional" />
<xsd:attribute name="meetingDate" type="xsd:dateTime" use="optional" />
<xsd:attribute name="recordDate" type="xsd:dateTime" use="optional" />
<xsd:attribute name="comment" type="xsd:string" use="optional" />
<xsd:attribute name="documentURL" type="xsd:anyURI" use="optional" />
<xsd:attribute name="caeIdentifier" type="xsd:string" use="optional" />
<xsd:attribute name="eventDescription" type="xsd:string"
use="optional" />
<xsd:attribute name="caeDate" type="xsd:dateTime" use="optional" />
</xsd:complexType>
I am using
props.setProperty(PersistenceOptions.MAXIMUM_SQL_NAME_LENGTH ,
"30");
props.setProperty(PersistenceOptions.JOIN_COLUMN_NAMING_STRA TEGY, "simple");
props.setProperty(PersistenceOptions.ID_COLUMN_NAME, "id");
props.setProperty(PersistenceOptions.ID_FEATURE_AS_PRIMARY_K EY,
"false");
props.setProperty(PersistenceOptions.ALSO_MAP_AS_CLASS, "false");
props.setProperty(PersistenceOptions.DEFAULT_TEMPORAL_VALUE,
"DATE");
props.setProperty(PersistenceOptions.DISABLE_ECONTAINER_MAPP ING, "true");
props.setProperty(PersistenceOptions.ALWAYS_VERSION, "false");
props.setProperty(PersistenceOptions.ALWAYS_MAP_LIST_AS_BAG,
"true");
props.setProperty(PersistenceOptions.INHERITANCE_MAPPING,
"JOINED");
The ID_COLUMN_NAME option I read as meaning it recognises the model
attribute with the name of "id" as the primary key
There is only one id attribute, also in the ecore, so how come I get the
following error?
I use Eclise 3.3, JDK 5 and Teneo from the 23rd April
Exception in thread "main" org.hibernate.MappingException: Repeated
column in mapping for entity: StatusChangeSubclass column: id (should be
mapped with insert="false" update="false")
at
org.hibernate.mapping.PersistentClass.checkColumnDuplication (PersistentClass.java:652)
at
org.hibernate.mapping.PersistentClass.checkPropertyColumnDup lication(PersistentClass.java:674)
Thx.
David
|
|
|
Re: [Teneo] Unexpected repeated column error [message #122492 is a reply to message #122399] |
Wed, 14 May 2008 10:58 |
Martin Taal Messages: 5468 Registered: July 2009 |
Senior Member |
|
|
Hi David,
This occurs because the type has an id attribute and you set the PersistenceOptions.ID_COLUMN_NAME
option to id. The PersistenceOptions.ID_COLUMN_NAME option is used to set the synthetic id column.
The synthetic id is created if the type does not have an explicit id column. So what happens is that
you have an id-attribute (which gets a column id) and because there is no explicit id for the type a
synthetic id is created (which also gets column id).
In your case you should annotate the id-feature with a @Id annotation as you want to use that
feature as the id (afaics).
gr. Marrtin
david wrote:
> Hi,
>
> I am getting and error I cannot see an obvious cause for .
>
> Based on the ecore generated from this
>
> <xsd:complexType name="StatusChangeSubclass">
> <xsd:sequence>
> <xsd:element minOccurs="0" maxOccurs="1" ref="gensec:meetingType" />
> <xsd:element minOccurs="0" maxOccurs="1" ref="gensec:agent" />
> <xsd:element minOccurs="0" maxOccurs="1"
> ref="gensec:caeLifecycleType" />
> <xsd:element minOccurs="0" maxOccurs="1"
> ref="gensec:caeStatusType" />
> <xsd:element ref="gensec:caeType" />
> <xsd:element minOccurs="0" maxOccurs="1"
> ref="gensec:entityIdentifier" />
> <xsd:element minOccurs="0" maxOccurs="1"
> ref="gensec:indicatorsType" />
> <xsd:element minOccurs="0" maxOccurs="1"
> ref="gensec:instrumentIdentifier" />
> <xsd:element minOccurs="0" maxOccurs="1" ref="gensec:issuerRef" />
> <xsd:element minOccurs="0" maxOccurs="1"
> ref="gensec:dataValueChange" />
> <xsd:element minOccurs="0" maxOccurs="1" ref="gensec:source" />
> <xsd:element minOccurs="0" maxOccurs="1" ref="gensec:relatedTo" />
> </xsd:sequence>
> <xsd:attribute name="id" type="xsd:int" use="optional" />
> <xsd:attribute name="effectiveDate" type="xsd:dateTime"
> use="optional" />
> <xsd:attribute name="announcementDate" type="xsd:dateTime"
> use="optional" />
> <xsd:attribute name="meetingDate" type="xsd:dateTime" use="optional" />
> <xsd:attribute name="recordDate" type="xsd:dateTime" use="optional" />
> <xsd:attribute name="comment" type="xsd:string" use="optional" />
> <xsd:attribute name="documentURL" type="xsd:anyURI" use="optional" />
> <xsd:attribute name="caeIdentifier" type="xsd:string" use="optional" />
> <xsd:attribute name="eventDescription" type="xsd:string"
> use="optional" />
> <xsd:attribute name="caeDate" type="xsd:dateTime" use="optional" />
> </xsd:complexType>
>
> I am using
>
> props.setProperty(PersistenceOptions.MAXIMUM_SQL_NAME_LENGTH ,
> "30");
>
> props.setProperty(PersistenceOptions.JOIN_COLUMN_NAMING_STRA TEGY,
> "simple");
> props.setProperty(PersistenceOptions.ID_COLUMN_NAME, "id");
> props.setProperty(PersistenceOptions.ID_FEATURE_AS_PRIMARY_K EY,
> "false");
> props.setProperty(PersistenceOptions.ALSO_MAP_AS_CLASS, "false");
> props.setProperty(PersistenceOptions.DEFAULT_TEMPORAL_VALUE,
> "DATE");
>
> props.setProperty(PersistenceOptions.DISABLE_ECONTAINER_MAPP ING, "true");
> props.setProperty(PersistenceOptions.ALWAYS_VERSION, "false");
> props.setProperty(PersistenceOptions.ALWAYS_MAP_LIST_AS_BAG,
> "true");
> props.setProperty(PersistenceOptions.INHERITANCE_MAPPING,
> "JOINED");
>
> The ID_COLUMN_NAME option I read as meaning it recognises the model
> attribute with the name of "id" as the primary key
>
> There is only one id attribute, also in the ecore, so how come I get the
> following error?
>
> I use Eclise 3.3, JDK 5 and Teneo from the 23rd April
>
> Exception in thread "main" org.hibernate.MappingException: Repeated
> column in mapping for entity: StatusChangeSubclass column: id (should be
> mapped with insert="false" update="false")
> at
> org.hibernate.mapping.PersistentClass.checkColumnDuplication (PersistentClass.java:652)
>
> at
> org.hibernate.mapping.PersistentClass.checkPropertyColumnDup lication(PersistentClass.java:674)
>
>
> Thx.
>
> David
--
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] Unexpected repeated column error [message #122547 is a reply to message #122492] |
Fri, 16 May 2008 13:14 |
David Wynter Messages: 4624 Registered: July 2009 |
Senior Member |
|
|
Hi,
I have been sifting through the elver website and cannot find the
documentation on the specific @Id annotation. I checked the EJV
Persistance document too, but it had Java annotations for the @Id. It is
not clear to me how you add the @Id annotation to an attribute within
the element in the xsd. Can you show me an example?
Also adding this
props.setProperty(PersistenceOptions.DEFAULT_ID_FEATURE_NAME , "id");
Shouldn't that cause Teneo to recognisedall features named 'id' as the
primary key?
<xsd:complexType name="StatusChangeSubclass">
<xsd:sequence>
<xsd:element minOccurs="0" maxOccurs="1"
ref="gensec:meetingType" />
<xsd:element minOccurs="0" maxOccurs="1" ref="gensec:agent" />
<xsd:element minOccurs="0" maxOccurs="1"
ref="gensec:caeLifecycleType" />
<xsd:element minOccurs="0" maxOccurs="1"
ref="gensec:caeStatusType" />
<xsd:element ref="gensec:caeType" />
<xsd:element minOccurs="0" maxOccurs="1"
ref="gensec:entityIdentifier" />
<xsd:element minOccurs="0" maxOccurs="1"
ref="gensec:indicatorsType" />
<xsd:element minOccurs="0" maxOccurs="1"
ref="gensec:instrumentIdentifier" />
<xsd:element minOccurs="0" maxOccurs="1" ref="gensec:issuerRef" />
<xsd:element minOccurs="0" maxOccurs="1"
ref="gensec:dataValueChange" />
<xsd:element minOccurs="0" maxOccurs="1" ref="gensec:source" />
<xsd:element minOccurs="0" maxOccurs="1" ref="gensec:relatedTo" />
</xsd:sequence>
<xsd:attribute name="id" type="xsd:int" use="optional" />
<xsd:attribute name="effectiveDate" type="xsd:dateTime"
use="optional" />
<xsd:attribute name="announcementDate" type="xsd:dateTime"
use="optional" />
<xsd:attribute name="meetingDate" type="xsd:dateTime"
use="optional" />
<xsd:attribute name="recordDate" type="xsd:dateTime"
use="optional" />
<xsd:attribute name="comment" type="xsd:string" use="optional" />
<xsd:attribute name="documentURL" type="xsd:anyURI" use="optional" />
<xsd:attribute name="caeIdentifier" type="xsd:string"
use="optional" />
<xsd:attribute name="eventDescription" type="xsd:string"
use="optional" />
<xsd:attribute name="caeDate" type="xsd:dateTime" use="optional" />
</xsd:complexType>
Thanks,
David
Martin Taal wrote:
> Hi David,
> This occurs because the type has an id attribute and you set the
> PersistenceOptions.ID_COLUMN_NAME option to id. The
> PersistenceOptions.ID_COLUMN_NAME option is used to set the synthetic id
> column. The synthetic id is created if the type does not have an
> explicit id column. So what happens is that you have an id-attribute
> (which gets a column id) and because there is no explicit id for the
> type a synthetic id is created (which also gets column id).
>
> In your case you should annotate the id-feature with a @Id annotation as
> you want to use that feature as the id (afaics).
>
> gr. Marrtin
>
> david wrote:
>> Hi,
>>
>> I am getting and error I cannot see an obvious cause for .
>>
>> Based on the ecore generated from this
>>
>> <xsd:complexType name="StatusChangeSubclass">
>> <xsd:sequence>
>> <xsd:element minOccurs="0" maxOccurs="1"
>> ref="gensec:meetingType" />
>> <xsd:element minOccurs="0" maxOccurs="1" ref="gensec:agent" />
>> <xsd:element minOccurs="0" maxOccurs="1"
>> ref="gensec:caeLifecycleType" />
>> <xsd:element minOccurs="0" maxOccurs="1"
>> ref="gensec:caeStatusType" />
>> <xsd:element ref="gensec:caeType" />
>> <xsd:element minOccurs="0" maxOccurs="1"
>> ref="gensec:entityIdentifier" />
>> <xsd:element minOccurs="0" maxOccurs="1"
>> ref="gensec:indicatorsType" />
>> <xsd:element minOccurs="0" maxOccurs="1"
>> ref="gensec:instrumentIdentifier" />
>> <xsd:element minOccurs="0" maxOccurs="1" ref="gensec:issuerRef" />
>> <xsd:element minOccurs="0" maxOccurs="1"
>> ref="gensec:dataValueChange" />
>> <xsd:element minOccurs="0" maxOccurs="1" ref="gensec:source" />
>> <xsd:element minOccurs="0" maxOccurs="1" ref="gensec:relatedTo" />
>> </xsd:sequence>
>> <xsd:attribute name="id" type="xsd:int" use="optional" />
>> <xsd:attribute name="effectiveDate" type="xsd:dateTime"
>> use="optional" />
>> <xsd:attribute name="announcementDate" type="xsd:dateTime"
>> use="optional" />
>> <xsd:attribute name="meetingDate" type="xsd:dateTime"
>> use="optional" />
>> <xsd:attribute name="recordDate" type="xsd:dateTime"
>> use="optional" />
>> <xsd:attribute name="comment" type="xsd:string" use="optional" />
>> <xsd:attribute name="documentURL" type="xsd:anyURI" use="optional" />
>> <xsd:attribute name="caeIdentifier" type="xsd:string"
>> use="optional" />
>> <xsd:attribute name="eventDescription" type="xsd:string"
>> use="optional" />
>> <xsd:attribute name="caeDate" type="xsd:dateTime" use="optional" />
>> </xsd:complexType>
>>
>> I am using
>>
>> props.setProperty(PersistenceOptions.MAXIMUM_SQL_NAME_LENGTH ,
>> "30");
>>
>> props.setProperty(PersistenceOptions.JOIN_COLUMN_NAMING_STRA TEGY,
>> "simple");
>> props.setProperty(PersistenceOptions.ID_COLUMN_NAME, "id");
>>
>> props.setProperty(PersistenceOptions.ID_FEATURE_AS_PRIMARY_K EY, "false");
>> props.setProperty(PersistenceOptions.ALSO_MAP_AS_CLASS, "false");
>> props.setProperty(PersistenceOptions.DEFAULT_TEMPORAL_VALUE,
>> "DATE");
>>
>> props.setProperty(PersistenceOptions.DISABLE_ECONTAINER_MAPP ING, "true");
>> props.setProperty(PersistenceOptions.ALWAYS_VERSION, "false");
>> props.setProperty(PersistenceOptions.ALWAYS_MAP_LIST_AS_BAG,
>> "true");
>> props.setProperty(PersistenceOptions.INHERITANCE_MAPPING,
>> "JOINED");
>>
>> The ID_COLUMN_NAME option I read as meaning it recognises the model
>> attribute with the name of "id" as the primary key
>>
>> There is only one id attribute, also in the ecore, so how come I get
>> the following error?
>>
>> I use Eclise 3.3, JDK 5 and Teneo from the 23rd April
>>
>> Exception in thread "main" org.hibernate.MappingException: Repeated
>> column in mapping for entity: StatusChangeSubclass column: id (should
>> be mapped with insert="false" update="false")
>> at
>> org.hibernate.mapping.PersistentClass.checkColumnDuplication (PersistentClass.java:652)
>>
>> at
>> org.hibernate.mapping.PersistentClass.checkPropertyColumnDup lication(PersistentClass.java:674)
>>
>>
>> Thx.
>>
>> David
>
>
|
|
|
Re: [Teneo] Unexpected repeated column error [message #122556 is a reply to message #122547] |
Fri, 16 May 2008 13:59 |
Martin Taal Messages: 5468 Registered: July 2009 |
Senior Member |
|
|
Hi David,
Yes you are right the DEFAULT_ID_FEATURE_NAME option should also work (forgot that one). You then
don't need the @Id annotation or the ID_COLUMN_NAME option.
The @Id is a standard jpa annotation. Here are some examples to define annotations in xml schema:
http://www.elver.org/hibernate/ejb3_examples.html#schemasamp les
gr. Martin
david wrote:
> Hi,
>
> I have been sifting through the elver website and cannot find the
> documentation on the specific @Id annotation. I checked the EJV
> Persistance document too, but it had Java annotations for the @Id. It is
> not clear to me how you add the @Id annotation to an attribute within
> the element in the xsd. Can you show me an example?
>
> Also adding this
> props.setProperty(PersistenceOptions.DEFAULT_ID_FEATURE_NAME , "id");
>
> Shouldn't that cause Teneo to recognisedall features named 'id' as the
> primary key?
>
>
> <xsd:complexType name="StatusChangeSubclass">
> <xsd:sequence>
> <xsd:element minOccurs="0" maxOccurs="1"
> ref="gensec:meetingType" />
> <xsd:element minOccurs="0" maxOccurs="1" ref="gensec:agent" />
> <xsd:element minOccurs="0" maxOccurs="1"
> ref="gensec:caeLifecycleType" />
> <xsd:element minOccurs="0" maxOccurs="1"
> ref="gensec:caeStatusType" />
> <xsd:element ref="gensec:caeType" />
> <xsd:element minOccurs="0" maxOccurs="1"
> ref="gensec:entityIdentifier" />
> <xsd:element minOccurs="0" maxOccurs="1"
> ref="gensec:indicatorsType" />
> <xsd:element minOccurs="0" maxOccurs="1"
> ref="gensec:instrumentIdentifier" />
> <xsd:element minOccurs="0" maxOccurs="1" ref="gensec:issuerRef" />
> <xsd:element minOccurs="0" maxOccurs="1"
> ref="gensec:dataValueChange" />
> <xsd:element minOccurs="0" maxOccurs="1" ref="gensec:source" />
> <xsd:element minOccurs="0" maxOccurs="1" ref="gensec:relatedTo" />
> </xsd:sequence>
> <xsd:attribute name="id" type="xsd:int" use="optional" />
> <xsd:attribute name="effectiveDate" type="xsd:dateTime"
> use="optional" />
> <xsd:attribute name="announcementDate" type="xsd:dateTime"
> use="optional" />
> <xsd:attribute name="meetingDate" type="xsd:dateTime"
> use="optional" />
> <xsd:attribute name="recordDate" type="xsd:dateTime"
> use="optional" />
> <xsd:attribute name="comment" type="xsd:string" use="optional" />
> <xsd:attribute name="documentURL" type="xsd:anyURI" use="optional" />
> <xsd:attribute name="caeIdentifier" type="xsd:string"
> use="optional" />
> <xsd:attribute name="eventDescription" type="xsd:string"
> use="optional" />
> <xsd:attribute name="caeDate" type="xsd:dateTime" use="optional" />
> </xsd:complexType>
>
>
> Thanks,
>
> David
>
> Martin Taal wrote:
>> Hi David,
>> This occurs because the type has an id attribute and you set the
>> PersistenceOptions.ID_COLUMN_NAME option to id. The
>> PersistenceOptions.ID_COLUMN_NAME option is used to set the synthetic
>> id column. The synthetic id is created if the type does not have an
>> explicit id column. So what happens is that you have an id-attribute
>> (which gets a column id) and because there is no explicit id for the
>> type a synthetic id is created (which also gets column id).
>>
>> In your case you should annotate the id-feature with a @Id annotation
>> as you want to use that feature as the id (afaics).
>>
>> gr. Marrtin
>>
>> david wrote:
>>> Hi,
>>>
>>> I am getting and error I cannot see an obvious cause for .
>>>
>>> Based on the ecore generated from this
>>>
>>> <xsd:complexType name="StatusChangeSubclass">
>>> <xsd:sequence>
>>> <xsd:element minOccurs="0" maxOccurs="1"
>>> ref="gensec:meetingType" />
>>> <xsd:element minOccurs="0" maxOccurs="1" ref="gensec:agent" />
>>> <xsd:element minOccurs="0" maxOccurs="1"
>>> ref="gensec:caeLifecycleType" />
>>> <xsd:element minOccurs="0" maxOccurs="1"
>>> ref="gensec:caeStatusType" />
>>> <xsd:element ref="gensec:caeType" />
>>> <xsd:element minOccurs="0" maxOccurs="1"
>>> ref="gensec:entityIdentifier" />
>>> <xsd:element minOccurs="0" maxOccurs="1"
>>> ref="gensec:indicatorsType" />
>>> <xsd:element minOccurs="0" maxOccurs="1"
>>> ref="gensec:instrumentIdentifier" />
>>> <xsd:element minOccurs="0" maxOccurs="1" ref="gensec:issuerRef" />
>>> <xsd:element minOccurs="0" maxOccurs="1"
>>> ref="gensec:dataValueChange" />
>>> <xsd:element minOccurs="0" maxOccurs="1" ref="gensec:source" />
>>> <xsd:element minOccurs="0" maxOccurs="1" ref="gensec:relatedTo" />
>>> </xsd:sequence>
>>> <xsd:attribute name="id" type="xsd:int" use="optional" />
>>> <xsd:attribute name="effectiveDate" type="xsd:dateTime"
>>> use="optional" />
>>> <xsd:attribute name="announcementDate" type="xsd:dateTime"
>>> use="optional" />
>>> <xsd:attribute name="meetingDate" type="xsd:dateTime"
>>> use="optional" />
>>> <xsd:attribute name="recordDate" type="xsd:dateTime"
>>> use="optional" />
>>> <xsd:attribute name="comment" type="xsd:string" use="optional" />
>>> <xsd:attribute name="documentURL" type="xsd:anyURI"
>>> use="optional" />
>>> <xsd:attribute name="caeIdentifier" type="xsd:string"
>>> use="optional" />
>>> <xsd:attribute name="eventDescription" type="xsd:string"
>>> use="optional" />
>>> <xsd:attribute name="caeDate" type="xsd:dateTime" use="optional" />
>>> </xsd:complexType>
>>>
>>> I am using
>>>
>>> props.setProperty(PersistenceOptions.MAXIMUM_SQL_NAME_LENGTH ,
>>> "30");
>>>
>>> props.setProperty(PersistenceOptions.JOIN_COLUMN_NAMING_STRA TEGY,
>>> "simple");
>>> props.setProperty(PersistenceOptions.ID_COLUMN_NAME, "id");
>>>
>>> props.setProperty(PersistenceOptions.ID_FEATURE_AS_PRIMARY_K EY,
>>> "false");
>>> props.setProperty(PersistenceOptions.ALSO_MAP_AS_CLASS,
>>> "false");
>>> props.setProperty(PersistenceOptions.DEFAULT_TEMPORAL_VALUE,
>>> "DATE");
>>>
>>> props.setProperty(PersistenceOptions.DISABLE_ECONTAINER_MAPP ING,
>>> "true");
>>> props.setProperty(PersistenceOptions.ALWAYS_VERSION, "false");
>>> props.setProperty(PersistenceOptions.ALWAYS_MAP_LIST_AS_BAG,
>>> "true");
>>> props.setProperty(PersistenceOptions.INHERITANCE_MAPPING,
>>> "JOINED");
>>>
>>> The ID_COLUMN_NAME option I read as meaning it recognises the model
>>> attribute with the name of "id" as the primary key
>>>
>>> There is only one id attribute, also in the ecore, so how come I get
>>> the following error?
>>>
>>> I use Eclise 3.3, JDK 5 and Teneo from the 23rd April
>>>
>>> Exception in thread "main" org.hibernate.MappingException: Repeated
>>> column in mapping for entity: StatusChangeSubclass column: id (should
>>> be mapped with insert="false" update="false")
>>> at
>>> org.hibernate.mapping.PersistentClass.checkColumnDuplication (PersistentClass.java:652)
>>>
>>> at
>>> org.hibernate.mapping.PersistentClass.checkPropertyColumnDup lication(PersistentClass.java:674)
>>>
>>>
>>> Thx.
>>>
>>> David
>>
>>
--
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] Unexpected repeated column error [message #122570 is a reply to message #122556] |
Fri, 16 May 2008 14:40 |
David Wynter Messages: 4624 Registered: July 2009 |
Senior Member |
|
|
Hi,
I ended up deleting the Id columns out of the xsd, and using the
props.setProperty(PersistenceOptions.ID_COLUMN_NAME, "id");
props.setProperty(PersistenceOptions.DEFAULT_ID_FEATURE_NAME ,
"id");
But to confirm would the annotation look like this
<xsd:complexType name="StatusChangeSubclass">
<xsd:sequence>
<xsd:annotation>
<xsd:appinfo source="teneo.jpa">
@Id(name="Id")
</xsd:appinfo>
</xsd:annotation>
....
I could not find an explicit example amongst the samples on that page.
Thx,
David
Martin Taal wrote:
> Hi David,
> Yes you are right the DEFAULT_ID_FEATURE_NAME option should also work
> (forgot that one). You then don't need the @Id annotation or the
> ID_COLUMN_NAME option.
>
> The @Id is a standard jpa annotation. Here are some examples to define
> annotations in xml schema:
> http://www.elver.org/hibernate/ejb3_examples.html#schemasamp les
>
> gr. Martin
>
> david wrote:
>> Hi,
>>
>> I have been sifting through the elver website and cannot find the
>> documentation on the specific @Id annotation. I checked the EJV
>> Persistance document too, but it had Java annotations for the @Id. It
>> is not clear to me how you add the @Id annotation to an attribute
>> within the element in the xsd. Can you show me an example?
>>
>> Also adding this
>> props.setProperty(PersistenceOptions.DEFAULT_ID_FEATURE_NAME , "id");
>>
>> Shouldn't that cause Teneo to recognisedall features named 'id' as the
>> primary key?
>>
>>
>> <xsd:complexType name="StatusChangeSubclass">
>> <xsd:sequence>
>> <xsd:element minOccurs="0" maxOccurs="1"
>> ref="gensec:meetingType" />
>> <xsd:element minOccurs="0" maxOccurs="1" ref="gensec:agent" />
>> <xsd:element minOccurs="0" maxOccurs="1"
>> ref="gensec:caeLifecycleType" />
>> <xsd:element minOccurs="0" maxOccurs="1"
>> ref="gensec:caeStatusType" />
>> <xsd:element ref="gensec:caeType" />
>> <xsd:element minOccurs="0" maxOccurs="1"
>> ref="gensec:entityIdentifier" />
>> <xsd:element minOccurs="0" maxOccurs="1"
>> ref="gensec:indicatorsType" />
>> <xsd:element minOccurs="0" maxOccurs="1"
>> ref="gensec:instrumentIdentifier" />
>> <xsd:element minOccurs="0" maxOccurs="1" ref="gensec:issuerRef" />
>> <xsd:element minOccurs="0" maxOccurs="1"
>> ref="gensec:dataValueChange" />
>> <xsd:element minOccurs="0" maxOccurs="1" ref="gensec:source" />
>> <xsd:element minOccurs="0" maxOccurs="1" ref="gensec:relatedTo" />
>> </xsd:sequence>
>> <xsd:attribute name="id" type="xsd:int" use="optional" />
>> <xsd:attribute name="effectiveDate" type="xsd:dateTime"
>> use="optional" />
>> <xsd:attribute name="announcementDate" type="xsd:dateTime"
>> use="optional" />
>> <xsd:attribute name="meetingDate" type="xsd:dateTime"
>> use="optional" />
>> <xsd:attribute name="recordDate" type="xsd:dateTime"
>> use="optional" />
>> <xsd:attribute name="comment" type="xsd:string" use="optional" />
>> <xsd:attribute name="documentURL" type="xsd:anyURI"
>> use="optional" />
>> <xsd:attribute name="caeIdentifier" type="xsd:string"
>> use="optional" />
>> <xsd:attribute name="eventDescription" type="xsd:string"
>> use="optional" />
>> <xsd:attribute name="caeDate" type="xsd:dateTime" use="optional" />
>> </xsd:complexType>
>>
>>
>> Thanks,
>>
>> David
>>
>> Martin Taal wrote:
>>> Hi David,
>>> This occurs because the type has an id attribute and you set the
>>> PersistenceOptions.ID_COLUMN_NAME option to id. The
>>> PersistenceOptions.ID_COLUMN_NAME option is used to set the synthetic
>>> id column. The synthetic id is created if the type does not have an
>>> explicit id column. So what happens is that you have an id-attribute
>>> (which gets a column id) and because there is no explicit id for the
>>> type a synthetic id is created (which also gets column id).
>>>
>>> In your case you should annotate the id-feature with a @Id annotation
>>> as you want to use that feature as the id (afaics).
>>>
>>> gr. Marrtin
>>>
>>> david wrote:
>>>> Hi,
>>>>
>>>> I am getting and error I cannot see an obvious cause for .
>>>>
>>>> Based on the ecore generated from this
>>>>
>>>> <xsd:complexType name="StatusChangeSubclass">
>>>> <xsd:sequence>
>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>> ref="gensec:meetingType" />
>>>> <xsd:element minOccurs="0" maxOccurs="1" ref="gensec:agent" />
>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>> ref="gensec:caeLifecycleType" />
>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>> ref="gensec:caeStatusType" />
>>>> <xsd:element ref="gensec:caeType" />
>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>> ref="gensec:entityIdentifier" />
>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>> ref="gensec:indicatorsType" />
>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>> ref="gensec:instrumentIdentifier" />
>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>> ref="gensec:issuerRef" />
>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>> ref="gensec:dataValueChange" />
>>>> <xsd:element minOccurs="0" maxOccurs="1" ref="gensec:source" />
>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>> ref="gensec:relatedTo" />
>>>> </xsd:sequence>
>>>> <xsd:attribute name="id" type="xsd:int" use="optional" />
>>>> <xsd:attribute name="effectiveDate" type="xsd:dateTime"
>>>> use="optional" />
>>>> <xsd:attribute name="announcementDate" type="xsd:dateTime"
>>>> use="optional" />
>>>> <xsd:attribute name="meetingDate" type="xsd:dateTime"
>>>> use="optional" />
>>>> <xsd:attribute name="recordDate" type="xsd:dateTime"
>>>> use="optional" />
>>>> <xsd:attribute name="comment" type="xsd:string" use="optional" />
>>>> <xsd:attribute name="documentURL" type="xsd:anyURI"
>>>> use="optional" />
>>>> <xsd:attribute name="caeIdentifier" type="xsd:string"
>>>> use="optional" />
>>>> <xsd:attribute name="eventDescription" type="xsd:string"
>>>> use="optional" />
>>>> <xsd:attribute name="caeDate" type="xsd:dateTime" use="optional" />
>>>> </xsd:complexType>
>>>>
>>>> I am using
>>>>
>>>>
>>>> props.setProperty(PersistenceOptions.MAXIMUM_SQL_NAME_LENGTH , "30");
>>>>
>>>> props.setProperty(PersistenceOptions.JOIN_COLUMN_NAMING_STRA TEGY,
>>>> "simple");
>>>> props.setProperty(PersistenceOptions.ID_COLUMN_NAME, "id");
>>>>
>>>> props.setProperty(PersistenceOptions.ID_FEATURE_AS_PRIMARY_K EY,
>>>> "false");
>>>> props.setProperty(PersistenceOptions.ALSO_MAP_AS_CLASS,
>>>> "false");
>>>> props.setProperty(PersistenceOptions.DEFAULT_TEMPORAL_VALUE,
>>>> "DATE");
>>>>
>>>> props.setProperty(PersistenceOptions.DISABLE_ECONTAINER_MAPP ING,
>>>> "true");
>>>> props.setProperty(PersistenceOptions.ALWAYS_VERSION, "false");
>>>> props.setProperty(PersistenceOptions.ALWAYS_MAP_LIST_AS_BAG,
>>>> "true");
>>>> props.setProperty(PersistenceOptions.INHERITANCE_MAPPING,
>>>> "JOINED");
>>>>
>>>> The ID_COLUMN_NAME option I read as meaning it recognises the model
>>>> attribute with the name of "id" as the primary key
>>>>
>>>> There is only one id attribute, also in the ecore, so how come I get
>>>> the following error?
>>>>
>>>> I use Eclise 3.3, JDK 5 and Teneo from the 23rd April
>>>>
>>>> Exception in thread "main" org.hibernate.MappingException: Repeated
>>>> column in mapping for entity: StatusChangeSubclass column: id
>>>> (should be mapped with insert="false" update="false")
>>>> at
>>>> org.hibernate.mapping.PersistentClass.checkColumnDuplication (PersistentClass.java:652)
>>>>
>>>> at
>>>> org.hibernate.mapping.PersistentClass.checkPropertyColumnDup lication(PersistentClass.java:674)
>>>>
>>>>
>>>> Thx.
>>>>
>>>> David
>>>
>>>
>
>
|
|
|
Re: [Teneo] Unexpected repeated column error [message #122579 is a reply to message #122570] |
Fri, 16 May 2008 14:52 |
Martin Taal Messages: 5468 Registered: July 2009 |
Senior Member |
|
|
Hi David,
I don't think that you need to delete the id element from the xsd
There are many examples here, did you find it?
http://www.elver.org/hibernate/ejb3_examples.html
The id annotation in xml schema will be something like this:
<xsd:element name="id" type="xsd:long">
<xsd:annotation>
<xsd:appinfo source="teneo.jpa">@Id</xsd:appinfo>
</xsd:annotation>
</xsd:element>
You can check the jpa spec for the syntax of the annotations.
or instead of setting the annotation in the xml schema then having the id element/attribute and set
the option: props.setProperty(PersistenceOptions.DEFAULT_ID_FEATURE_NAME , "id")
should work.
gr. Martin
david wrote:
> Hi,
>
> I ended up deleting the Id columns out of the xsd, and using the
>
> props.setProperty(PersistenceOptions.ID_COLUMN_NAME, "id");
> props.setProperty(PersistenceOptions.DEFAULT_ID_FEATURE_NAME ,
> "id");
>
>
> But to confirm would the annotation look like this
>
> <xsd:complexType name="StatusChangeSubclass">
> <xsd:sequence>
> <xsd:annotation>
> <xsd:appinfo source="teneo.jpa">
> @Id(name="Id")
> </xsd:appinfo>
> </xsd:annotation>
> ....
>
> I could not find an explicit example amongst the samples on that page.
>
> Thx,
>
> David
>
>
> Martin Taal wrote:
>> Hi David,
>> Yes you are right the DEFAULT_ID_FEATURE_NAME option should also work
>> (forgot that one). You then don't need the @Id annotation or the
>> ID_COLUMN_NAME option.
>>
>> The @Id is a standard jpa annotation. Here are some examples to define
>> annotations in xml schema:
>> http://www.elver.org/hibernate/ejb3_examples.html#schemasamp les
>>
>> gr. Martin
>>
>> david wrote:
>>> Hi,
>>>
>>> I have been sifting through the elver website and cannot find the
>>> documentation on the specific @Id annotation. I checked the EJV
>>> Persistance document too, but it had Java annotations for the @Id. It
>>> is not clear to me how you add the @Id annotation to an attribute
>>> within the element in the xsd. Can you show me an example?
>>>
>>> Also adding this
>>> props.setProperty(PersistenceOptions.DEFAULT_ID_FEATURE_NAME , "id");
>>>
>>> Shouldn't that cause Teneo to recognisedall features named 'id' as
>>> the primary key?
>>>
>>>
>>> <xsd:complexType name="StatusChangeSubclass">
>>> <xsd:sequence>
>>> <xsd:element minOccurs="0" maxOccurs="1"
>>> ref="gensec:meetingType" />
>>> <xsd:element minOccurs="0" maxOccurs="1" ref="gensec:agent" />
>>> <xsd:element minOccurs="0" maxOccurs="1"
>>> ref="gensec:caeLifecycleType" />
>>> <xsd:element minOccurs="0" maxOccurs="1"
>>> ref="gensec:caeStatusType" />
>>> <xsd:element ref="gensec:caeType" />
>>> <xsd:element minOccurs="0" maxOccurs="1"
>>> ref="gensec:entityIdentifier" />
>>> <xsd:element minOccurs="0" maxOccurs="1"
>>> ref="gensec:indicatorsType" />
>>> <xsd:element minOccurs="0" maxOccurs="1"
>>> ref="gensec:instrumentIdentifier" />
>>> <xsd:element minOccurs="0" maxOccurs="1"
>>> ref="gensec:issuerRef" />
>>> <xsd:element minOccurs="0" maxOccurs="1"
>>> ref="gensec:dataValueChange" />
>>> <xsd:element minOccurs="0" maxOccurs="1" ref="gensec:source" />
>>> <xsd:element minOccurs="0" maxOccurs="1"
>>> ref="gensec:relatedTo" />
>>> </xsd:sequence>
>>> <xsd:attribute name="id" type="xsd:int" use="optional" />
>>> <xsd:attribute name="effectiveDate" type="xsd:dateTime"
>>> use="optional" />
>>> <xsd:attribute name="announcementDate" type="xsd:dateTime"
>>> use="optional" />
>>> <xsd:attribute name="meetingDate" type="xsd:dateTime"
>>> use="optional" />
>>> <xsd:attribute name="recordDate" type="xsd:dateTime"
>>> use="optional" />
>>> <xsd:attribute name="comment" type="xsd:string" use="optional" />
>>> <xsd:attribute name="documentURL" type="xsd:anyURI"
>>> use="optional" />
>>> <xsd:attribute name="caeIdentifier" type="xsd:string"
>>> use="optional" />
>>> <xsd:attribute name="eventDescription" type="xsd:string"
>>> use="optional" />
>>> <xsd:attribute name="caeDate" type="xsd:dateTime" use="optional" />
>>> </xsd:complexType>
>>>
>>>
>>> Thanks,
>>>
>>> David
>>>
>>> Martin Taal wrote:
>>>> Hi David,
>>>> This occurs because the type has an id attribute and you set the
>>>> PersistenceOptions.ID_COLUMN_NAME option to id. The
>>>> PersistenceOptions.ID_COLUMN_NAME option is used to set the
>>>> synthetic id column. The synthetic id is created if the type does
>>>> not have an explicit id column. So what happens is that you have an
>>>> id-attribute (which gets a column id) and because there is no
>>>> explicit id for the type a synthetic id is created (which also gets
>>>> column id).
>>>>
>>>> In your case you should annotate the id-feature with a @Id
>>>> annotation as you want to use that feature as the id (afaics).
>>>>
>>>> gr. Marrtin
>>>>
>>>> david wrote:
>>>>> Hi,
>>>>>
>>>>> I am getting and error I cannot see an obvious cause for .
>>>>>
>>>>> Based on the ecore generated from this
>>>>>
>>>>> <xsd:complexType name="StatusChangeSubclass">
>>>>> <xsd:sequence>
>>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>>> ref="gensec:meetingType" />
>>>>> <xsd:element minOccurs="0" maxOccurs="1" ref="gensec:agent" />
>>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>>> ref="gensec:caeLifecycleType" />
>>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>>> ref="gensec:caeStatusType" />
>>>>> <xsd:element ref="gensec:caeType" />
>>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>>> ref="gensec:entityIdentifier" />
>>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>>> ref="gensec:indicatorsType" />
>>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>>> ref="gensec:instrumentIdentifier" />
>>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>>> ref="gensec:issuerRef" />
>>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>>> ref="gensec:dataValueChange" />
>>>>> <xsd:element minOccurs="0" maxOccurs="1" ref="gensec:source" />
>>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>>> ref="gensec:relatedTo" />
>>>>> </xsd:sequence>
>>>>> <xsd:attribute name="id" type="xsd:int" use="optional" />
>>>>> <xsd:attribute name="effectiveDate" type="xsd:dateTime"
>>>>> use="optional" />
>>>>> <xsd:attribute name="announcementDate" type="xsd:dateTime"
>>>>> use="optional" />
>>>>> <xsd:attribute name="meetingDate" type="xsd:dateTime"
>>>>> use="optional" />
>>>>> <xsd:attribute name="recordDate" type="xsd:dateTime"
>>>>> use="optional" />
>>>>> <xsd:attribute name="comment" type="xsd:string" use="optional" />
>>>>> <xsd:attribute name="documentURL" type="xsd:anyURI"
>>>>> use="optional" />
>>>>> <xsd:attribute name="caeIdentifier" type="xsd:string"
>>>>> use="optional" />
>>>>> <xsd:attribute name="eventDescription" type="xsd:string"
>>>>> use="optional" />
>>>>> <xsd:attribute name="caeDate" type="xsd:dateTime"
>>>>> use="optional" />
>>>>> </xsd:complexType>
>>>>>
>>>>> I am using
>>>>>
>>>>>
>>>>> props.setProperty(PersistenceOptions.MAXIMUM_SQL_NAME_LENGTH , "30");
>>>>>
>>>>> props.setProperty(PersistenceOptions.JOIN_COLUMN_NAMING_STRA TEGY,
>>>>> "simple");
>>>>> props.setProperty(PersistenceOptions.ID_COLUMN_NAME, "id");
>>>>>
>>>>> props.setProperty(PersistenceOptions.ID_FEATURE_AS_PRIMARY_K EY,
>>>>> "false");
>>>>> props.setProperty(PersistenceOptions.ALSO_MAP_AS_CLASS,
>>>>> "false");
>>>>>
>>>>> props.setProperty(PersistenceOptions.DEFAULT_TEMPORAL_VALUE, "DATE");
>>>>>
>>>>> props.setProperty(PersistenceOptions.DISABLE_ECONTAINER_MAPP ING,
>>>>> "true");
>>>>> props.setProperty(PersistenceOptions.ALWAYS_VERSION, "false");
>>>>>
>>>>> props.setProperty(PersistenceOptions.ALWAYS_MAP_LIST_AS_BAG, "true");
>>>>> props.setProperty(PersistenceOptions.INHERITANCE_MAPPING,
>>>>> "JOINED");
>>>>>
>>>>> The ID_COLUMN_NAME option I read as meaning it recognises the model
>>>>> attribute with the name of "id" as the primary key
>>>>>
>>>>> There is only one id attribute, also in the ecore, so how come I
>>>>> get the following error?
>>>>>
>>>>> I use Eclise 3.3, JDK 5 and Teneo from the 23rd April
>>>>>
>>>>> Exception in thread "main" org.hibernate.MappingException: Repeated
>>>>> column in mapping for entity: StatusChangeSubclass column: id
>>>>> (should be mapped with insert="false" update="false")
>>>>> at
>>>>> org.hibernate.mapping.PersistentClass.checkColumnDuplication (PersistentClass.java:652)
>>>>>
>>>>> at
>>>>> org.hibernate.mapping.PersistentClass.checkPropertyColumnDup lication(PersistentClass.java:674)
>>>>>
>>>>>
>>>>> Thx.
>>>>>
>>>>> David
>>>>
>>>>
>>
>>
--
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] Unexpected repeated column error [message #122597 is a reply to message #122579] |
Fri, 16 May 2008 16:57 |
David Wynter Messages: 4624 Registered: July 2009 |
Senior Member |
|
|
Hi,
This is were it gets confusing, as below I mentioned the id is actually
an attribute, not an element. Since the annotations are contained within
an element I was not sure if this same mechanism can be used for adding
annotations to attributes as opposed to elements as all the examples show.
Is this valid?
<xsd:attribute name="id" type="xsd:int">
<xsd:annotation>
<xsd:appinfo source="teneo.jpa">@Id</xsd:appinfo>
</xsd:annotation>
</xsd:attribute>
Thx.
David
Martin Taal wrote:
> Hi David,
> I don't think that you need to delete the id element from the xsd
>
> There are many examples here, did you find it?
> http://www.elver.org/hibernate/ejb3_examples.html
>
> The id annotation in xml schema will be something like this:
> <xsd:element name="id" type="xsd:long">
> <xsd:annotation>
> <xsd:appinfo source="teneo.jpa">@Id</xsd:appinfo>
> </xsd:annotation>
> </xsd:element>
>
> You can check the jpa spec for the syntax of the annotations.
>
> or instead of setting the annotation in the xml schema then having the
> id element/attribute and set the option:
> props.setProperty(PersistenceOptions.DEFAULT_ID_FEATURE_NAME , "id")
> should work.
>
> gr. Martin
>
> david wrote:
>> Hi,
>>
>> I ended up deleting the Id columns out of the xsd, and using the
>>
>> props.setProperty(PersistenceOptions.ID_COLUMN_NAME, "id");
>> props.setProperty(PersistenceOptions.DEFAULT_ID_FEATURE_NAME ,
>> "id");
>>
>>
>> But to confirm would the annotation look like this
>>
>> <xsd:complexType name="StatusChangeSubclass">
>> <xsd:sequence>
>> <xsd:annotation>
>> <xsd:appinfo source="teneo.jpa">
>> @Id(name="Id")
>> </xsd:appinfo>
>> </xsd:annotation>
>> ....
>>
>> I could not find an explicit example amongst the samples on that page.
>>
>> Thx,
>>
>> David
>>
>>
>> Martin Taal wrote:
>>> Hi David,
>>> Yes you are right the DEFAULT_ID_FEATURE_NAME option should also work
>>> (forgot that one). You then don't need the @Id annotation or the
>>> ID_COLUMN_NAME option.
>>>
>>> The @Id is a standard jpa annotation. Here are some examples to
>>> define annotations in xml schema:
>>> http://www.elver.org/hibernate/ejb3_examples.html#schemasamp les
>>>
>>> gr. Martin
>>>
>>> david wrote:
>>>> Hi,
>>>>
>>>> I have been sifting through the elver website and cannot find the
>>>> documentation on the specific @Id annotation. I checked the EJV
>>>> Persistance document too, but it had Java annotations for the @Id.
>>>> It is not clear to me how you add the @Id annotation to an attribute
>>>> within the element in the xsd. Can you show me an example?
>>>>
>>>> Also adding this
>>>> props.setProperty(PersistenceOptions.DEFAULT_ID_FEATURE_NAME , "id");
>>>>
>>>> Shouldn't that cause Teneo to recognisedall features named 'id' as
>>>> the primary key?
>>>>
>>>>
>>>> <xsd:complexType name="StatusChangeSubclass">
>>>> <xsd:sequence>
>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>> ref="gensec:meetingType" />
>>>> <xsd:element minOccurs="0" maxOccurs="1" ref="gensec:agent" />
>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>> ref="gensec:caeLifecycleType" />
>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>> ref="gensec:caeStatusType" />
>>>> <xsd:element ref="gensec:caeType" />
>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>> ref="gensec:entityIdentifier" />
>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>> ref="gensec:indicatorsType" />
>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>> ref="gensec:instrumentIdentifier" />
>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>> ref="gensec:issuerRef" />
>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>> ref="gensec:dataValueChange" />
>>>> <xsd:element minOccurs="0" maxOccurs="1" ref="gensec:source" />
>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>> ref="gensec:relatedTo" />
>>>> </xsd:sequence>
>>>> <xsd:attribute name="id" type="xsd:int" use="optional" />
>>>> <xsd:attribute name="effectiveDate" type="xsd:dateTime"
>>>> use="optional" />
>>>> <xsd:attribute name="announcementDate" type="xsd:dateTime"
>>>> use="optional" />
>>>> <xsd:attribute name="meetingDate" type="xsd:dateTime"
>>>> use="optional" />
>>>> <xsd:attribute name="recordDate" type="xsd:dateTime"
>>>> use="optional" />
>>>> <xsd:attribute name="comment" type="xsd:string" use="optional" />
>>>> <xsd:attribute name="documentURL" type="xsd:anyURI"
>>>> use="optional" />
>>>> <xsd:attribute name="caeIdentifier" type="xsd:string"
>>>> use="optional" />
>>>> <xsd:attribute name="eventDescription" type="xsd:string"
>>>> use="optional" />
>>>> <xsd:attribute name="caeDate" type="xsd:dateTime"
>>>> use="optional" />
>>>> </xsd:complexType>
>>>>
>>>>
>>>> Thanks,
>>>>
>>>> David
>>>>
>>>> Martin Taal wrote:
>>>>> Hi David,
>>>>> This occurs because the type has an id attribute and you set the
>>>>> PersistenceOptions.ID_COLUMN_NAME option to id. The
>>>>> PersistenceOptions.ID_COLUMN_NAME option is used to set the
>>>>> synthetic id column. The synthetic id is created if the type does
>>>>> not have an explicit id column. So what happens is that you have an
>>>>> id-attribute (which gets a column id) and because there is no
>>>>> explicit id for the type a synthetic id is created (which also gets
>>>>> column id).
>>>>>
>>>>> In your case you should annotate the id-feature with a @Id
>>>>> annotation as you want to use that feature as the id (afaics).
>>>>>
>>>>> gr. Marrtin
>>>>>
>>>>> david wrote:
>>>>>> Hi,
>>>>>>
>>>>>> I am getting and error I cannot see an obvious cause for .
>>>>>>
>>>>>> Based on the ecore generated from this
>>>>>>
>>>>>> <xsd:complexType name="StatusChangeSubclass">
>>>>>> <xsd:sequence>
>>>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>>>> ref="gensec:meetingType" />
>>>>>> <xsd:element minOccurs="0" maxOccurs="1" ref="gensec:agent" />
>>>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>>>> ref="gensec:caeLifecycleType" />
>>>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>>>> ref="gensec:caeStatusType" />
>>>>>> <xsd:element ref="gensec:caeType" />
>>>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>>>> ref="gensec:entityIdentifier" />
>>>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>>>> ref="gensec:indicatorsType" />
>>>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>>>> ref="gensec:instrumentIdentifier" />
>>>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>>>> ref="gensec:issuerRef" />
>>>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>>>> ref="gensec:dataValueChange" />
>>>>>> <xsd:element minOccurs="0" maxOccurs="1" ref="gensec:source" />
>>>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>>>> ref="gensec:relatedTo" />
>>>>>> </xsd:sequence>
>>>>>> <xsd:attribute name="id" type="xsd:int" use="optional" />
>>>>>> <xsd:attribute name="effectiveDate" type="xsd:dateTime"
>>>>>> use="optional" />
>>>>>> <xsd:attribute name="announcementDate" type="xsd:dateTime"
>>>>>> use="optional" />
>>>>>> <xsd:attribute name="meetingDate" type="xsd:dateTime"
>>>>>> use="optional" />
>>>>>> <xsd:attribute name="recordDate" type="xsd:dateTime"
>>>>>> use="optional" />
>>>>>> <xsd:attribute name="comment" type="xsd:string" use="optional" />
>>>>>> <xsd:attribute name="documentURL" type="xsd:anyURI"
>>>>>> use="optional" />
>>>>>> <xsd:attribute name="caeIdentifier" type="xsd:string"
>>>>>> use="optional" />
>>>>>> <xsd:attribute name="eventDescription" type="xsd:string"
>>>>>> use="optional" />
>>>>>> <xsd:attribute name="caeDate" type="xsd:dateTime"
>>>>>> use="optional" />
>>>>>> </xsd:complexType>
>>>>>>
>>>>>> I am using
>>>>>>
>>>>>>
>>>>>> props.setProperty(PersistenceOptions.MAXIMUM_SQL_NAME_LENGTH , "30");
>>>>>>
>>>>>> props.setProperty(PersistenceOptions.JOIN_COLUMN_NAMING_STRA TEGY,
>>>>>> "simple");
>>>>>> props.setProperty(PersistenceOptions.ID_COLUMN_NAME, "id");
>>>>>>
>>>>>> props.setProperty(PersistenceOptions.ID_FEATURE_AS_PRIMARY_K EY,
>>>>>> "false");
>>>>>> props.setProperty(PersistenceOptions.ALSO_MAP_AS_CLASS,
>>>>>> "false");
>>>>>>
>>>>>> props.setProperty(PersistenceOptions.DEFAULT_TEMPORAL_VALUE, "DATE");
>>>>>>
>>>>>> props.setProperty(PersistenceOptions.DISABLE_ECONTAINER_MAPP ING,
>>>>>> "true");
>>>>>> props.setProperty(PersistenceOptions.ALWAYS_VERSION,
>>>>>> "false");
>>>>>>
>>>>>> props.setProperty(PersistenceOptions.ALWAYS_MAP_LIST_AS_BAG, "true");
>>>>>> props.setProperty(PersistenceOptions.INHERITANCE_MAPPING,
>>>>>> "JOINED");
>>>>>>
>>>>>> The ID_COLUMN_NAME option I read as meaning it recognises the
>>>>>> model attribute with the name of "id" as the primary key
>>>>>>
>>>>>> There is only one id attribute, also in the ecore, so how come I
>>>>>> get the following error?
>>>>>>
>>>>>> I use Eclise 3.3, JDK 5 and Teneo from the 23rd April
>>>>>>
>>>>>> Exception in thread "main" org.hibernate.MappingException:
>>>>>> Repeated column in mapping for entity: StatusChangeSubclass
>>>>>> column: id (should be mapped with insert="false" update="false")
>>>>>> at
>>>>>> org.hibernate.mapping.PersistentClass.checkColumnDuplication (PersistentClass.java:652)
>>>>>>
>>>>>> at
>>>>>> org.hibernate.mapping.PersistentClass.checkPropertyColumnDup lication(PersistentClass.java:674)
>>>>>>
>>>>>>
>>>>>> Thx.
>>>>>>
>>>>>> David
>>>>>
>>>>>
>>>
>>>
>
>
|
|
|
Re: [Teneo] Unexpected repeated column error [message #122607 is a reply to message #122597] |
Fri, 16 May 2008 17:03 |
Martin Taal Messages: 5468 Registered: July 2009 |
Senior Member |
|
|
Hi David,
It seems valid to me, you can check out if it works when you generate the java model code from this.
The @Id should then be somewhere in the generated PackageImpl as a string in the initialization code.
gr. Martin
david wrote:
> Hi,
>
> This is were it gets confusing, as below I mentioned the id is actually
> an attribute, not an element. Since the annotations are contained within
> an element I was not sure if this same mechanism can be used for adding
> annotations to attributes as opposed to elements as all the examples show.
>
> Is this valid?
>
> <xsd:attribute name="id" type="xsd:int">
> <xsd:annotation>
> <xsd:appinfo source="teneo.jpa">@Id</xsd:appinfo>
> </xsd:annotation>
> </xsd:attribute>
>
> Thx.
>
> David
>
> Martin Taal wrote:
>> Hi David,
>> I don't think that you need to delete the id element from the xsd
>>
>> There are many examples here, did you find it?
>> http://www.elver.org/hibernate/ejb3_examples.html
>>
>> The id annotation in xml schema will be something like this:
>> <xsd:element name="id" type="xsd:long">
>> <xsd:annotation>
>> <xsd:appinfo source="teneo.jpa">@Id</xsd:appinfo>
>> </xsd:annotation>
>> </xsd:element>
>>
>> You can check the jpa spec for the syntax of the annotations.
>>
>> or instead of setting the annotation in the xml schema then having the
>> id element/attribute and set the option:
>> props.setProperty(PersistenceOptions.DEFAULT_ID_FEATURE_NAME , "id")
>> should work.
>>
>> gr. Martin
>>
>> david wrote:
>>> Hi,
>>>
>>> I ended up deleting the Id columns out of the xsd, and using the
>>>
>>> props.setProperty(PersistenceOptions.ID_COLUMN_NAME, "id");
>>> props.setProperty(PersistenceOptions.DEFAULT_ID_FEATURE_NAME ,
>>> "id");
>>>
>>>
>>> But to confirm would the annotation look like this
>>>
>>> <xsd:complexType name="StatusChangeSubclass">
>>> <xsd:sequence>
>>> <xsd:annotation>
>>> <xsd:appinfo source="teneo.jpa">
>>> @Id(name="Id")
>>> </xsd:appinfo>
>>> </xsd:annotation>
>>> ....
>>>
>>> I could not find an explicit example amongst the samples on that page.
>>>
>>> Thx,
>>>
>>> David
>>>
>>>
>>> Martin Taal wrote:
>>>> Hi David,
>>>> Yes you are right the DEFAULT_ID_FEATURE_NAME option should also
>>>> work (forgot that one). You then don't need the @Id annotation or
>>>> the ID_COLUMN_NAME option.
>>>>
>>>> The @Id is a standard jpa annotation. Here are some examples to
>>>> define annotations in xml schema:
>>>> http://www.elver.org/hibernate/ejb3_examples.html#schemasamp les
>>>>
>>>> gr. Martin
>>>>
>>>> david wrote:
>>>>> Hi,
>>>>>
>>>>> I have been sifting through the elver website and cannot find the
>>>>> documentation on the specific @Id annotation. I checked the EJV
>>>>> Persistance document too, but it had Java annotations for the @Id.
>>>>> It is not clear to me how you add the @Id annotation to an
>>>>> attribute within the element in the xsd. Can you show me an example?
>>>>>
>>>>> Also adding this
>>>>> props.setProperty(PersistenceOptions.DEFAULT_ID_FEATURE_NAME , "id");
>>>>>
>>>>> Shouldn't that cause Teneo to recognisedall features named 'id' as
>>>>> the primary key?
>>>>>
>>>>>
>>>>> <xsd:complexType name="StatusChangeSubclass">
>>>>> <xsd:sequence>
>>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>>> ref="gensec:meetingType" />
>>>>> <xsd:element minOccurs="0" maxOccurs="1" ref="gensec:agent" />
>>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>>> ref="gensec:caeLifecycleType" />
>>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>>> ref="gensec:caeStatusType" />
>>>>> <xsd:element ref="gensec:caeType" />
>>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>>> ref="gensec:entityIdentifier" />
>>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>>> ref="gensec:indicatorsType" />
>>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>>> ref="gensec:instrumentIdentifier" />
>>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>>> ref="gensec:issuerRef" />
>>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>>> ref="gensec:dataValueChange" />
>>>>> <xsd:element minOccurs="0" maxOccurs="1" ref="gensec:source" />
>>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>>> ref="gensec:relatedTo" />
>>>>> </xsd:sequence>
>>>>> <xsd:attribute name="id" type="xsd:int" use="optional" />
>>>>> <xsd:attribute name="effectiveDate" type="xsd:dateTime"
>>>>> use="optional" />
>>>>> <xsd:attribute name="announcementDate" type="xsd:dateTime"
>>>>> use="optional" />
>>>>> <xsd:attribute name="meetingDate" type="xsd:dateTime"
>>>>> use="optional" />
>>>>> <xsd:attribute name="recordDate" type="xsd:dateTime"
>>>>> use="optional" />
>>>>> <xsd:attribute name="comment" type="xsd:string" use="optional" />
>>>>> <xsd:attribute name="documentURL" type="xsd:anyURI"
>>>>> use="optional" />
>>>>> <xsd:attribute name="caeIdentifier" type="xsd:string"
>>>>> use="optional" />
>>>>> <xsd:attribute name="eventDescription" type="xsd:string"
>>>>> use="optional" />
>>>>> <xsd:attribute name="caeDate" type="xsd:dateTime"
>>>>> use="optional" />
>>>>> </xsd:complexType>
>>>>>
>>>>>
>>>>> Thanks,
>>>>>
>>>>> David
>>>>>
>>>>> Martin Taal wrote:
>>>>>> Hi David,
>>>>>> This occurs because the type has an id attribute and you set the
>>>>>> PersistenceOptions.ID_COLUMN_NAME option to id. The
>>>>>> PersistenceOptions.ID_COLUMN_NAME option is used to set the
>>>>>> synthetic id column. The synthetic id is created if the type does
>>>>>> not have an explicit id column. So what happens is that you have
>>>>>> an id-attribute (which gets a column id) and because there is no
>>>>>> explicit id for the type a synthetic id is created (which also
>>>>>> gets column id).
>>>>>>
>>>>>> In your case you should annotate the id-feature with a @Id
>>>>>> annotation as you want to use that feature as the id (afaics).
>>>>>>
>>>>>> gr. Marrtin
>>>>>>
>>>>>> david wrote:
>>>>>>> Hi,
>>>>>>>
>>>>>>> I am getting and error I cannot see an obvious cause for .
>>>>>>>
>>>>>>> Based on the ecore generated from this
>>>>>>>
>>>>>>> <xsd:complexType name="StatusChangeSubclass">
>>>>>>> <xsd:sequence>
>>>>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>>>>> ref="gensec:meetingType" />
>>>>>>> <xsd:element minOccurs="0" maxOccurs="1" ref="gensec:agent" />
>>>>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>>>>> ref="gensec:caeLifecycleType" />
>>>>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>>>>> ref="gensec:caeStatusType" />
>>>>>>> <xsd:element ref="gensec:caeType" />
>>>>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>>>>> ref="gensec:entityIdentifier" />
>>>>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>>>>> ref="gensec:indicatorsType" />
>>>>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>>>>> ref="gensec:instrumentIdentifier" />
>>>>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>>>>> ref="gensec:issuerRef" />
>>>>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>>>>> ref="gensec:dataValueChange" />
>>>>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>>>>> ref="gensec:source" />
>>>>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>>>>> ref="gensec:relatedTo" />
>>>>>>> </xsd:sequence>
>>>>>>> <xsd:attribute name="id" type="xsd:int" use="optional" />
>>>>>>> <xsd:attribute name="effectiveDate" type="xsd:dateTime"
>>>>>>> use="optional" />
>>>>>>> <xsd:attribute name="announcementDate" type="xsd:dateTime"
>>>>>>> use="optional" />
>>>>>>> <xsd:attribute name="meetingDate" type="xsd:dateTime"
>>>>>>> use="optional" />
>>>>>>> <xsd:attribute name="recordDate" type="xsd:dateTime"
>>>>>>> use="optional" />
>>>>>>> <xsd:attribute name="comment" type="xsd:string"
>>>>>>> use="optional" />
>>>>>>> <xsd:attribute name="documentURL" type="xsd:anyURI"
>>>>>>> use="optional" />
>>>>>>> <xsd:attribute name="caeIdentifier" type="xsd:string"
>>>>>>> use="optional" />
>>>>>>> <xsd:attribute name="eventDescription" type="xsd:string"
>>>>>>> use="optional" />
>>>>>>> <xsd:attribute name="caeDate" type="xsd:dateTime"
>>>>>>> use="optional" />
>>>>>>> </xsd:complexType>
>>>>>>>
>>>>>>> I am using
>>>>>>>
>>>>>>>
>>>>>>> props.setProperty(PersistenceOptions.MAXIMUM_SQL_NAME_LENGTH , "30");
>>>>>>>
>>>>>>> props.setProperty(PersistenceOptions.JOIN_COLUMN_NAMING_STRA TEGY,
>>>>>>> "simple");
>>>>>>> props.setProperty(PersistenceOptions.ID_COLUMN_NAME, "id");
>>>>>>>
>>>>>>> props.setProperty(PersistenceOptions.ID_FEATURE_AS_PRIMARY_K EY,
>>>>>>> "false");
>>>>>>> props.setProperty(PersistenceOptions.ALSO_MAP_AS_CLASS,
>>>>>>> "false");
>>>>>>>
>>>>>>> props.setProperty(PersistenceOptions.DEFAULT_TEMPORAL_VALUE,
>>>>>>> "DATE");
>>>>>>>
>>>>>>> props.setProperty(PersistenceOptions.DISABLE_ECONTAINER_MAPP ING,
>>>>>>> "true");
>>>>>>> props.setProperty(PersistenceOptions.ALWAYS_VERSION,
>>>>>>> "false");
>>>>>>>
>>>>>>> props.setProperty(PersistenceOptions.ALWAYS_MAP_LIST_AS_BAG,
>>>>>>> "true");
>>>>>>> props.setProperty(PersistenceOptions.INHERITANCE_MAPPING,
>>>>>>> "JOINED");
>>>>>>>
>>>>>>> The ID_COLUMN_NAME option I read as meaning it recognises the
>>>>>>> model attribute with the name of "id" as the primary key
>>>>>>>
>>>>>>> There is only one id attribute, also in the ecore, so how come I
>>>>>>> get the following error?
>>>>>>>
>>>>>>> I use Eclise 3.3, JDK 5 and Teneo from the 23rd April
>>>>>>>
>>>>>>> Exception in thread "main" org.hibernate.MappingException:
>>>>>>> Repeated column in mapping for entity: StatusChangeSubclass
>>>>>>> column: id (should be mapped with insert="false" update="false")
>>>>>>> at
>>>>>>> org.hibernate.mapping.PersistentClass.checkColumnDuplication (PersistentClass.java:652)
>>>>>>>
>>>>>>> at
>>>>>>> org.hibernate.mapping.PersistentClass.checkPropertyColumnDup lication(PersistentClass.java:674)
>>>>>>>
>>>>>>>
>>>>>>> Thx.
>>>>>>>
>>>>>>> David
>>>>>>
>>>>>>
>>>>
>>>>
>>
>>
--
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] Unexpected repeated column error [message #122832 is a reply to message #122607] |
Thu, 22 May 2008 11:07 |
David Wynter Messages: 4624 Registered: July 2009 |
Senior Member |
|
|
Hi,
I have these options,
props.setProperty(Environment.DRIVER, "com.mysql.jdbc.Driver");
props.setProperty(Environment.USER, "tLoader");
props.setProperty(Environment.PASS, "pass34w0rd");
props.setProperty(Environment.URL, "jdbc:mysql://192.168.0.3:3306/"
+ dbName);
props.setProperty(Environment.DIALECT,
org.hibernate.dialect.MySQLInnoDBDialect.class.getName());
props.setProperty(PersistenceOptions.MAXIMUM_SQL_NAME_LENGTH ,
"30");
props.setProperty(PersistenceOptions.ID_FEATURE_AS_PRIMARY_K EY,
"true");
props.setProperty(PersistenceOptions.DEFAULT_ID_FEATURE_NAME ,
"id");
props.setProperty(PersistenceOptions.JOIN_COLUMN_NAMING_STRA TEGY, "simple");
props.setProperty(PersistenceOptions.ALSO_MAP_AS_CLASS, "false");
props.setProperty(PersistenceOptions.DEFAULT_TEMPORAL_VALUE,
"DATE");
props.setProperty(PersistenceOptions.DISABLE_ECONTAINER_MAPP ING, "true");
props.setProperty(PersistenceOptions.ALWAYS_VERSION, "false");
props.setProperty(PersistenceOptions.ALWAYS_MAP_LIST_AS_BAG,
"true");
props.setProperty(PersistenceOptions.INHERITANCE_MAPPING,
"JOINED");
I added the
<xsd:attribute name="id" type="xsd:int">
<xsd:annotation>
<xsd:appinfo source="teneo.jpa">@Id</xsd:appinfo>
</xsd:annotation>
</xsd:attribute>
to all my elements.
But I still get the e_id being produced as the primary key and the id
column is not being used?
Thx.
David
Martin Taal wrote:
> Hi David,
> It seems valid to me, you can check out if it works when you generate
> the java model code from this. The @Id should then be somewhere in the
> generated PackageImpl as a string in the initialization code.
>
> gr. Martin
>
> david wrote:
>> Hi,
>>
>> This is were it gets confusing, as below I mentioned the id is
>> actually an attribute, not an element. Since the annotations are
>> contained within an element I was not sure if this same mechanism can
>> be used for adding annotations to attributes as opposed to elements as
>> all the examples show.
>>
>> Is this valid?
>>
>> <xsd:attribute name="id" type="xsd:int">
>> <xsd:annotation>
>> <xsd:appinfo source="teneo.jpa">@Id</xsd:appinfo>
>> </xsd:annotation>
>> </xsd:attribute>
>>
>> Thx.
>>
>> David
>>
>> Martin Taal wrote:
>>> Hi David,
>>> I don't think that you need to delete the id element from the xsd
>>>
>>> There are many examples here, did you find it?
>>> http://www.elver.org/hibernate/ejb3_examples.html
>>>
>>> The id annotation in xml schema will be something like this:
>>> <xsd:element name="id" type="xsd:long">
>>> <xsd:annotation>
>>> <xsd:appinfo source="teneo.jpa">@Id</xsd:appinfo>
>>> </xsd:annotation>
>>> </xsd:element>
>>>
>>> You can check the jpa spec for the syntax of the annotations.
>>>
>>> or instead of setting the annotation in the xml schema then having
>>> the id element/attribute and set the option:
>>> props.setProperty(PersistenceOptions.DEFAULT_ID_FEATURE_NAME , "id")
>>> should work.
>>>
>>> gr. Martin
>>>
>>> david wrote:
>>>> Hi,
>>>>
>>>> I ended up deleting the Id columns out of the xsd, and using the
>>>>
>>>> props.setProperty(PersistenceOptions.ID_COLUMN_NAME, "id");
>>>>
>>>> props.setProperty(PersistenceOptions.DEFAULT_ID_FEATURE_NAME , "id");
>>>>
>>>>
>>>> But to confirm would the annotation look like this
>>>>
>>>> <xsd:complexType name="StatusChangeSubclass">
>>>> <xsd:sequence>
>>>> <xsd:annotation>
>>>> <xsd:appinfo source="teneo.jpa">
>>>> @Id(name="Id")
>>>> </xsd:appinfo>
>>>> </xsd:annotation>
>>>> ....
>>>>
>>>> I could not find an explicit example amongst the samples on that page.
>>>>
>>>> Thx,
>>>>
>>>> David
>>>>
>>>>
>>>> Martin Taal wrote:
>>>>> Hi David,
>>>>> Yes you are right the DEFAULT_ID_FEATURE_NAME option should also
>>>>> work (forgot that one). You then don't need the @Id annotation or
>>>>> the ID_COLUMN_NAME option.
>>>>>
>>>>> The @Id is a standard jpa annotation. Here are some examples to
>>>>> define annotations in xml schema:
>>>>> http://www.elver.org/hibernate/ejb3_examples.html#schemasamp les
>>>>>
>>>>> gr. Martin
>>>>>
>>>>> david wrote:
>>>>>> Hi,
>>>>>>
>>>>>> I have been sifting through the elver website and cannot find the
>>>>>> documentation on the specific @Id annotation. I checked the EJV
>>>>>> Persistance document too, but it had Java annotations for the @Id.
>>>>>> It is not clear to me how you add the @Id annotation to an
>>>>>> attribute within the element in the xsd. Can you show me an example?
>>>>>>
>>>>>> Also adding this
>>>>>> props.setProperty(PersistenceOptions.DEFAULT_ID_FEATURE_NAME , "id");
>>>>>>
>>>>>> Shouldn't that cause Teneo to recognisedall features named 'id' as
>>>>>> the primary key?
>>>>>>
>>>>>>
>>>>>> <xsd:complexType name="StatusChangeSubclass">
>>>>>> <xsd:sequence>
>>>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>>>> ref="gensec:meetingType" />
>>>>>> <xsd:element minOccurs="0" maxOccurs="1" ref="gensec:agent" />
>>>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>>>> ref="gensec:caeLifecycleType" />
>>>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>>>> ref="gensec:caeStatusType" />
>>>>>> <xsd:element ref="gensec:caeType" />
>>>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>>>> ref="gensec:entityIdentifier" />
>>>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>>>> ref="gensec:indicatorsType" />
>>>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>>>> ref="gensec:instrumentIdentifier" />
>>>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>>>> ref="gensec:issuerRef" />
>>>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>>>> ref="gensec:dataValueChange" />
>>>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>>>> ref="gensec:source" />
>>>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>>>> ref="gensec:relatedTo" />
>>>>>> </xsd:sequence>
>>>>>> <xsd:attribute name="id" type="xsd:int" use="optional" />
>>>>>> <xsd:attribute name="effectiveDate" type="xsd:dateTime"
>>>>>> use="optional" />
>>>>>> <xsd:attribute name="announcementDate" type="xsd:dateTime"
>>>>>> use="optional" />
>>>>>> <xsd:attribute name="meetingDate" type="xsd:dateTime"
>>>>>> use="optional" />
>>>>>> <xsd:attribute name="recordDate" type="xsd:dateTime"
>>>>>> use="optional" />
>>>>>> <xsd:attribute name="comment" type="xsd:string"
>>>>>> use="optional" />
>>>>>> <xsd:attribute name="documentURL" type="xsd:anyURI"
>>>>>> use="optional" />
>>>>>> <xsd:attribute name="caeIdentifier" type="xsd:string"
>>>>>> use="optional" />
>>>>>> <xsd:attribute name="eventDescription" type="xsd:string"
>>>>>> use="optional" />
>>>>>> <xsd:attribute name="caeDate" type="xsd:dateTime"
>>>>>> use="optional" />
>>>>>> </xsd:complexType>
>>>>>>
>>>>>>
>>>>>> Thanks,
>>>>>>
>>>>>> David
>>>>>>
>>>>>> Martin Taal wrote:
>>>>>>> Hi David,
>>>>>>> This occurs because the type has an id attribute and you set the
>>>>>>> PersistenceOptions.ID_COLUMN_NAME option to id. The
>>>>>>> PersistenceOptions.ID_COLUMN_NAME option is used to set the
>>>>>>> synthetic id column. The synthetic id is created if the type does
>>>>>>> not have an explicit id column. So what happens is that you have
>>>>>>> an id-attribute (which gets a column id) and because there is no
>>>>>>> explicit id for the type a synthetic id is created (which also
>>>>>>> gets column id).
>>>>>>>
>>>>>>> In your case you should annotate the id-feature with a @Id
>>>>>>> annotation as you want to use that feature as the id (afaics).
>>>>>>>
>>>>>>> gr. Marrtin
>>>>>>>
>>>>>>> david wrote:
>>>>>>>> Hi,
>>>>>>>>
>>>>>>>> I am getting and error I cannot see an obvious cause for .
>>>>>>>>
>>>>>>>> Based on the ecore generated from this
>>>>>>>>
>>>>>>>> <xsd:complexType name="StatusChangeSubclass">
>>>>>>>> <xsd:sequence>
>>>>>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>>>>>> ref="gensec:meetingType" />
>>>>>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>>>>>> ref="gensec:agent" />
>>>>>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>>>>>> ref="gensec:caeLifecycleType" />
>>>>>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>>>>>> ref="gensec:caeStatusType" />
>>>>>>>> <xsd:element ref="gensec:caeType" />
>>>>>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>>>>>> ref="gensec:entityIdentifier" />
>>>>>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>>>>>> ref="gensec:indicatorsType" />
>>>>>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>>>>>> ref="gensec:instrumentIdentifier" />
>>>>>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>>>>>> ref="gensec:issuerRef" />
>>>>>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>>>>>> ref="gensec:dataValueChange" />
>>>>>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>>>>>> ref="gensec:source" />
>>>>>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>>>>>> ref="gensec:relatedTo" />
>>>>>>>> </xsd:sequence>
>>>>>>>> <xsd:attribute name="id" type="xsd:int" use="optional" />
>>>>>>>> <xsd:attribute name="effectiveDate" type="xsd:dateTime"
>>>>>>>> use="optional" />
>>>>>>>> <xsd:attribute name="announcementDate" type="xsd:dateTime"
>>>>>>>> use="optional" />
>>>>>>>> <xsd:attribute name="meetingDate" type="xsd:dateTime"
>>>>>>>> use="optional" />
>>>>>>>> <xsd:attribute name="recordDate" type="xsd:dateTime"
>>>>>>>> use="optional" />
>>>>>>>> <xsd:attribute name="comment" type="xsd:string"
>>>>>>>> use="optional" />
>>>>>>>> <xsd:attribute name="documentURL" type="xsd:anyURI"
>>>>>>>> use="optional" />
>>>>>>>> <xsd:attribute name="caeIdentifier" type="xsd:string"
>>>>>>>> use="optional" />
>>>>>>>> <xsd:attribute name="eventDescription" type="xsd:string"
>>>>>>>> use="optional" />
>>>>>>>> <xsd:attribute name="caeDate" type="xsd:dateTime"
>>>>>>>> use="optional" />
>>>>>>>> </xsd:complexType>
>>>>>>>>
>>>>>>>> I am using
>>>>>>>>
>>>>>>>>
>>>>>>>> props.setProperty(PersistenceOptions.MAXIMUM_SQL_NAME_LENGTH ,
>>>>>>>> "30");
>>>>>>>>
>>>>>>>> props.setProperty(PersistenceOptions.JOIN_COLUMN_NAMING_STRA TEGY,
>>>>>>>> "simple");
>>>>>>>> props.setProperty(PersistenceOptions.ID_COLUMN_NAME, "id");
>>>>>>>>
>>>>>>>> props.setProperty(PersistenceOptions.ID_FEATURE_AS_PRIMARY_K EY,
>>>>>>>> "false");
>>>>>>>> props.setProperty(PersistenceOptions.ALSO_MAP_AS_CLASS,
>>>>>>>> "false");
>>>>>>>>
>>>>>>>> props.setProperty(PersistenceOptions.DEFAULT_TEMPORAL_VALUE,
>>>>>>>> "DATE");
>>>>>>>>
>>>>>>>> props.setProperty(PersistenceOptions.DISABLE_ECONTAINER_MAPP ING,
>>>>>>>> "true");
>>>>>>>> props.setProperty(PersistenceOptions.ALWAYS_VERSION,
>>>>>>>> "false");
>>>>>>>>
>>>>>>>> props.setProperty(PersistenceOptions.ALWAYS_MAP_LIST_AS_BAG,
>>>>>>>> "true");
>>>>>>>>
>>>>>>>> props.setProperty(PersistenceOptions.INHERITANCE_MAPPING,
>>>>>>>> "JOINED");
>>>>>>>>
>>>>>>>> The ID_COLUMN_NAME option I read as meaning it recognises the
>>>>>>>> model attribute with the name of "id" as the primary key
>>>>>>>>
>>>>>>>> There is only one id attribute, also in the ecore, so how come I
>>>>>>>> get the following error?
>>>>>>>>
>>>>>>>> I use Eclise 3.3, JDK 5 and Teneo from the 23rd April
>>>>>>>>
>>>>>>>> Exception in thread "main" org.hibernate.MappingException:
>>>>>>>> Repeated column in mapping for entity: StatusChangeSubclass
>>>>>>>> column: id (should be mapped with insert="false" update="false")
>>>>>>>> at
>>>>>>>> org.hibernate.mapping.PersistentClass.checkColumnDuplication (PersistentClass.java:652)
>>>>>>>>
>>>>>>>> at
>>>>>>>> org.hibernate.mapping.PersistentClass.checkPropertyColumnDup lication(PersistentClass.java:674)
>>>>>>>>
>>>>>>>>
>>>>>>>> Thx.
>>>>>>>>
>>>>>>>> David
>>>>>>>
>>>>>>>
>>>>>
>>>>>
>>>
>>>
>
>
|
|
|
Re: [Teneo] Unexpected repeated column error [message #122843 is a reply to message #122832] |
Thu, 22 May 2008 11:15 |
Martin Taal Messages: 5468 Registered: July 2009 |
Senior Member |
|
|
Hi David,
You did do a reload of the genmodel and regenerate of the java code?
Can you see the annotation in the generated PackageImpl somewhere?
Can you post the hbm which maps the id attribute and the id of the entity itself?
gr. Martin
david wrote:
> Hi,
>
> I have these options,
>
> props.setProperty(Environment.DRIVER, "com.mysql.jdbc.Driver");
> props.setProperty(Environment.USER, "tLoader");
> props.setProperty(Environment.PASS, "pass34w0rd");
> props.setProperty(Environment.URL,
> "jdbc:mysql://192.168.0.3:3306/" + dbName);
> props.setProperty(Environment.DIALECT,
> org.hibernate.dialect.MySQLInnoDBDialect.class.getName());
> props.setProperty(PersistenceOptions.MAXIMUM_SQL_NAME_LENGTH ,
> "30");
> props.setProperty(PersistenceOptions.ID_FEATURE_AS_PRIMARY_K EY,
> "true");
> props.setProperty(PersistenceOptions.DEFAULT_ID_FEATURE_NAME ,
> "id");
>
> props.setProperty(PersistenceOptions.JOIN_COLUMN_NAMING_STRA TEGY,
> "simple");
> props.setProperty(PersistenceOptions.ALSO_MAP_AS_CLASS, "false");
> props.setProperty(PersistenceOptions.DEFAULT_TEMPORAL_VALUE,
> "DATE");
>
> props.setProperty(PersistenceOptions.DISABLE_ECONTAINER_MAPP ING, "true");
> props.setProperty(PersistenceOptions.ALWAYS_VERSION, "false");
> props.setProperty(PersistenceOptions.ALWAYS_MAP_LIST_AS_BAG,
> "true");
> props.setProperty(PersistenceOptions.INHERITANCE_MAPPING,
> "JOINED");
>
>
> I added the
>
> <xsd:attribute name="id" type="xsd:int">
> <xsd:annotation>
> <xsd:appinfo source="teneo.jpa">@Id</xsd:appinfo>
> </xsd:annotation>
> </xsd:attribute>
>
> to all my elements.
>
> But I still get the e_id being produced as the primary key and the id
> column is not being used?
>
> Thx.
>
> David
>
>
>
> Martin Taal wrote:
>> Hi David,
>> It seems valid to me, you can check out if it works when you generate
>> the java model code from this. The @Id should then be somewhere in the
>> generated PackageImpl as a string in the initialization code.
>>
>> gr. Martin
>>
>> david wrote:
>>> Hi,
>>>
>>> This is were it gets confusing, as below I mentioned the id is
>>> actually an attribute, not an element. Since the annotations are
>>> contained within an element I was not sure if this same mechanism can
>>> be used for adding annotations to attributes as opposed to elements
>>> as all the examples show.
>>>
>>> Is this valid?
>>>
>>> <xsd:attribute name="id" type="xsd:int">
>>> <xsd:annotation>
>>> <xsd:appinfo source="teneo.jpa">@Id</xsd:appinfo>
>>> </xsd:annotation>
>>> </xsd:attribute>
>>>
>>> Thx.
>>>
>>> David
>>>
>>> Martin Taal wrote:
>>>> Hi David,
>>>> I don't think that you need to delete the id element from the xsd
>>>>
>>>> There are many examples here, did you find it?
>>>> http://www.elver.org/hibernate/ejb3_examples.html
>>>>
>>>> The id annotation in xml schema will be something like this:
>>>> <xsd:element name="id" type="xsd:long">
>>>> <xsd:annotation>
>>>> <xsd:appinfo source="teneo.jpa">@Id</xsd:appinfo>
>>>> </xsd:annotation>
>>>> </xsd:element>
>>>>
>>>> You can check the jpa spec for the syntax of the annotations.
>>>>
>>>> or instead of setting the annotation in the xml schema then having
>>>> the id element/attribute and set the option:
>>>> props.setProperty(PersistenceOptions.DEFAULT_ID_FEATURE_NAME , "id")
>>>> should work.
>>>>
>>>> gr. Martin
>>>>
>>>> david wrote:
>>>>> Hi,
>>>>>
>>>>> I ended up deleting the Id columns out of the xsd, and using the
>>>>>
>>>>> props.setProperty(PersistenceOptions.ID_COLUMN_NAME, "id");
>>>>>
>>>>> props.setProperty(PersistenceOptions.DEFAULT_ID_FEATURE_NAME , "id");
>>>>>
>>>>>
>>>>> But to confirm would the annotation look like this
>>>>>
>>>>> <xsd:complexType name="StatusChangeSubclass">
>>>>> <xsd:sequence>
>>>>> <xsd:annotation>
>>>>> <xsd:appinfo source="teneo.jpa">
>>>>> @Id(name="Id")
>>>>> </xsd:appinfo>
>>>>> </xsd:annotation>
>>>>> ....
>>>>>
>>>>> I could not find an explicit example amongst the samples on that page.
>>>>>
>>>>> Thx,
>>>>>
>>>>> David
>>>>>
>>>>>
>>>>> Martin Taal wrote:
>>>>>> Hi David,
>>>>>> Yes you are right the DEFAULT_ID_FEATURE_NAME option should also
>>>>>> work (forgot that one). You then don't need the @Id annotation or
>>>>>> the ID_COLUMN_NAME option.
>>>>>>
>>>>>> The @Id is a standard jpa annotation. Here are some examples to
>>>>>> define annotations in xml schema:
>>>>>> http://www.elver.org/hibernate/ejb3_examples.html#schemasamp les
>>>>>>
>>>>>> gr. Martin
>>>>>>
>>>>>> david wrote:
>>>>>>> Hi,
>>>>>>>
>>>>>>> I have been sifting through the elver website and cannot find the
>>>>>>> documentation on the specific @Id annotation. I checked the EJV
>>>>>>> Persistance document too, but it had Java annotations for the
>>>>>>> @Id. It is not clear to me how you add the @Id annotation to an
>>>>>>> attribute within the element in the xsd. Can you show me an example?
>>>>>>>
>>>>>>> Also adding this
>>>>>>> props.setProperty(PersistenceOptions.DEFAULT_ID_FEATURE_NAME , "id");
>>>>>>>
>>>>>>> Shouldn't that cause Teneo to recognisedall features named 'id'
>>>>>>> as the primary key?
>>>>>>>
>>>>>>>
>>>>>>> <xsd:complexType name="StatusChangeSubclass">
>>>>>>> <xsd:sequence>
>>>>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>>>>> ref="gensec:meetingType" />
>>>>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>>>>> ref="gensec:agent" />
>>>>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>>>>> ref="gensec:caeLifecycleType" />
>>>>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>>>>> ref="gensec:caeStatusType" />
>>>>>>> <xsd:element ref="gensec:caeType" />
>>>>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>>>>> ref="gensec:entityIdentifier" />
>>>>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>>>>> ref="gensec:indicatorsType" />
>>>>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>>>>> ref="gensec:instrumentIdentifier" />
>>>>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>>>>> ref="gensec:issuerRef" />
>>>>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>>>>> ref="gensec:dataValueChange" />
>>>>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>>>>> ref="gensec:source" />
>>>>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>>>>> ref="gensec:relatedTo" />
>>>>>>> </xsd:sequence>
>>>>>>> <xsd:attribute name="id" type="xsd:int" use="optional" />
>>>>>>> <xsd:attribute name="effectiveDate" type="xsd:dateTime"
>>>>>>> use="optional" />
>>>>>>> <xsd:attribute name="announcementDate" type="xsd:dateTime"
>>>>>>> use="optional" />
>>>>>>> <xsd:attribute name="meetingDate" type="xsd:dateTime"
>>>>>>> use="optional" />
>>>>>>> <xsd:attribute name="recordDate" type="xsd:dateTime"
>>>>>>> use="optional" />
>>>>>>> <xsd:attribute name="comment" type="xsd:string"
>>>>>>> use="optional" />
>>>>>>> <xsd:attribute name="documentURL" type="xsd:anyURI"
>>>>>>> use="optional" />
>>>>>>> <xsd:attribute name="caeIdentifier" type="xsd:string"
>>>>>>> use="optional" />
>>>>>>> <xsd:attribute name="eventDescription" type="xsd:string"
>>>>>>> use="optional" />
>>>>>>> <xsd:attribute name="caeDate" type="xsd:dateTime"
>>>>>>> use="optional" />
>>>>>>> </xsd:complexType>
>>>>>>>
>>>>>>>
>>>>>>> Thanks,
>>>>>>>
>>>>>>> David
>>>>>>>
>>>>>>> Martin Taal wrote:
>>>>>>>> Hi David,
>>>>>>>> This occurs because the type has an id attribute and you set the
>>>>>>>> PersistenceOptions.ID_COLUMN_NAME option to id. The
>>>>>>>> PersistenceOptions.ID_COLUMN_NAME option is used to set the
>>>>>>>> synthetic id column. The synthetic id is created if the type
>>>>>>>> does not have an explicit id column. So what happens is that you
>>>>>>>> have an id-attribute (which gets a column id) and because there
>>>>>>>> is no explicit id for the type a synthetic id is created (which
>>>>>>>> also gets column id).
>>>>>>>>
>>>>>>>> In your case you should annotate the id-feature with a @Id
>>>>>>>> annotation as you want to use that feature as the id (afaics).
>>>>>>>>
>>>>>>>> gr. Marrtin
>>>>>>>>
>>>>>>>> david wrote:
>>>>>>>>> Hi,
>>>>>>>>>
>>>>>>>>> I am getting and error I cannot see an obvious cause for .
>>>>>>>>>
>>>>>>>>> Based on the ecore generated from this
>>>>>>>>>
>>>>>>>>> <xsd:complexType name="StatusChangeSubclass">
>>>>>>>>> <xsd:sequence>
>>>>>>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>>>>>>> ref="gensec:meetingType" />
>>>>>>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>>>>>>> ref="gensec:agent" />
>>>>>>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>>>>>>> ref="gensec:caeLifecycleType" />
>>>>>>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>>>>>>> ref="gensec:caeStatusType" />
>>>>>>>>> <xsd:element ref="gensec:caeType" />
>>>>>>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>>>>>>> ref="gensec:entityIdentifier" />
>>>>>>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>>>>>>> ref="gensec:indicatorsType" />
>>>>>>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>>>>>>> ref="gensec:instrumentIdentifier" />
>>>>>>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>>>>>>> ref="gensec:issuerRef" />
>>>>>>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>>>>>>> ref="gensec:dataValueChange" />
>>>>>>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>>>>>>> ref="gensec:source" />
>>>>>>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>>>>>>> ref="gensec:relatedTo" />
>>>>>>>>> </xsd:sequence>
>>>>>>>>> <xsd:attribute name="id" type="xsd:int" use="optional" />
>>>>>>>>> <xsd:attribute name="effectiveDate" type="xsd:dateTime"
>>>>>>>>> use="optional" />
>>>>>>>>> <xsd:attribute name="announcementDate" type="xsd:dateTime"
>>>>>>>>> use="optional" />
>>>>>>>>> <xsd:attribute name="meetingDate" type="xsd:dateTime"
>>>>>>>>> use="optional" />
>>>>>>>>> <xsd:attribute name="recordDate" type="xsd:dateTime"
>>>>>>>>> use="optional" />
>>>>>>>>> <xsd:attribute name="comment" type="xsd:string"
>>>>>>>>> use="optional" />
>>>>>>>>> <xsd:attribute name="documentURL" type="xsd:anyURI"
>>>>>>>>> use="optional" />
>>>>>>>>> <xsd:attribute name="caeIdentifier" type="xsd:string"
>>>>>>>>> use="optional" />
>>>>>>>>> <xsd:attribute name="eventDescription" type="xsd:string"
>>>>>>>>> use="optional" />
>>>>>>>>> <xsd:attribute name="caeDate" type="xsd:dateTime"
>>>>>>>>> use="optional" />
>>>>>>>>> </xsd:complexType>
>>>>>>>>>
>>>>>>>>> I am using
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> props.setProperty(PersistenceOptions.MAXIMUM_SQL_NAME_LENGTH ,
>>>>>>>>> "30");
>>>>>>>>>
>>>>>>>>> props.setProperty(PersistenceOptions.JOIN_COLUMN_NAMING_STRA TEGY,
>>>>>>>>> "simple");
>>>>>>>>> props.setProperty(PersistenceOptions.ID_COLUMN_NAME,
>>>>>>>>> "id");
>>>>>>>>>
>>>>>>>>> props.setProperty(PersistenceOptions.ID_FEATURE_AS_PRIMARY_K EY,
>>>>>>>>> "false");
>>>>>>>>> props.setProperty(PersistenceOptions.ALSO_MAP_AS_CLASS,
>>>>>>>>> "false");
>>>>>>>>>
>>>>>>>>> props.setProperty(PersistenceOptions.DEFAULT_TEMPORAL_VALUE,
>>>>>>>>> "DATE");
>>>>>>>>>
>>>>>>>>> props.setProperty(PersistenceOptions.DISABLE_ECONTAINER_MAPP ING,
>>>>>>>>> "true");
>>>>>>>>> props.setProperty(PersistenceOptions.ALWAYS_VERSION,
>>>>>>>>> "false");
>>>>>>>>>
>>>>>>>>> props.setProperty(PersistenceOptions.ALWAYS_MAP_LIST_AS_BAG,
>>>>>>>>> "true");
>>>>>>>>>
>>>>>>>>> props.setProperty(PersistenceOptions.INHERITANCE_MAPPING,
>>>>>>>>> "JOINED");
>>>>>>>>>
>>>>>>>>> The ID_COLUMN_NAME option I read as meaning it recognises the
>>>>>>>>> model attribute with the name of "id" as the primary key
>>>>>>>>>
>>>>>>>>> There is only one id attribute, also in the ecore, so how come
>>>>>>>>> I get the following error?
>>>>>>>>>
>>>>>>>>> I use Eclise 3.3, JDK 5 and Teneo from the 23rd April
>>>>>>>>>
>>>>>>>>> Exception in thread "main" org.hibernate.MappingException:
>>>>>>>>> Repeated column in mapping for entity: StatusChangeSubclass
>>>>>>>>> column: id (should be mapped with insert="false" update="false")
>>>>>>>>> at
>>>>>>>>> org.hibernate.mapping.PersistentClass.checkColumnDuplication (PersistentClass.java:652)
>>>>>>>>>
>>>>>>>>> at
>>>>>>>>> org.hibernate.mapping.PersistentClass.checkPropertyColumnDup lication(PersistentClass.java:674)
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> Thx.
>>>>>>>>>
>>>>>>>>> David
>>>>>>>>
>>>>>>>>
>>>>>>
>>>>>>
>>>>
>>>>
>>
>>
--
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] Unexpected repeated column error [message #122866 is a reply to message #122843] |
Thu, 22 May 2008 14:06 |
David Wynter Messages: 4624 Registered: July 2009 |
Senior Member |
|
|
Hi,
It was my misunderstanding of how the generation was done. From previous
newsgroup messages I thought that either you generated the hbm file
and then used Hibernate to generate or you could use the programmatic
method as I had.
I had already regenerated the model, but I had not generated the hbm
file. I tried it again just generating the hbm file first and it then
programmatically generated using the HbDataStore initialize() method.
That worked correctly.
Thx.
David
Martin Taal wrote:
> Hi David,
> You did do a reload of the genmodel and regenerate of the java code?
> Can you see the annotation in the generated PackageImpl somewhere?
>
> Can you post the hbm which maps the id attribute and the id of the
> entity itself?
>
> gr. Martin
>
> david wrote:
>> Hi,
>>
>> I have these options,
>>
>> props.setProperty(Environment.DRIVER, "com.mysql.jdbc.Driver");
>> props.setProperty(Environment.USER, "tLoader");
>> props.setProperty(Environment.PASS, "pass34w0rd");
>> props.setProperty(Environment.URL,
>> "jdbc:mysql://192.168.0.3:3306/" + dbName);
>> props.setProperty(Environment.DIALECT,
>> org.hibernate.dialect.MySQLInnoDBDialect.class.getName());
>> props.setProperty(PersistenceOptions.MAXIMUM_SQL_NAME_LENGTH ,
>> "30");
>>
>> props.setProperty(PersistenceOptions.ID_FEATURE_AS_PRIMARY_K EY, "true");
>> props.setProperty(PersistenceOptions.DEFAULT_ID_FEATURE_NAME ,
>> "id");
>>
>> props.setProperty(PersistenceOptions.JOIN_COLUMN_NAMING_STRA TEGY,
>> "simple");
>> props.setProperty(PersistenceOptions.ALSO_MAP_AS_CLASS, "false");
>> props.setProperty(PersistenceOptions.DEFAULT_TEMPORAL_VALUE,
>> "DATE");
>>
>> props.setProperty(PersistenceOptions.DISABLE_ECONTAINER_MAPP ING, "true");
>> props.setProperty(PersistenceOptions.ALWAYS_VERSION, "false");
>> props.setProperty(PersistenceOptions.ALWAYS_MAP_LIST_AS_BAG,
>> "true");
>> props.setProperty(PersistenceOptions.INHERITANCE_MAPPING,
>> "JOINED");
>>
>>
>> I added the
>>
>> <xsd:attribute name="id" type="xsd:int">
>> <xsd:annotation>
>> <xsd:appinfo source="teneo.jpa">@Id</xsd:appinfo>
>> </xsd:annotation>
>> </xsd:attribute>
>>
>> to all my elements.
>>
>> But I still get the e_id being produced as the primary key and the id
>> column is not being used?
>>
>> Thx.
>>
>> David
>>
>>
>>
>> Martin Taal wrote:
>>> Hi David,
>>> It seems valid to me, you can check out if it works when you generate
>>> the java model code from this. The @Id should then be somewhere in
>>> the generated PackageImpl as a string in the initialization code.
>>>
>>> gr. Martin
>>>
>>> david wrote:
>>>> Hi,
>>>>
>>>> This is were it gets confusing, as below I mentioned the id is
>>>> actually an attribute, not an element. Since the annotations are
>>>> contained within an element I was not sure if this same mechanism
>>>> can be used for adding annotations to attributes as opposed to
>>>> elements as all the examples show.
>>>>
>>>> Is this valid?
>>>>
>>>> <xsd:attribute name="id" type="xsd:int">
>>>> <xsd:annotation>
>>>> <xsd:appinfo source="teneo.jpa">@Id</xsd:appinfo>
>>>> </xsd:annotation>
>>>> </xsd:attribute>
>>>>
>>>> Thx.
>>>>
>>>> David
>>>>
>>>> Martin Taal wrote:
>>>>> Hi David,
>>>>> I don't think that you need to delete the id element from the xsd
>>>>>
>>>>> There are many examples here, did you find it?
>>>>> http://www.elver.org/hibernate/ejb3_examples.html
>>>>>
>>>>> The id annotation in xml schema will be something like this:
>>>>> <xsd:element name="id" type="xsd:long">
>>>>> <xsd:annotation>
>>>>> <xsd:appinfo source="teneo.jpa">@Id</xsd:appinfo>
>>>>> </xsd:annotation>
>>>>> </xsd:element>
>>>>>
>>>>> You can check the jpa spec for the syntax of the annotations.
>>>>>
>>>>> or instead of setting the annotation in the xml schema then having
>>>>> the id element/attribute and set the option:
>>>>> props.setProperty(PersistenceOptions.DEFAULT_ID_FEATURE_NAME , "id")
>>>>> should work.
>>>>>
>>>>> gr. Martin
>>>>>
>>>>> david wrote:
>>>>>> Hi,
>>>>>>
>>>>>> I ended up deleting the Id columns out of the xsd, and using the
>>>>>>
>>>>>> props.setProperty(PersistenceOptions.ID_COLUMN_NAME, "id");
>>>>>>
>>>>>> props.setProperty(PersistenceOptions.DEFAULT_ID_FEATURE_NAME , "id");
>>>>>>
>>>>>>
>>>>>> But to confirm would the annotation look like this
>>>>>>
>>>>>> <xsd:complexType name="StatusChangeSubclass">
>>>>>> <xsd:sequence>
>>>>>> <xsd:annotation>
>>>>>> <xsd:appinfo source="teneo.jpa">
>>>>>> @Id(name="Id")
>>>>>> </xsd:appinfo>
>>>>>> </xsd:annotation>
>>>>>> ....
>>>>>>
>>>>>> I could not find an explicit example amongst the samples on that
>>>>>> page.
>>>>>>
>>>>>> Thx,
>>>>>>
>>>>>> David
>>>>>>
>>>>>>
>>>>>> Martin Taal wrote:
>>>>>>> Hi David,
>>>>>>> Yes you are right the DEFAULT_ID_FEATURE_NAME option should also
>>>>>>> work (forgot that one). You then don't need the @Id annotation or
>>>>>>> the ID_COLUMN_NAME option.
>>>>>>>
>>>>>>> The @Id is a standard jpa annotation. Here are some examples to
>>>>>>> define annotations in xml schema:
>>>>>>> http://www.elver.org/hibernate/ejb3_examples.html#schemasamp les
>>>>>>>
>>>>>>> gr. Martin
>>>>>>>
>>>>>>> david wrote:
>>>>>>>> Hi,
>>>>>>>>
>>>>>>>> I have been sifting through the elver website and cannot find
>>>>>>>> the documentation on the specific @Id annotation. I checked the
>>>>>>>> EJV Persistance document too, but it had Java annotations for
>>>>>>>> the @Id. It is not clear to me how you add the @Id annotation to
>>>>>>>> an attribute within the element in the xsd. Can you show me an
>>>>>>>> example?
>>>>>>>>
>>>>>>>> Also adding this
>>>>>>>> props.setProperty(PersistenceOptions.DEFAULT_ID_FEATURE_NAME ,
>>>>>>>> "id");
>>>>>>>>
>>>>>>>> Shouldn't that cause Teneo to recognisedall features named 'id'
>>>>>>>> as the primary key?
>>>>>>>>
>>>>>>>>
>>>>>>>> <xsd:complexType name="StatusChangeSubclass">
>>>>>>>> <xsd:sequence>
>>>>>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>>>>>> ref="gensec:meetingType" />
>>>>>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>>>>>> ref="gensec:agent" />
>>>>>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>>>>>> ref="gensec:caeLifecycleType" />
>>>>>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>>>>>> ref="gensec:caeStatusType" />
>>>>>>>> <xsd:element ref="gensec:caeType" />
>>>>>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>>>>>> ref="gensec:entityIdentifier" />
>>>>>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>>>>>> ref="gensec:indicatorsType" />
>>>>>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>>>>>> ref="gensec:instrumentIdentifier" />
>>>>>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>>>>>> ref="gensec:issuerRef" />
>>>>>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>>>>>> ref="gensec:dataValueChange" />
>>>>>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>>>>>> ref="gensec:source" />
>>>>>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>>>>>> ref="gensec:relatedTo" />
>>>>>>>> </xsd:sequence>
>>>>>>>> <xsd:attribute name="id" type="xsd:int" use="optional" />
>>>>>>>> <xsd:attribute name="effectiveDate" type="xsd:dateTime"
>>>>>>>> use="optional" />
>>>>>>>> <xsd:attribute name="announcementDate" type="xsd:dateTime"
>>>>>>>> use="optional" />
>>>>>>>> <xsd:attribute name="meetingDate" type="xsd:dateTime"
>>>>>>>> use="optional" />
>>>>>>>> <xsd:attribute name="recordDate" type="xsd:dateTime"
>>>>>>>> use="optional" />
>>>>>>>> <xsd:attribute name="comment" type="xsd:string"
>>>>>>>> use="optional" />
>>>>>>>> <xsd:attribute name="documentURL" type="xsd:anyURI"
>>>>>>>> use="optional" />
>>>>>>>> <xsd:attribute name="caeIdentifier" type="xsd:string"
>>>>>>>> use="optional" />
>>>>>>>> <xsd:attribute name="eventDescription" type="xsd:string"
>>>>>>>> use="optional" />
>>>>>>>> <xsd:attribute name="caeDate" type="xsd:dateTime"
>>>>>>>> use="optional" />
>>>>>>>> </xsd:complexType>
>>>>>>>>
>>>>>>>>
>>>>>>>> Thanks,
>>>>>>>>
>>>>>>>> David
>>>>>>>>
>>>>>>>> Martin Taal wrote:
>>>>>>>>> Hi David,
>>>>>>>>> This occurs because the type has an id attribute and you set
>>>>>>>>> the PersistenceOptions.ID_COLUMN_NAME option to id. The
>>>>>>>>> PersistenceOptions.ID_COLUMN_NAME option is used to set the
>>>>>>>>> synthetic id column. The synthetic id is created if the type
>>>>>>>>> does not have an explicit id column. So what happens is that
>>>>>>>>> you have an id-attribute (which gets a column id) and because
>>>>>>>>> there is no explicit id for the type a synthetic id is created
>>>>>>>>> (which also gets column id).
>>>>>>>>>
>>>>>>>>> In your case you should annotate the id-feature with a @Id
>>>>>>>>> annotation as you want to use that feature as the id (afaics).
>>>>>>>>>
>>>>>>>>> gr. Marrtin
>>>>>>>>>
>>>>>>>>> david wrote:
>>>>>>>>>> Hi,
>>>>>>>>>>
>>>>>>>>>> I am getting and error I cannot see an obvious cause for .
>>>>>>>>>>
>>>>>>>>>> Based on the ecore generated from this
>>>>>>>>>>
>>>>>>>>>> <xsd:complexType name="StatusChangeSubclass">
>>>>>>>>>> <xsd:sequence>
>>>>>>>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>>>>>>>> ref="gensec:meetingType" />
>>>>>>>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>>>>>>>> ref="gensec:agent" />
>>>>>>>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>>>>>>>> ref="gensec:caeLifecycleType" />
>>>>>>>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>>>>>>>> ref="gensec:caeStatusType" />
>>>>>>>>>> <xsd:element ref="gensec:caeType" />
>>>>>>>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>>>>>>>> ref="gensec:entityIdentifier" />
>>>>>>>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>>>>>>>> ref="gensec:indicatorsType" />
>>>>>>>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>>>>>>>> ref="gensec:instrumentIdentifier" />
>>>>>>>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>>>>>>>> ref="gensec:issuerRef" />
>>>>>>>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>>>>>>>> ref="gensec:dataValueChange" />
>>>>>>>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>>>>>>>> ref="gensec:source" />
>>>>>>>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>>>>>>>> ref="gensec:relatedTo" />
>>>>>>>>>> </xsd:sequence>
>>>>>>>>>> <xsd:attribute name="id" type="xsd:int" use="optional" />
>>>>>>>>>> <xsd:attribute name="effectiveDate" type="xsd:dateTime"
>>>>>>>>>> use="optional" />
>>>>>>>>>> <xsd:attribute name="announcementDate" type="xsd:dateTime"
>>>>>>>>>> use="optional" />
>>>>>>>>>> <xsd:attribute name="meetingDate" type="xsd:dateTime"
>>>>>>>>>> use="optional" />
>>>>>>>>>> <xsd:attribute name="recordDate" type="xsd:dateTime"
>>>>>>>>>> use="optional" />
>>>>>>>>>> <xsd:attribute name="comment" type="xsd:string"
>>>>>>>>>> use="optional" />
>>>>>>>>>> <xsd:attribute name="documentURL" type="xsd:anyURI"
>>>>>>>>>> use="optional" />
>>>>>>>>>> <xsd:attribute name="caeIdentifier" type="xsd:string"
>>>>>>>>>> use="optional" />
>>>>>>>>>> <xsd:attribute name="eventDescription" type="xsd:string"
>>>>>>>>>> use="optional" />
>>>>>>>>>> <xsd:attribute name="caeDate" type="xsd:dateTime"
>>>>>>>>>> use="optional" />
>>>>>>>>>> </xsd:complexType>
>>>>>>>>>>
>>>>>>>>>> I am using
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> props.setProperty(PersistenceOptions.MAXIMUM_SQL_NAME_LENGTH ,
>>>>>>>>>> "30");
>>>>>>>>>>
>>>>>>>>>> props.setProperty(PersistenceOptions.JOIN_COLUMN_NAMING_STRA TEGY,
>>>>>>>>>> "simple");
>>>>>>>>>> props.setProperty(PersistenceOptions.ID_COLUMN_NAME,
>>>>>>>>>> "id");
>>>>>>>>>>
>>>>>>>>>> props.setProperty(PersistenceOptions.ID_FEATURE_AS_PRIMARY_K EY,
>>>>>>>>>> "false");
>>>>>>>>>>
>>>>>>>>>> props.setProperty(PersistenceOptions.ALSO_MAP_AS_CLASS, "false");
>>>>>>>>>>
>>>>>>>>>> props.setProperty(PersistenceOptions.DEFAULT_TEMPORAL_VALUE,
>>>>>>>>>> "DATE");
>>>>>>>>>>
>>>>>>>>>> props.setProperty(PersistenceOptions.DISABLE_ECONTAINER_MAPP ING,
>>>>>>>>>> "true");
>>>>>>>>>> props.setProperty(PersistenceOptions.ALWAYS_VERSION,
>>>>>>>>>> "false");
>>>>>>>>>>
>>>>>>>>>> props.setProperty(PersistenceOptions.ALWAYS_MAP_LIST_AS_BAG,
>>>>>>>>>> "true");
>>>>>>>>>>
>>>>>>>>>> props.setProperty(PersistenceOptions.INHERITANCE_MAPPING,
>>>>>>>>>> "JOINED");
>>>>>>>>>>
>>>>>>>>>> The ID_COLUMN_NAME option I read as meaning it recognises the
>>>>>>>>>> model attribute with the name of "id" as the primary key
>>>>>>>>>>
>>>>>>>>>> There is only one id attribute, also in the ecore, so how come
>>>>>>>>>> I get the following error?
>>>>>>>>>>
>>>>>>>>>> I use Eclise 3.3, JDK 5 and Teneo from the 23rd April
>>>>>>>>>>
>>>>>>>>>> Exception in thread "main" org.hibernate.MappingException:
>>>>>>>>>> Repeated column in mapping for entity: StatusChangeSubclass
>>>>>>>>>> column: id (should be mapped with insert="false" update="false")
>>>>>>>>>> at
>>>>>>>>>> org.hibernate.mapping.PersistentClass.checkColumnDuplication (PersistentClass.java:652)
>>>>>>>>>>
>>>>>>>>>> at
>>>>>>>>>> org.hibernate.mapping.PersistentClass.checkPropertyColumnDup lication(PersistentClass.java:674)
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> Thx.
>>>>>>>>>>
>>>>>>>>>> David
>>>>>>>>>
>>>>>>>>>
>>>>>>>
>>>>>>>
>>>>>
>>>>>
>>>
>>>
>
>
|
|
|
Re: [Teneo] Unexpected repeated column error [message #618045 is a reply to message #122399] |
Wed, 14 May 2008 10:58 |
Martin Taal Messages: 5468 Registered: July 2009 |
Senior Member |
|
|
Hi David,
This occurs because the type has an id attribute and you set the PersistenceOptions.ID_COLUMN_NAME
option to id. The PersistenceOptions.ID_COLUMN_NAME option is used to set the synthetic id column.
The synthetic id is created if the type does not have an explicit id column. So what happens is that
you have an id-attribute (which gets a column id) and because there is no explicit id for the type a
synthetic id is created (which also gets column id).
In your case you should annotate the id-feature with a @Id annotation as you want to use that
feature as the id (afaics).
gr. Marrtin
david wrote:
> Hi,
>
> I am getting and error I cannot see an obvious cause for .
>
> Based on the ecore generated from this
>
> <xsd:complexType name="StatusChangeSubclass">
> <xsd:sequence>
> <xsd:element minOccurs="0" maxOccurs="1" ref="gensec:meetingType" />
> <xsd:element minOccurs="0" maxOccurs="1" ref="gensec:agent" />
> <xsd:element minOccurs="0" maxOccurs="1"
> ref="gensec:caeLifecycleType" />
> <xsd:element minOccurs="0" maxOccurs="1"
> ref="gensec:caeStatusType" />
> <xsd:element ref="gensec:caeType" />
> <xsd:element minOccurs="0" maxOccurs="1"
> ref="gensec:entityIdentifier" />
> <xsd:element minOccurs="0" maxOccurs="1"
> ref="gensec:indicatorsType" />
> <xsd:element minOccurs="0" maxOccurs="1"
> ref="gensec:instrumentIdentifier" />
> <xsd:element minOccurs="0" maxOccurs="1" ref="gensec:issuerRef" />
> <xsd:element minOccurs="0" maxOccurs="1"
> ref="gensec:dataValueChange" />
> <xsd:element minOccurs="0" maxOccurs="1" ref="gensec:source" />
> <xsd:element minOccurs="0" maxOccurs="1" ref="gensec:relatedTo" />
> </xsd:sequence>
> <xsd:attribute name="id" type="xsd:int" use="optional" />
> <xsd:attribute name="effectiveDate" type="xsd:dateTime"
> use="optional" />
> <xsd:attribute name="announcementDate" type="xsd:dateTime"
> use="optional" />
> <xsd:attribute name="meetingDate" type="xsd:dateTime" use="optional" />
> <xsd:attribute name="recordDate" type="xsd:dateTime" use="optional" />
> <xsd:attribute name="comment" type="xsd:string" use="optional" />
> <xsd:attribute name="documentURL" type="xsd:anyURI" use="optional" />
> <xsd:attribute name="caeIdentifier" type="xsd:string" use="optional" />
> <xsd:attribute name="eventDescription" type="xsd:string"
> use="optional" />
> <xsd:attribute name="caeDate" type="xsd:dateTime" use="optional" />
> </xsd:complexType>
>
> I am using
>
> props.setProperty(PersistenceOptions.MAXIMUM_SQL_NAME_LENGTH ,
> "30");
>
> props.setProperty(PersistenceOptions.JOIN_COLUMN_NAMING_STRA TEGY,
> "simple");
> props.setProperty(PersistenceOptions.ID_COLUMN_NAME, "id");
> props.setProperty(PersistenceOptions.ID_FEATURE_AS_PRIMARY_K EY,
> "false");
> props.setProperty(PersistenceOptions.ALSO_MAP_AS_CLASS, "false");
> props.setProperty(PersistenceOptions.DEFAULT_TEMPORAL_VALUE,
> "DATE");
>
> props.setProperty(PersistenceOptions.DISABLE_ECONTAINER_MAPP ING, "true");
> props.setProperty(PersistenceOptions.ALWAYS_VERSION, "false");
> props.setProperty(PersistenceOptions.ALWAYS_MAP_LIST_AS_BAG,
> "true");
> props.setProperty(PersistenceOptions.INHERITANCE_MAPPING,
> "JOINED");
>
> The ID_COLUMN_NAME option I read as meaning it recognises the model
> attribute with the name of "id" as the primary key
>
> There is only one id attribute, also in the ecore, so how come I get the
> following error?
>
> I use Eclise 3.3, JDK 5 and Teneo from the 23rd April
>
> Exception in thread "main" org.hibernate.MappingException: Repeated
> column in mapping for entity: StatusChangeSubclass column: id (should be
> mapped with insert="false" update="false")
> at
> org.hibernate.mapping.PersistentClass.checkColumnDuplication (PersistentClass.java:652)
>
> at
> org.hibernate.mapping.PersistentClass.checkPropertyColumnDup lication(PersistentClass.java:674)
>
>
> Thx.
>
> David
--
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] Unexpected repeated column error [message #618051 is a reply to message #122492] |
Fri, 16 May 2008 13:14 |
David Wynter Messages: 4624 Registered: July 2009 |
Senior Member |
|
|
Hi,
I have been sifting through the elver website and cannot find the
documentation on the specific @Id annotation. I checked the EJV
Persistance document too, but it had Java annotations for the @Id. It is
not clear to me how you add the @Id annotation to an attribute within
the element in the xsd. Can you show me an example?
Also adding this
props.setProperty(PersistenceOptions.DEFAULT_ID_FEATURE_NAME , "id");
Shouldn't that cause Teneo to recognisedall features named 'id' as the
primary key?
<xsd:complexType name="StatusChangeSubclass">
<xsd:sequence>
<xsd:element minOccurs="0" maxOccurs="1"
ref="gensec:meetingType" />
<xsd:element minOccurs="0" maxOccurs="1" ref="gensec:agent" />
<xsd:element minOccurs="0" maxOccurs="1"
ref="gensec:caeLifecycleType" />
<xsd:element minOccurs="0" maxOccurs="1"
ref="gensec:caeStatusType" />
<xsd:element ref="gensec:caeType" />
<xsd:element minOccurs="0" maxOccurs="1"
ref="gensec:entityIdentifier" />
<xsd:element minOccurs="0" maxOccurs="1"
ref="gensec:indicatorsType" />
<xsd:element minOccurs="0" maxOccurs="1"
ref="gensec:instrumentIdentifier" />
<xsd:element minOccurs="0" maxOccurs="1" ref="gensec:issuerRef" />
<xsd:element minOccurs="0" maxOccurs="1"
ref="gensec:dataValueChange" />
<xsd:element minOccurs="0" maxOccurs="1" ref="gensec:source" />
<xsd:element minOccurs="0" maxOccurs="1" ref="gensec:relatedTo" />
</xsd:sequence>
<xsd:attribute name="id" type="xsd:int" use="optional" />
<xsd:attribute name="effectiveDate" type="xsd:dateTime"
use="optional" />
<xsd:attribute name="announcementDate" type="xsd:dateTime"
use="optional" />
<xsd:attribute name="meetingDate" type="xsd:dateTime"
use="optional" />
<xsd:attribute name="recordDate" type="xsd:dateTime"
use="optional" />
<xsd:attribute name="comment" type="xsd:string" use="optional" />
<xsd:attribute name="documentURL" type="xsd:anyURI" use="optional" />
<xsd:attribute name="caeIdentifier" type="xsd:string"
use="optional" />
<xsd:attribute name="eventDescription" type="xsd:string"
use="optional" />
<xsd:attribute name="caeDate" type="xsd:dateTime" use="optional" />
</xsd:complexType>
Thanks,
David
Martin Taal wrote:
> Hi David,
> This occurs because the type has an id attribute and you set the
> PersistenceOptions.ID_COLUMN_NAME option to id. The
> PersistenceOptions.ID_COLUMN_NAME option is used to set the synthetic id
> column. The synthetic id is created if the type does not have an
> explicit id column. So what happens is that you have an id-attribute
> (which gets a column id) and because there is no explicit id for the
> type a synthetic id is created (which also gets column id).
>
> In your case you should annotate the id-feature with a @Id annotation as
> you want to use that feature as the id (afaics).
>
> gr. Marrtin
>
> david wrote:
>> Hi,
>>
>> I am getting and error I cannot see an obvious cause for .
>>
>> Based on the ecore generated from this
>>
>> <xsd:complexType name="StatusChangeSubclass">
>> <xsd:sequence>
>> <xsd:element minOccurs="0" maxOccurs="1"
>> ref="gensec:meetingType" />
>> <xsd:element minOccurs="0" maxOccurs="1" ref="gensec:agent" />
>> <xsd:element minOccurs="0" maxOccurs="1"
>> ref="gensec:caeLifecycleType" />
>> <xsd:element minOccurs="0" maxOccurs="1"
>> ref="gensec:caeStatusType" />
>> <xsd:element ref="gensec:caeType" />
>> <xsd:element minOccurs="0" maxOccurs="1"
>> ref="gensec:entityIdentifier" />
>> <xsd:element minOccurs="0" maxOccurs="1"
>> ref="gensec:indicatorsType" />
>> <xsd:element minOccurs="0" maxOccurs="1"
>> ref="gensec:instrumentIdentifier" />
>> <xsd:element minOccurs="0" maxOccurs="1" ref="gensec:issuerRef" />
>> <xsd:element minOccurs="0" maxOccurs="1"
>> ref="gensec:dataValueChange" />
>> <xsd:element minOccurs="0" maxOccurs="1" ref="gensec:source" />
>> <xsd:element minOccurs="0" maxOccurs="1" ref="gensec:relatedTo" />
>> </xsd:sequence>
>> <xsd:attribute name="id" type="xsd:int" use="optional" />
>> <xsd:attribute name="effectiveDate" type="xsd:dateTime"
>> use="optional" />
>> <xsd:attribute name="announcementDate" type="xsd:dateTime"
>> use="optional" />
>> <xsd:attribute name="meetingDate" type="xsd:dateTime"
>> use="optional" />
>> <xsd:attribute name="recordDate" type="xsd:dateTime"
>> use="optional" />
>> <xsd:attribute name="comment" type="xsd:string" use="optional" />
>> <xsd:attribute name="documentURL" type="xsd:anyURI" use="optional" />
>> <xsd:attribute name="caeIdentifier" type="xsd:string"
>> use="optional" />
>> <xsd:attribute name="eventDescription" type="xsd:string"
>> use="optional" />
>> <xsd:attribute name="caeDate" type="xsd:dateTime" use="optional" />
>> </xsd:complexType>
>>
>> I am using
>>
>> props.setProperty(PersistenceOptions.MAXIMUM_SQL_NAME_LENGTH ,
>> "30");
>>
>> props.setProperty(PersistenceOptions.JOIN_COLUMN_NAMING_STRA TEGY,
>> "simple");
>> props.setProperty(PersistenceOptions.ID_COLUMN_NAME, "id");
>>
>> props.setProperty(PersistenceOptions.ID_FEATURE_AS_PRIMARY_K EY, "false");
>> props.setProperty(PersistenceOptions.ALSO_MAP_AS_CLASS, "false");
>> props.setProperty(PersistenceOptions.DEFAULT_TEMPORAL_VALUE,
>> "DATE");
>>
>> props.setProperty(PersistenceOptions.DISABLE_ECONTAINER_MAPP ING, "true");
>> props.setProperty(PersistenceOptions.ALWAYS_VERSION, "false");
>> props.setProperty(PersistenceOptions.ALWAYS_MAP_LIST_AS_BAG,
>> "true");
>> props.setProperty(PersistenceOptions.INHERITANCE_MAPPING,
>> "JOINED");
>>
>> The ID_COLUMN_NAME option I read as meaning it recognises the model
>> attribute with the name of "id" as the primary key
>>
>> There is only one id attribute, also in the ecore, so how come I get
>> the following error?
>>
>> I use Eclise 3.3, JDK 5 and Teneo from the 23rd April
>>
>> Exception in thread "main" org.hibernate.MappingException: Repeated
>> column in mapping for entity: StatusChangeSubclass column: id (should
>> be mapped with insert="false" update="false")
>> at
>> org.hibernate.mapping.PersistentClass.checkColumnDuplication (PersistentClass.java:652)
>>
>> at
>> org.hibernate.mapping.PersistentClass.checkPropertyColumnDup lication(PersistentClass.java:674)
>>
>>
>> Thx.
>>
>> David
>
>
|
|
|
Re: [Teneo] Unexpected repeated column error [message #618052 is a reply to message #122547] |
Fri, 16 May 2008 13:59 |
Martin Taal Messages: 5468 Registered: July 2009 |
Senior Member |
|
|
Hi David,
Yes you are right the DEFAULT_ID_FEATURE_NAME option should also work (forgot that one). You then
don't need the @Id annotation or the ID_COLUMN_NAME option.
The @Id is a standard jpa annotation. Here are some examples to define annotations in xml schema:
http://www.elver.org/hibernate/ejb3_examples.html#schemasamp les
gr. Martin
david wrote:
> Hi,
>
> I have been sifting through the elver website and cannot find the
> documentation on the specific @Id annotation. I checked the EJV
> Persistance document too, but it had Java annotations for the @Id. It is
> not clear to me how you add the @Id annotation to an attribute within
> the element in the xsd. Can you show me an example?
>
> Also adding this
> props.setProperty(PersistenceOptions.DEFAULT_ID_FEATURE_NAME , "id");
>
> Shouldn't that cause Teneo to recognisedall features named 'id' as the
> primary key?
>
>
> <xsd:complexType name="StatusChangeSubclass">
> <xsd:sequence>
> <xsd:element minOccurs="0" maxOccurs="1"
> ref="gensec:meetingType" />
> <xsd:element minOccurs="0" maxOccurs="1" ref="gensec:agent" />
> <xsd:element minOccurs="0" maxOccurs="1"
> ref="gensec:caeLifecycleType" />
> <xsd:element minOccurs="0" maxOccurs="1"
> ref="gensec:caeStatusType" />
> <xsd:element ref="gensec:caeType" />
> <xsd:element minOccurs="0" maxOccurs="1"
> ref="gensec:entityIdentifier" />
> <xsd:element minOccurs="0" maxOccurs="1"
> ref="gensec:indicatorsType" />
> <xsd:element minOccurs="0" maxOccurs="1"
> ref="gensec:instrumentIdentifier" />
> <xsd:element minOccurs="0" maxOccurs="1" ref="gensec:issuerRef" />
> <xsd:element minOccurs="0" maxOccurs="1"
> ref="gensec:dataValueChange" />
> <xsd:element minOccurs="0" maxOccurs="1" ref="gensec:source" />
> <xsd:element minOccurs="0" maxOccurs="1" ref="gensec:relatedTo" />
> </xsd:sequence>
> <xsd:attribute name="id" type="xsd:int" use="optional" />
> <xsd:attribute name="effectiveDate" type="xsd:dateTime"
> use="optional" />
> <xsd:attribute name="announcementDate" type="xsd:dateTime"
> use="optional" />
> <xsd:attribute name="meetingDate" type="xsd:dateTime"
> use="optional" />
> <xsd:attribute name="recordDate" type="xsd:dateTime"
> use="optional" />
> <xsd:attribute name="comment" type="xsd:string" use="optional" />
> <xsd:attribute name="documentURL" type="xsd:anyURI" use="optional" />
> <xsd:attribute name="caeIdentifier" type="xsd:string"
> use="optional" />
> <xsd:attribute name="eventDescription" type="xsd:string"
> use="optional" />
> <xsd:attribute name="caeDate" type="xsd:dateTime" use="optional" />
> </xsd:complexType>
>
>
> Thanks,
>
> David
>
> Martin Taal wrote:
>> Hi David,
>> This occurs because the type has an id attribute and you set the
>> PersistenceOptions.ID_COLUMN_NAME option to id. The
>> PersistenceOptions.ID_COLUMN_NAME option is used to set the synthetic
>> id column. The synthetic id is created if the type does not have an
>> explicit id column. So what happens is that you have an id-attribute
>> (which gets a column id) and because there is no explicit id for the
>> type a synthetic id is created (which also gets column id).
>>
>> In your case you should annotate the id-feature with a @Id annotation
>> as you want to use that feature as the id (afaics).
>>
>> gr. Marrtin
>>
>> david wrote:
>>> Hi,
>>>
>>> I am getting and error I cannot see an obvious cause for .
>>>
>>> Based on the ecore generated from this
>>>
>>> <xsd:complexType name="StatusChangeSubclass">
>>> <xsd:sequence>
>>> <xsd:element minOccurs="0" maxOccurs="1"
>>> ref="gensec:meetingType" />
>>> <xsd:element minOccurs="0" maxOccurs="1" ref="gensec:agent" />
>>> <xsd:element minOccurs="0" maxOccurs="1"
>>> ref="gensec:caeLifecycleType" />
>>> <xsd:element minOccurs="0" maxOccurs="1"
>>> ref="gensec:caeStatusType" />
>>> <xsd:element ref="gensec:caeType" />
>>> <xsd:element minOccurs="0" maxOccurs="1"
>>> ref="gensec:entityIdentifier" />
>>> <xsd:element minOccurs="0" maxOccurs="1"
>>> ref="gensec:indicatorsType" />
>>> <xsd:element minOccurs="0" maxOccurs="1"
>>> ref="gensec:instrumentIdentifier" />
>>> <xsd:element minOccurs="0" maxOccurs="1" ref="gensec:issuerRef" />
>>> <xsd:element minOccurs="0" maxOccurs="1"
>>> ref="gensec:dataValueChange" />
>>> <xsd:element minOccurs="0" maxOccurs="1" ref="gensec:source" />
>>> <xsd:element minOccurs="0" maxOccurs="1" ref="gensec:relatedTo" />
>>> </xsd:sequence>
>>> <xsd:attribute name="id" type="xsd:int" use="optional" />
>>> <xsd:attribute name="effectiveDate" type="xsd:dateTime"
>>> use="optional" />
>>> <xsd:attribute name="announcementDate" type="xsd:dateTime"
>>> use="optional" />
>>> <xsd:attribute name="meetingDate" type="xsd:dateTime"
>>> use="optional" />
>>> <xsd:attribute name="recordDate" type="xsd:dateTime"
>>> use="optional" />
>>> <xsd:attribute name="comment" type="xsd:string" use="optional" />
>>> <xsd:attribute name="documentURL" type="xsd:anyURI"
>>> use="optional" />
>>> <xsd:attribute name="caeIdentifier" type="xsd:string"
>>> use="optional" />
>>> <xsd:attribute name="eventDescription" type="xsd:string"
>>> use="optional" />
>>> <xsd:attribute name="caeDate" type="xsd:dateTime" use="optional" />
>>> </xsd:complexType>
>>>
>>> I am using
>>>
>>> props.setProperty(PersistenceOptions.MAXIMUM_SQL_NAME_LENGTH ,
>>> "30");
>>>
>>> props.setProperty(PersistenceOptions.JOIN_COLUMN_NAMING_STRA TEGY,
>>> "simple");
>>> props.setProperty(PersistenceOptions.ID_COLUMN_NAME, "id");
>>>
>>> props.setProperty(PersistenceOptions.ID_FEATURE_AS_PRIMARY_K EY,
>>> "false");
>>> props.setProperty(PersistenceOptions.ALSO_MAP_AS_CLASS,
>>> "false");
>>> props.setProperty(PersistenceOptions.DEFAULT_TEMPORAL_VALUE,
>>> "DATE");
>>>
>>> props.setProperty(PersistenceOptions.DISABLE_ECONTAINER_MAPP ING,
>>> "true");
>>> props.setProperty(PersistenceOptions.ALWAYS_VERSION, "false");
>>> props.setProperty(PersistenceOptions.ALWAYS_MAP_LIST_AS_BAG,
>>> "true");
>>> props.setProperty(PersistenceOptions.INHERITANCE_MAPPING,
>>> "JOINED");
>>>
>>> The ID_COLUMN_NAME option I read as meaning it recognises the model
>>> attribute with the name of "id" as the primary key
>>>
>>> There is only one id attribute, also in the ecore, so how come I get
>>> the following error?
>>>
>>> I use Eclise 3.3, JDK 5 and Teneo from the 23rd April
>>>
>>> Exception in thread "main" org.hibernate.MappingException: Repeated
>>> column in mapping for entity: StatusChangeSubclass column: id (should
>>> be mapped with insert="false" update="false")
>>> at
>>> org.hibernate.mapping.PersistentClass.checkColumnDuplication (PersistentClass.java:652)
>>>
>>> at
>>> org.hibernate.mapping.PersistentClass.checkPropertyColumnDup lication(PersistentClass.java:674)
>>>
>>>
>>> Thx.
>>>
>>> David
>>
>>
--
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] Unexpected repeated column error [message #618054 is a reply to message #122556] |
Fri, 16 May 2008 14:40 |
David Wynter Messages: 4624 Registered: July 2009 |
Senior Member |
|
|
Hi,
I ended up deleting the Id columns out of the xsd, and using the
props.setProperty(PersistenceOptions.ID_COLUMN_NAME, "id");
props.setProperty(PersistenceOptions.DEFAULT_ID_FEATURE_NAME ,
"id");
But to confirm would the annotation look like this
<xsd:complexType name="StatusChangeSubclass">
<xsd:sequence>
<xsd:annotation>
<xsd:appinfo source="teneo.jpa">
@Id(name="Id")
</xsd:appinfo>
</xsd:annotation>
....
I could not find an explicit example amongst the samples on that page.
Thx,
David
Martin Taal wrote:
> Hi David,
> Yes you are right the DEFAULT_ID_FEATURE_NAME option should also work
> (forgot that one). You then don't need the @Id annotation or the
> ID_COLUMN_NAME option.
>
> The @Id is a standard jpa annotation. Here are some examples to define
> annotations in xml schema:
> http://www.elver.org/hibernate/ejb3_examples.html#schemasamp les
>
> gr. Martin
>
> david wrote:
>> Hi,
>>
>> I have been sifting through the elver website and cannot find the
>> documentation on the specific @Id annotation. I checked the EJV
>> Persistance document too, but it had Java annotations for the @Id. It
>> is not clear to me how you add the @Id annotation to an attribute
>> within the element in the xsd. Can you show me an example?
>>
>> Also adding this
>> props.setProperty(PersistenceOptions.DEFAULT_ID_FEATURE_NAME , "id");
>>
>> Shouldn't that cause Teneo to recognisedall features named 'id' as the
>> primary key?
>>
>>
>> <xsd:complexType name="StatusChangeSubclass">
>> <xsd:sequence>
>> <xsd:element minOccurs="0" maxOccurs="1"
>> ref="gensec:meetingType" />
>> <xsd:element minOccurs="0" maxOccurs="1" ref="gensec:agent" />
>> <xsd:element minOccurs="0" maxOccurs="1"
>> ref="gensec:caeLifecycleType" />
>> <xsd:element minOccurs="0" maxOccurs="1"
>> ref="gensec:caeStatusType" />
>> <xsd:element ref="gensec:caeType" />
>> <xsd:element minOccurs="0" maxOccurs="1"
>> ref="gensec:entityIdentifier" />
>> <xsd:element minOccurs="0" maxOccurs="1"
>> ref="gensec:indicatorsType" />
>> <xsd:element minOccurs="0" maxOccurs="1"
>> ref="gensec:instrumentIdentifier" />
>> <xsd:element minOccurs="0" maxOccurs="1" ref="gensec:issuerRef" />
>> <xsd:element minOccurs="0" maxOccurs="1"
>> ref="gensec:dataValueChange" />
>> <xsd:element minOccurs="0" maxOccurs="1" ref="gensec:source" />
>> <xsd:element minOccurs="0" maxOccurs="1" ref="gensec:relatedTo" />
>> </xsd:sequence>
>> <xsd:attribute name="id" type="xsd:int" use="optional" />
>> <xsd:attribute name="effectiveDate" type="xsd:dateTime"
>> use="optional" />
>> <xsd:attribute name="announcementDate" type="xsd:dateTime"
>> use="optional" />
>> <xsd:attribute name="meetingDate" type="xsd:dateTime"
>> use="optional" />
>> <xsd:attribute name="recordDate" type="xsd:dateTime"
>> use="optional" />
>> <xsd:attribute name="comment" type="xsd:string" use="optional" />
>> <xsd:attribute name="documentURL" type="xsd:anyURI"
>> use="optional" />
>> <xsd:attribute name="caeIdentifier" type="xsd:string"
>> use="optional" />
>> <xsd:attribute name="eventDescription" type="xsd:string"
>> use="optional" />
>> <xsd:attribute name="caeDate" type="xsd:dateTime" use="optional" />
>> </xsd:complexType>
>>
>>
>> Thanks,
>>
>> David
>>
>> Martin Taal wrote:
>>> Hi David,
>>> This occurs because the type has an id attribute and you set the
>>> PersistenceOptions.ID_COLUMN_NAME option to id. The
>>> PersistenceOptions.ID_COLUMN_NAME option is used to set the synthetic
>>> id column. The synthetic id is created if the type does not have an
>>> explicit id column. So what happens is that you have an id-attribute
>>> (which gets a column id) and because there is no explicit id for the
>>> type a synthetic id is created (which also gets column id).
>>>
>>> In your case you should annotate the id-feature with a @Id annotation
>>> as you want to use that feature as the id (afaics).
>>>
>>> gr. Marrtin
>>>
>>> david wrote:
>>>> Hi,
>>>>
>>>> I am getting and error I cannot see an obvious cause for .
>>>>
>>>> Based on the ecore generated from this
>>>>
>>>> <xsd:complexType name="StatusChangeSubclass">
>>>> <xsd:sequence>
>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>> ref="gensec:meetingType" />
>>>> <xsd:element minOccurs="0" maxOccurs="1" ref="gensec:agent" />
>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>> ref="gensec:caeLifecycleType" />
>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>> ref="gensec:caeStatusType" />
>>>> <xsd:element ref="gensec:caeType" />
>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>> ref="gensec:entityIdentifier" />
>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>> ref="gensec:indicatorsType" />
>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>> ref="gensec:instrumentIdentifier" />
>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>> ref="gensec:issuerRef" />
>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>> ref="gensec:dataValueChange" />
>>>> <xsd:element minOccurs="0" maxOccurs="1" ref="gensec:source" />
>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>> ref="gensec:relatedTo" />
>>>> </xsd:sequence>
>>>> <xsd:attribute name="id" type="xsd:int" use="optional" />
>>>> <xsd:attribute name="effectiveDate" type="xsd:dateTime"
>>>> use="optional" />
>>>> <xsd:attribute name="announcementDate" type="xsd:dateTime"
>>>> use="optional" />
>>>> <xsd:attribute name="meetingDate" type="xsd:dateTime"
>>>> use="optional" />
>>>> <xsd:attribute name="recordDate" type="xsd:dateTime"
>>>> use="optional" />
>>>> <xsd:attribute name="comment" type="xsd:string" use="optional" />
>>>> <xsd:attribute name="documentURL" type="xsd:anyURI"
>>>> use="optional" />
>>>> <xsd:attribute name="caeIdentifier" type="xsd:string"
>>>> use="optional" />
>>>> <xsd:attribute name="eventDescription" type="xsd:string"
>>>> use="optional" />
>>>> <xsd:attribute name="caeDate" type="xsd:dateTime" use="optional" />
>>>> </xsd:complexType>
>>>>
>>>> I am using
>>>>
>>>>
>>>> props.setProperty(PersistenceOptions.MAXIMUM_SQL_NAME_LENGTH , "30");
>>>>
>>>> props.setProperty(PersistenceOptions.JOIN_COLUMN_NAMING_STRA TEGY,
>>>> "simple");
>>>> props.setProperty(PersistenceOptions.ID_COLUMN_NAME, "id");
>>>>
>>>> props.setProperty(PersistenceOptions.ID_FEATURE_AS_PRIMARY_K EY,
>>>> "false");
>>>> props.setProperty(PersistenceOptions.ALSO_MAP_AS_CLASS,
>>>> "false");
>>>> props.setProperty(PersistenceOptions.DEFAULT_TEMPORAL_VALUE,
>>>> "DATE");
>>>>
>>>> props.setProperty(PersistenceOptions.DISABLE_ECONTAINER_MAPP ING,
>>>> "true");
>>>> props.setProperty(PersistenceOptions.ALWAYS_VERSION, "false");
>>>> props.setProperty(PersistenceOptions.ALWAYS_MAP_LIST_AS_BAG,
>>>> "true");
>>>> props.setProperty(PersistenceOptions.INHERITANCE_MAPPING,
>>>> "JOINED");
>>>>
>>>> The ID_COLUMN_NAME option I read as meaning it recognises the model
>>>> attribute with the name of "id" as the primary key
>>>>
>>>> There is only one id attribute, also in the ecore, so how come I get
>>>> the following error?
>>>>
>>>> I use Eclise 3.3, JDK 5 and Teneo from the 23rd April
>>>>
>>>> Exception in thread "main" org.hibernate.MappingException: Repeated
>>>> column in mapping for entity: StatusChangeSubclass column: id
>>>> (should be mapped with insert="false" update="false")
>>>> at
>>>> org.hibernate.mapping.PersistentClass.checkColumnDuplication (PersistentClass.java:652)
>>>>
>>>> at
>>>> org.hibernate.mapping.PersistentClass.checkPropertyColumnDup lication(PersistentClass.java:674)
>>>>
>>>>
>>>> Thx.
>>>>
>>>> David
>>>
>>>
>
>
|
|
|
Re: [Teneo] Unexpected repeated column error [message #618055 is a reply to message #122570] |
Fri, 16 May 2008 14:52 |
Martin Taal Messages: 5468 Registered: July 2009 |
Senior Member |
|
|
Hi David,
I don't think that you need to delete the id element from the xsd
There are many examples here, did you find it?
http://www.elver.org/hibernate/ejb3_examples.html
The id annotation in xml schema will be something like this:
<xsd:element name="id" type="xsd:long">
<xsd:annotation>
<xsd:appinfo source="teneo.jpa">@Id</xsd:appinfo>
</xsd:annotation>
</xsd:element>
You can check the jpa spec for the syntax of the annotations.
or instead of setting the annotation in the xml schema then having the id element/attribute and set
the option: props.setProperty(PersistenceOptions.DEFAULT_ID_FEATURE_NAME , "id")
should work.
gr. Martin
david wrote:
> Hi,
>
> I ended up deleting the Id columns out of the xsd, and using the
>
> props.setProperty(PersistenceOptions.ID_COLUMN_NAME, "id");
> props.setProperty(PersistenceOptions.DEFAULT_ID_FEATURE_NAME ,
> "id");
>
>
> But to confirm would the annotation look like this
>
> <xsd:complexType name="StatusChangeSubclass">
> <xsd:sequence>
> <xsd:annotation>
> <xsd:appinfo source="teneo.jpa">
> @Id(name="Id")
> </xsd:appinfo>
> </xsd:annotation>
> ....
>
> I could not find an explicit example amongst the samples on that page.
>
> Thx,
>
> David
>
>
> Martin Taal wrote:
>> Hi David,
>> Yes you are right the DEFAULT_ID_FEATURE_NAME option should also work
>> (forgot that one). You then don't need the @Id annotation or the
>> ID_COLUMN_NAME option.
>>
>> The @Id is a standard jpa annotation. Here are some examples to define
>> annotations in xml schema:
>> http://www.elver.org/hibernate/ejb3_examples.html#schemasamp les
>>
>> gr. Martin
>>
>> david wrote:
>>> Hi,
>>>
>>> I have been sifting through the elver website and cannot find the
>>> documentation on the specific @Id annotation. I checked the EJV
>>> Persistance document too, but it had Java annotations for the @Id. It
>>> is not clear to me how you add the @Id annotation to an attribute
>>> within the element in the xsd. Can you show me an example?
>>>
>>> Also adding this
>>> props.setProperty(PersistenceOptions.DEFAULT_ID_FEATURE_NAME , "id");
>>>
>>> Shouldn't that cause Teneo to recognisedall features named 'id' as
>>> the primary key?
>>>
>>>
>>> <xsd:complexType name="StatusChangeSubclass">
>>> <xsd:sequence>
>>> <xsd:element minOccurs="0" maxOccurs="1"
>>> ref="gensec:meetingType" />
>>> <xsd:element minOccurs="0" maxOccurs="1" ref="gensec:agent" />
>>> <xsd:element minOccurs="0" maxOccurs="1"
>>> ref="gensec:caeLifecycleType" />
>>> <xsd:element minOccurs="0" maxOccurs="1"
>>> ref="gensec:caeStatusType" />
>>> <xsd:element ref="gensec:caeType" />
>>> <xsd:element minOccurs="0" maxOccurs="1"
>>> ref="gensec:entityIdentifier" />
>>> <xsd:element minOccurs="0" maxOccurs="1"
>>> ref="gensec:indicatorsType" />
>>> <xsd:element minOccurs="0" maxOccurs="1"
>>> ref="gensec:instrumentIdentifier" />
>>> <xsd:element minOccurs="0" maxOccurs="1"
>>> ref="gensec:issuerRef" />
>>> <xsd:element minOccurs="0" maxOccurs="1"
>>> ref="gensec:dataValueChange" />
>>> <xsd:element minOccurs="0" maxOccurs="1" ref="gensec:source" />
>>> <xsd:element minOccurs="0" maxOccurs="1"
>>> ref="gensec:relatedTo" />
>>> </xsd:sequence>
>>> <xsd:attribute name="id" type="xsd:int" use="optional" />
>>> <xsd:attribute name="effectiveDate" type="xsd:dateTime"
>>> use="optional" />
>>> <xsd:attribute name="announcementDate" type="xsd:dateTime"
>>> use="optional" />
>>> <xsd:attribute name="meetingDate" type="xsd:dateTime"
>>> use="optional" />
>>> <xsd:attribute name="recordDate" type="xsd:dateTime"
>>> use="optional" />
>>> <xsd:attribute name="comment" type="xsd:string" use="optional" />
>>> <xsd:attribute name="documentURL" type="xsd:anyURI"
>>> use="optional" />
>>> <xsd:attribute name="caeIdentifier" type="xsd:string"
>>> use="optional" />
>>> <xsd:attribute name="eventDescription" type="xsd:string"
>>> use="optional" />
>>> <xsd:attribute name="caeDate" type="xsd:dateTime" use="optional" />
>>> </xsd:complexType>
>>>
>>>
>>> Thanks,
>>>
>>> David
>>>
>>> Martin Taal wrote:
>>>> Hi David,
>>>> This occurs because the type has an id attribute and you set the
>>>> PersistenceOptions.ID_COLUMN_NAME option to id. The
>>>> PersistenceOptions.ID_COLUMN_NAME option is used to set the
>>>> synthetic id column. The synthetic id is created if the type does
>>>> not have an explicit id column. So what happens is that you have an
>>>> id-attribute (which gets a column id) and because there is no
>>>> explicit id for the type a synthetic id is created (which also gets
>>>> column id).
>>>>
>>>> In your case you should annotate the id-feature with a @Id
>>>> annotation as you want to use that feature as the id (afaics).
>>>>
>>>> gr. Marrtin
>>>>
>>>> david wrote:
>>>>> Hi,
>>>>>
>>>>> I am getting and error I cannot see an obvious cause for .
>>>>>
>>>>> Based on the ecore generated from this
>>>>>
>>>>> <xsd:complexType name="StatusChangeSubclass">
>>>>> <xsd:sequence>
>>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>>> ref="gensec:meetingType" />
>>>>> <xsd:element minOccurs="0" maxOccurs="1" ref="gensec:agent" />
>>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>>> ref="gensec:caeLifecycleType" />
>>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>>> ref="gensec:caeStatusType" />
>>>>> <xsd:element ref="gensec:caeType" />
>>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>>> ref="gensec:entityIdentifier" />
>>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>>> ref="gensec:indicatorsType" />
>>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>>> ref="gensec:instrumentIdentifier" />
>>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>>> ref="gensec:issuerRef" />
>>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>>> ref="gensec:dataValueChange" />
>>>>> <xsd:element minOccurs="0" maxOccurs="1" ref="gensec:source" />
>>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>>> ref="gensec:relatedTo" />
>>>>> </xsd:sequence>
>>>>> <xsd:attribute name="id" type="xsd:int" use="optional" />
>>>>> <xsd:attribute name="effectiveDate" type="xsd:dateTime"
>>>>> use="optional" />
>>>>> <xsd:attribute name="announcementDate" type="xsd:dateTime"
>>>>> use="optional" />
>>>>> <xsd:attribute name="meetingDate" type="xsd:dateTime"
>>>>> use="optional" />
>>>>> <xsd:attribute name="recordDate" type="xsd:dateTime"
>>>>> use="optional" />
>>>>> <xsd:attribute name="comment" type="xsd:string" use="optional" />
>>>>> <xsd:attribute name="documentURL" type="xsd:anyURI"
>>>>> use="optional" />
>>>>> <xsd:attribute name="caeIdentifier" type="xsd:string"
>>>>> use="optional" />
>>>>> <xsd:attribute name="eventDescription" type="xsd:string"
>>>>> use="optional" />
>>>>> <xsd:attribute name="caeDate" type="xsd:dateTime"
>>>>> use="optional" />
>>>>> </xsd:complexType>
>>>>>
>>>>> I am using
>>>>>
>>>>>
>>>>> props.setProperty(PersistenceOptions.MAXIMUM_SQL_NAME_LENGTH , "30");
>>>>>
>>>>> props.setProperty(PersistenceOptions.JOIN_COLUMN_NAMING_STRA TEGY,
>>>>> "simple");
>>>>> props.setProperty(PersistenceOptions.ID_COLUMN_NAME, "id");
>>>>>
>>>>> props.setProperty(PersistenceOptions.ID_FEATURE_AS_PRIMARY_K EY,
>>>>> "false");
>>>>> props.setProperty(PersistenceOptions.ALSO_MAP_AS_CLASS,
>>>>> "false");
>>>>>
>>>>> props.setProperty(PersistenceOptions.DEFAULT_TEMPORAL_VALUE, "DATE");
>>>>>
>>>>> props.setProperty(PersistenceOptions.DISABLE_ECONTAINER_MAPP ING,
>>>>> "true");
>>>>> props.setProperty(PersistenceOptions.ALWAYS_VERSION, "false");
>>>>>
>>>>> props.setProperty(PersistenceOptions.ALWAYS_MAP_LIST_AS_BAG, "true");
>>>>> props.setProperty(PersistenceOptions.INHERITANCE_MAPPING,
>>>>> "JOINED");
>>>>>
>>>>> The ID_COLUMN_NAME option I read as meaning it recognises the model
>>>>> attribute with the name of "id" as the primary key
>>>>>
>>>>> There is only one id attribute, also in the ecore, so how come I
>>>>> get the following error?
>>>>>
>>>>> I use Eclise 3.3, JDK 5 and Teneo from the 23rd April
>>>>>
>>>>> Exception in thread "main" org.hibernate.MappingException: Repeated
>>>>> column in mapping for entity: StatusChangeSubclass column: id
>>>>> (should be mapped with insert="false" update="false")
>>>>> at
>>>>> org.hibernate.mapping.PersistentClass.checkColumnDuplication (PersistentClass.java:652)
>>>>>
>>>>> at
>>>>> org.hibernate.mapping.PersistentClass.checkPropertyColumnDup lication(PersistentClass.java:674)
>>>>>
>>>>>
>>>>> Thx.
>>>>>
>>>>> David
>>>>
>>>>
>>
>>
--
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] Unexpected repeated column error [message #618057 is a reply to message #122579] |
Fri, 16 May 2008 16:57 |
David Wynter Messages: 4624 Registered: July 2009 |
Senior Member |
|
|
Hi,
This is were it gets confusing, as below I mentioned the id is actually
an attribute, not an element. Since the annotations are contained within
an element I was not sure if this same mechanism can be used for adding
annotations to attributes as opposed to elements as all the examples show.
Is this valid?
<xsd:attribute name="id" type="xsd:int">
<xsd:annotation>
<xsd:appinfo source="teneo.jpa">@Id</xsd:appinfo>
</xsd:annotation>
</xsd:attribute>
Thx.
David
Martin Taal wrote:
> Hi David,
> I don't think that you need to delete the id element from the xsd
>
> There are many examples here, did you find it?
> http://www.elver.org/hibernate/ejb3_examples.html
>
> The id annotation in xml schema will be something like this:
> <xsd:element name="id" type="xsd:long">
> <xsd:annotation>
> <xsd:appinfo source="teneo.jpa">@Id</xsd:appinfo>
> </xsd:annotation>
> </xsd:element>
>
> You can check the jpa spec for the syntax of the annotations.
>
> or instead of setting the annotation in the xml schema then having the
> id element/attribute and set the option:
> props.setProperty(PersistenceOptions.DEFAULT_ID_FEATURE_NAME , "id")
> should work.
>
> gr. Martin
>
> david wrote:
>> Hi,
>>
>> I ended up deleting the Id columns out of the xsd, and using the
>>
>> props.setProperty(PersistenceOptions.ID_COLUMN_NAME, "id");
>> props.setProperty(PersistenceOptions.DEFAULT_ID_FEATURE_NAME ,
>> "id");
>>
>>
>> But to confirm would the annotation look like this
>>
>> <xsd:complexType name="StatusChangeSubclass">
>> <xsd:sequence>
>> <xsd:annotation>
>> <xsd:appinfo source="teneo.jpa">
>> @Id(name="Id")
>> </xsd:appinfo>
>> </xsd:annotation>
>> ....
>>
>> I could not find an explicit example amongst the samples on that page.
>>
>> Thx,
>>
>> David
>>
>>
>> Martin Taal wrote:
>>> Hi David,
>>> Yes you are right the DEFAULT_ID_FEATURE_NAME option should also work
>>> (forgot that one). You then don't need the @Id annotation or the
>>> ID_COLUMN_NAME option.
>>>
>>> The @Id is a standard jpa annotation. Here are some examples to
>>> define annotations in xml schema:
>>> http://www.elver.org/hibernate/ejb3_examples.html#schemasamp les
>>>
>>> gr. Martin
>>>
>>> david wrote:
>>>> Hi,
>>>>
>>>> I have been sifting through the elver website and cannot find the
>>>> documentation on the specific @Id annotation. I checked the EJV
>>>> Persistance document too, but it had Java annotations for the @Id.
>>>> It is not clear to me how you add the @Id annotation to an attribute
>>>> within the element in the xsd. Can you show me an example?
>>>>
>>>> Also adding this
>>>> props.setProperty(PersistenceOptions.DEFAULT_ID_FEATURE_NAME , "id");
>>>>
>>>> Shouldn't that cause Teneo to recognisedall features named 'id' as
>>>> the primary key?
>>>>
>>>>
>>>> <xsd:complexType name="StatusChangeSubclass">
>>>> <xsd:sequence>
>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>> ref="gensec:meetingType" />
>>>> <xsd:element minOccurs="0" maxOccurs="1" ref="gensec:agent" />
>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>> ref="gensec:caeLifecycleType" />
>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>> ref="gensec:caeStatusType" />
>>>> <xsd:element ref="gensec:caeType" />
>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>> ref="gensec:entityIdentifier" />
>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>> ref="gensec:indicatorsType" />
>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>> ref="gensec:instrumentIdentifier" />
>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>> ref="gensec:issuerRef" />
>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>> ref="gensec:dataValueChange" />
>>>> <xsd:element minOccurs="0" maxOccurs="1" ref="gensec:source" />
>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>> ref="gensec:relatedTo" />
>>>> </xsd:sequence>
>>>> <xsd:attribute name="id" type="xsd:int" use="optional" />
>>>> <xsd:attribute name="effectiveDate" type="xsd:dateTime"
>>>> use="optional" />
>>>> <xsd:attribute name="announcementDate" type="xsd:dateTime"
>>>> use="optional" />
>>>> <xsd:attribute name="meetingDate" type="xsd:dateTime"
>>>> use="optional" />
>>>> <xsd:attribute name="recordDate" type="xsd:dateTime"
>>>> use="optional" />
>>>> <xsd:attribute name="comment" type="xsd:string" use="optional" />
>>>> <xsd:attribute name="documentURL" type="xsd:anyURI"
>>>> use="optional" />
>>>> <xsd:attribute name="caeIdentifier" type="xsd:string"
>>>> use="optional" />
>>>> <xsd:attribute name="eventDescription" type="xsd:string"
>>>> use="optional" />
>>>> <xsd:attribute name="caeDate" type="xsd:dateTime"
>>>> use="optional" />
>>>> </xsd:complexType>
>>>>
>>>>
>>>> Thanks,
>>>>
>>>> David
>>>>
>>>> Martin Taal wrote:
>>>>> Hi David,
>>>>> This occurs because the type has an id attribute and you set the
>>>>> PersistenceOptions.ID_COLUMN_NAME option to id. The
>>>>> PersistenceOptions.ID_COLUMN_NAME option is used to set the
>>>>> synthetic id column. The synthetic id is created if the type does
>>>>> not have an explicit id column. So what happens is that you have an
>>>>> id-attribute (which gets a column id) and because there is no
>>>>> explicit id for the type a synthetic id is created (which also gets
>>>>> column id).
>>>>>
>>>>> In your case you should annotate the id-feature with a @Id
>>>>> annotation as you want to use that feature as the id (afaics).
>>>>>
>>>>> gr. Marrtin
>>>>>
>>>>> david wrote:
>>>>>> Hi,
>>>>>>
>>>>>> I am getting and error I cannot see an obvious cause for .
>>>>>>
>>>>>> Based on the ecore generated from this
>>>>>>
>>>>>> <xsd:complexType name="StatusChangeSubclass">
>>>>>> <xsd:sequence>
>>>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>>>> ref="gensec:meetingType" />
>>>>>> <xsd:element minOccurs="0" maxOccurs="1" ref="gensec:agent" />
>>>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>>>> ref="gensec:caeLifecycleType" />
>>>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>>>> ref="gensec:caeStatusType" />
>>>>>> <xsd:element ref="gensec:caeType" />
>>>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>>>> ref="gensec:entityIdentifier" />
>>>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>>>> ref="gensec:indicatorsType" />
>>>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>>>> ref="gensec:instrumentIdentifier" />
>>>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>>>> ref="gensec:issuerRef" />
>>>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>>>> ref="gensec:dataValueChange" />
>>>>>> <xsd:element minOccurs="0" maxOccurs="1" ref="gensec:source" />
>>>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>>>> ref="gensec:relatedTo" />
>>>>>> </xsd:sequence>
>>>>>> <xsd:attribute name="id" type="xsd:int" use="optional" />
>>>>>> <xsd:attribute name="effectiveDate" type="xsd:dateTime"
>>>>>> use="optional" />
>>>>>> <xsd:attribute name="announcementDate" type="xsd:dateTime"
>>>>>> use="optional" />
>>>>>> <xsd:attribute name="meetingDate" type="xsd:dateTime"
>>>>>> use="optional" />
>>>>>> <xsd:attribute name="recordDate" type="xsd:dateTime"
>>>>>> use="optional" />
>>>>>> <xsd:attribute name="comment" type="xsd:string" use="optional" />
>>>>>> <xsd:attribute name="documentURL" type="xsd:anyURI"
>>>>>> use="optional" />
>>>>>> <xsd:attribute name="caeIdentifier" type="xsd:string"
>>>>>> use="optional" />
>>>>>> <xsd:attribute name="eventDescription" type="xsd:string"
>>>>>> use="optional" />
>>>>>> <xsd:attribute name="caeDate" type="xsd:dateTime"
>>>>>> use="optional" />
>>>>>> </xsd:complexType>
>>>>>>
>>>>>> I am using
>>>>>>
>>>>>>
>>>>>> props.setProperty(PersistenceOptions.MAXIMUM_SQL_NAME_LENGTH , "30");
>>>>>>
>>>>>> props.setProperty(PersistenceOptions.JOIN_COLUMN_NAMING_STRA TEGY,
>>>>>> "simple");
>>>>>> props.setProperty(PersistenceOptions.ID_COLUMN_NAME, "id");
>>>>>>
>>>>>> props.setProperty(PersistenceOptions.ID_FEATURE_AS_PRIMARY_K EY,
>>>>>> "false");
>>>>>> props.setProperty(PersistenceOptions.ALSO_MAP_AS_CLASS,
>>>>>> "false");
>>>>>>
>>>>>> props.setProperty(PersistenceOptions.DEFAULT_TEMPORAL_VALUE, "DATE");
>>>>>>
>>>>>> props.setProperty(PersistenceOptions.DISABLE_ECONTAINER_MAPP ING,
>>>>>> "true");
>>>>>> props.setProperty(PersistenceOptions.ALWAYS_VERSION,
>>>>>> "false");
>>>>>>
>>>>>> props.setProperty(PersistenceOptions.ALWAYS_MAP_LIST_AS_BAG, "true");
>>>>>> props.setProperty(PersistenceOptions.INHERITANCE_MAPPING,
>>>>>> "JOINED");
>>>>>>
>>>>>> The ID_COLUMN_NAME option I read as meaning it recognises the
>>>>>> model attribute with the name of "id" as the primary key
>>>>>>
>>>>>> There is only one id attribute, also in the ecore, so how come I
>>>>>> get the following error?
>>>>>>
>>>>>> I use Eclise 3.3, JDK 5 and Teneo from the 23rd April
>>>>>>
>>>>>> Exception in thread "main" org.hibernate.MappingException:
>>>>>> Repeated column in mapping for entity: StatusChangeSubclass
>>>>>> column: id (should be mapped with insert="false" update="false")
>>>>>> at
>>>>>> org.hibernate.mapping.PersistentClass.checkColumnDuplication (PersistentClass.java:652)
>>>>>>
>>>>>> at
>>>>>> org.hibernate.mapping.PersistentClass.checkPropertyColumnDup lication(PersistentClass.java:674)
>>>>>>
>>>>>>
>>>>>> Thx.
>>>>>>
>>>>>> David
>>>>>
>>>>>
>>>
>>>
>
>
|
|
|
Re: [Teneo] Unexpected repeated column error [message #618058 is a reply to message #122597] |
Fri, 16 May 2008 17:03 |
Martin Taal Messages: 5468 Registered: July 2009 |
Senior Member |
|
|
Hi David,
It seems valid to me, you can check out if it works when you generate the java model code from this.
The @Id should then be somewhere in the generated PackageImpl as a string in the initialization code.
gr. Martin
david wrote:
> Hi,
>
> This is were it gets confusing, as below I mentioned the id is actually
> an attribute, not an element. Since the annotations are contained within
> an element I was not sure if this same mechanism can be used for adding
> annotations to attributes as opposed to elements as all the examples show.
>
> Is this valid?
>
> <xsd:attribute name="id" type="xsd:int">
> <xsd:annotation>
> <xsd:appinfo source="teneo.jpa">@Id</xsd:appinfo>
> </xsd:annotation>
> </xsd:attribute>
>
> Thx.
>
> David
>
> Martin Taal wrote:
>> Hi David,
>> I don't think that you need to delete the id element from the xsd
>>
>> There are many examples here, did you find it?
>> http://www.elver.org/hibernate/ejb3_examples.html
>>
>> The id annotation in xml schema will be something like this:
>> <xsd:element name="id" type="xsd:long">
>> <xsd:annotation>
>> <xsd:appinfo source="teneo.jpa">@Id</xsd:appinfo>
>> </xsd:annotation>
>> </xsd:element>
>>
>> You can check the jpa spec for the syntax of the annotations.
>>
>> or instead of setting the annotation in the xml schema then having the
>> id element/attribute and set the option:
>> props.setProperty(PersistenceOptions.DEFAULT_ID_FEATURE_NAME , "id")
>> should work.
>>
>> gr. Martin
>>
>> david wrote:
>>> Hi,
>>>
>>> I ended up deleting the Id columns out of the xsd, and using the
>>>
>>> props.setProperty(PersistenceOptions.ID_COLUMN_NAME, "id");
>>> props.setProperty(PersistenceOptions.DEFAULT_ID_FEATURE_NAME ,
>>> "id");
>>>
>>>
>>> But to confirm would the annotation look like this
>>>
>>> <xsd:complexType name="StatusChangeSubclass">
>>> <xsd:sequence>
>>> <xsd:annotation>
>>> <xsd:appinfo source="teneo.jpa">
>>> @Id(name="Id")
>>> </xsd:appinfo>
>>> </xsd:annotation>
>>> ....
>>>
>>> I could not find an explicit example amongst the samples on that page.
>>>
>>> Thx,
>>>
>>> David
>>>
>>>
>>> Martin Taal wrote:
>>>> Hi David,
>>>> Yes you are right the DEFAULT_ID_FEATURE_NAME option should also
>>>> work (forgot that one). You then don't need the @Id annotation or
>>>> the ID_COLUMN_NAME option.
>>>>
>>>> The @Id is a standard jpa annotation. Here are some examples to
>>>> define annotations in xml schema:
>>>> http://www.elver.org/hibernate/ejb3_examples.html#schemasamp les
>>>>
>>>> gr. Martin
>>>>
>>>> david wrote:
>>>>> Hi,
>>>>>
>>>>> I have been sifting through the elver website and cannot find the
>>>>> documentation on the specific @Id annotation. I checked the EJV
>>>>> Persistance document too, but it had Java annotations for the @Id.
>>>>> It is not clear to me how you add the @Id annotation to an
>>>>> attribute within the element in the xsd. Can you show me an example?
>>>>>
>>>>> Also adding this
>>>>> props.setProperty(PersistenceOptions.DEFAULT_ID_FEATURE_NAME , "id");
>>>>>
>>>>> Shouldn't that cause Teneo to recognisedall features named 'id' as
>>>>> the primary key?
>>>>>
>>>>>
>>>>> <xsd:complexType name="StatusChangeSubclass">
>>>>> <xsd:sequence>
>>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>>> ref="gensec:meetingType" />
>>>>> <xsd:element minOccurs="0" maxOccurs="1" ref="gensec:agent" />
>>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>>> ref="gensec:caeLifecycleType" />
>>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>>> ref="gensec:caeStatusType" />
>>>>> <xsd:element ref="gensec:caeType" />
>>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>>> ref="gensec:entityIdentifier" />
>>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>>> ref="gensec:indicatorsType" />
>>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>>> ref="gensec:instrumentIdentifier" />
>>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>>> ref="gensec:issuerRef" />
>>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>>> ref="gensec:dataValueChange" />
>>>>> <xsd:element minOccurs="0" maxOccurs="1" ref="gensec:source" />
>>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>>> ref="gensec:relatedTo" />
>>>>> </xsd:sequence>
>>>>> <xsd:attribute name="id" type="xsd:int" use="optional" />
>>>>> <xsd:attribute name="effectiveDate" type="xsd:dateTime"
>>>>> use="optional" />
>>>>> <xsd:attribute name="announcementDate" type="xsd:dateTime"
>>>>> use="optional" />
>>>>> <xsd:attribute name="meetingDate" type="xsd:dateTime"
>>>>> use="optional" />
>>>>> <xsd:attribute name="recordDate" type="xsd:dateTime"
>>>>> use="optional" />
>>>>> <xsd:attribute name="comment" type="xsd:string" use="optional" />
>>>>> <xsd:attribute name="documentURL" type="xsd:anyURI"
>>>>> use="optional" />
>>>>> <xsd:attribute name="caeIdentifier" type="xsd:string"
>>>>> use="optional" />
>>>>> <xsd:attribute name="eventDescription" type="xsd:string"
>>>>> use="optional" />
>>>>> <xsd:attribute name="caeDate" type="xsd:dateTime"
>>>>> use="optional" />
>>>>> </xsd:complexType>
>>>>>
>>>>>
>>>>> Thanks,
>>>>>
>>>>> David
>>>>>
>>>>> Martin Taal wrote:
>>>>>> Hi David,
>>>>>> This occurs because the type has an id attribute and you set the
>>>>>> PersistenceOptions.ID_COLUMN_NAME option to id. The
>>>>>> PersistenceOptions.ID_COLUMN_NAME option is used to set the
>>>>>> synthetic id column. The synthetic id is created if the type does
>>>>>> not have an explicit id column. So what happens is that you have
>>>>>> an id-attribute (which gets a column id) and because there is no
>>>>>> explicit id for the type a synthetic id is created (which also
>>>>>> gets column id).
>>>>>>
>>>>>> In your case you should annotate the id-feature with a @Id
>>>>>> annotation as you want to use that feature as the id (afaics).
>>>>>>
>>>>>> gr. Marrtin
>>>>>>
>>>>>> david wrote:
>>>>>>> Hi,
>>>>>>>
>>>>>>> I am getting and error I cannot see an obvious cause for .
>>>>>>>
>>>>>>> Based on the ecore generated from this
>>>>>>>
>>>>>>> <xsd:complexType name="StatusChangeSubclass">
>>>>>>> <xsd:sequence>
>>>>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>>>>> ref="gensec:meetingType" />
>>>>>>> <xsd:element minOccurs="0" maxOccurs="1" ref="gensec:agent" />
>>>>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>>>>> ref="gensec:caeLifecycleType" />
>>>>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>>>>> ref="gensec:caeStatusType" />
>>>>>>> <xsd:element ref="gensec:caeType" />
>>>>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>>>>> ref="gensec:entityIdentifier" />
>>>>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>>>>> ref="gensec:indicatorsType" />
>>>>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>>>>> ref="gensec:instrumentIdentifier" />
>>>>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>>>>> ref="gensec:issuerRef" />
>>>>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>>>>> ref="gensec:dataValueChange" />
>>>>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>>>>> ref="gensec:source" />
>>>>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>>>>> ref="gensec:relatedTo" />
>>>>>>> </xsd:sequence>
>>>>>>> <xsd:attribute name="id" type="xsd:int" use="optional" />
>>>>>>> <xsd:attribute name="effectiveDate" type="xsd:dateTime"
>>>>>>> use="optional" />
>>>>>>> <xsd:attribute name="announcementDate" type="xsd:dateTime"
>>>>>>> use="optional" />
>>>>>>> <xsd:attribute name="meetingDate" type="xsd:dateTime"
>>>>>>> use="optional" />
>>>>>>> <xsd:attribute name="recordDate" type="xsd:dateTime"
>>>>>>> use="optional" />
>>>>>>> <xsd:attribute name="comment" type="xsd:string"
>>>>>>> use="optional" />
>>>>>>> <xsd:attribute name="documentURL" type="xsd:anyURI"
>>>>>>> use="optional" />
>>>>>>> <xsd:attribute name="caeIdentifier" type="xsd:string"
>>>>>>> use="optional" />
>>>>>>> <xsd:attribute name="eventDescription" type="xsd:string"
>>>>>>> use="optional" />
>>>>>>> <xsd:attribute name="caeDate" type="xsd:dateTime"
>>>>>>> use="optional" />
>>>>>>> </xsd:complexType>
>>>>>>>
>>>>>>> I am using
>>>>>>>
>>>>>>>
>>>>>>> props.setProperty(PersistenceOptions.MAXIMUM_SQL_NAME_LENGTH , "30");
>>>>>>>
>>>>>>> props.setProperty(PersistenceOptions.JOIN_COLUMN_NAMING_STRA TEGY,
>>>>>>> "simple");
>>>>>>> props.setProperty(PersistenceOptions.ID_COLUMN_NAME, "id");
>>>>>>>
>>>>>>> props.setProperty(PersistenceOptions.ID_FEATURE_AS_PRIMARY_K EY,
>>>>>>> "false");
>>>>>>> props.setProperty(PersistenceOptions.ALSO_MAP_AS_CLASS,
>>>>>>> "false");
>>>>>>>
>>>>>>> props.setProperty(PersistenceOptions.DEFAULT_TEMPORAL_VALUE,
>>>>>>> "DATE");
>>>>>>>
>>>>>>> props.setProperty(PersistenceOptions.DISABLE_ECONTAINER_MAPP ING,
>>>>>>> "true");
>>>>>>> props.setProperty(PersistenceOptions.ALWAYS_VERSION,
>>>>>>> "false");
>>>>>>>
>>>>>>> props.setProperty(PersistenceOptions.ALWAYS_MAP_LIST_AS_BAG,
>>>>>>> "true");
>>>>>>> props.setProperty(PersistenceOptions.INHERITANCE_MAPPING,
>>>>>>> "JOINED");
>>>>>>>
>>>>>>> The ID_COLUMN_NAME option I read as meaning it recognises the
>>>>>>> model attribute with the name of "id" as the primary key
>>>>>>>
>>>>>>> There is only one id attribute, also in the ecore, so how come I
>>>>>>> get the following error?
>>>>>>>
>>>>>>> I use Eclise 3.3, JDK 5 and Teneo from the 23rd April
>>>>>>>
>>>>>>> Exception in thread "main" org.hibernate.MappingException:
>>>>>>> Repeated column in mapping for entity: StatusChangeSubclass
>>>>>>> column: id (should be mapped with insert="false" update="false")
>>>>>>> at
>>>>>>> org.hibernate.mapping.PersistentClass.checkColumnDuplication (PersistentClass.java:652)
>>>>>>>
>>>>>>> at
>>>>>>> org.hibernate.mapping.PersistentClass.checkPropertyColumnDup lication(PersistentClass.java:674)
>>>>>>>
>>>>>>>
>>>>>>> Thx.
>>>>>>>
>>>>>>> David
>>>>>>
>>>>>>
>>>>
>>>>
>>
>>
--
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] Unexpected repeated column error [message #618121 is a reply to message #122607] |
Thu, 22 May 2008 11:07 |
David Wynter Messages: 4624 Registered: July 2009 |
Senior Member |
|
|
Hi,
I have these options,
props.setProperty(Environment.DRIVER, "com.mysql.jdbc.Driver");
props.setProperty(Environment.USER, "tLoader");
props.setProperty(Environment.PASS, "pass34w0rd");
props.setProperty(Environment.URL, "jdbc:mysql://192.168.0.3:3306/"
+ dbName);
props.setProperty(Environment.DIALECT,
org.hibernate.dialect.MySQLInnoDBDialect.class.getName());
props.setProperty(PersistenceOptions.MAXIMUM_SQL_NAME_LENGTH ,
"30");
props.setProperty(PersistenceOptions.ID_FEATURE_AS_PRIMARY_K EY,
"true");
props.setProperty(PersistenceOptions.DEFAULT_ID_FEATURE_NAME ,
"id");
props.setProperty(PersistenceOptions.JOIN_COLUMN_NAMING_STRA TEGY, "simple");
props.setProperty(PersistenceOptions.ALSO_MAP_AS_CLASS, "false");
props.setProperty(PersistenceOptions.DEFAULT_TEMPORAL_VALUE,
"DATE");
props.setProperty(PersistenceOptions.DISABLE_ECONTAINER_MAPP ING, "true");
props.setProperty(PersistenceOptions.ALWAYS_VERSION, "false");
props.setProperty(PersistenceOptions.ALWAYS_MAP_LIST_AS_BAG,
"true");
props.setProperty(PersistenceOptions.INHERITANCE_MAPPING,
"JOINED");
I added the
<xsd:attribute name="id" type="xsd:int">
<xsd:annotation>
<xsd:appinfo source="teneo.jpa">@Id</xsd:appinfo>
</xsd:annotation>
</xsd:attribute>
to all my elements.
But I still get the e_id being produced as the primary key and the id
column is not being used?
Thx.
David
Martin Taal wrote:
> Hi David,
> It seems valid to me, you can check out if it works when you generate
> the java model code from this. The @Id should then be somewhere in the
> generated PackageImpl as a string in the initialization code.
>
> gr. Martin
>
> david wrote:
>> Hi,
>>
>> This is were it gets confusing, as below I mentioned the id is
>> actually an attribute, not an element. Since the annotations are
>> contained within an element I was not sure if this same mechanism can
>> be used for adding annotations to attributes as opposed to elements as
>> all the examples show.
>>
>> Is this valid?
>>
>> <xsd:attribute name="id" type="xsd:int">
>> <xsd:annotation>
>> <xsd:appinfo source="teneo.jpa">@Id</xsd:appinfo>
>> </xsd:annotation>
>> </xsd:attribute>
>>
>> Thx.
>>
>> David
>>
>> Martin Taal wrote:
>>> Hi David,
>>> I don't think that you need to delete the id element from the xsd
>>>
>>> There are many examples here, did you find it?
>>> http://www.elver.org/hibernate/ejb3_examples.html
>>>
>>> The id annotation in xml schema will be something like this:
>>> <xsd:element name="id" type="xsd:long">
>>> <xsd:annotation>
>>> <xsd:appinfo source="teneo.jpa">@Id</xsd:appinfo>
>>> </xsd:annotation>
>>> </xsd:element>
>>>
>>> You can check the jpa spec for the syntax of the annotations.
>>>
>>> or instead of setting the annotation in the xml schema then having
>>> the id element/attribute and set the option:
>>> props.setProperty(PersistenceOptions.DEFAULT_ID_FEATURE_NAME , "id")
>>> should work.
>>>
>>> gr. Martin
>>>
>>> david wrote:
>>>> Hi,
>>>>
>>>> I ended up deleting the Id columns out of the xsd, and using the
>>>>
>>>> props.setProperty(PersistenceOptions.ID_COLUMN_NAME, "id");
>>>>
>>>> props.setProperty(PersistenceOptions.DEFAULT_ID_FEATURE_NAME , "id");
>>>>
>>>>
>>>> But to confirm would the annotation look like this
>>>>
>>>> <xsd:complexType name="StatusChangeSubclass">
>>>> <xsd:sequence>
>>>> <xsd:annotation>
>>>> <xsd:appinfo source="teneo.jpa">
>>>> @Id(name="Id")
>>>> </xsd:appinfo>
>>>> </xsd:annotation>
>>>> ....
>>>>
>>>> I could not find an explicit example amongst the samples on that page.
>>>>
>>>> Thx,
>>>>
>>>> David
>>>>
>>>>
>>>> Martin Taal wrote:
>>>>> Hi David,
>>>>> Yes you are right the DEFAULT_ID_FEATURE_NAME option should also
>>>>> work (forgot that one). You then don't need the @Id annotation or
>>>>> the ID_COLUMN_NAME option.
>>>>>
>>>>> The @Id is a standard jpa annotation. Here are some examples to
>>>>> define annotations in xml schema:
>>>>> http://www.elver.org/hibernate/ejb3_examples.html#schemasamp les
>>>>>
>>>>> gr. Martin
>>>>>
>>>>> david wrote:
>>>>>> Hi,
>>>>>>
>>>>>> I have been sifting through the elver website and cannot find the
>>>>>> documentation on the specific @Id annotation. I checked the EJV
>>>>>> Persistance document too, but it had Java annotations for the @Id.
>>>>>> It is not clear to me how you add the @Id annotation to an
>>>>>> attribute within the element in the xsd. Can you show me an example?
>>>>>>
>>>>>> Also adding this
>>>>>> props.setProperty(PersistenceOptions.DEFAULT_ID_FEATURE_NAME , "id");
>>>>>>
>>>>>> Shouldn't that cause Teneo to recognisedall features named 'id' as
>>>>>> the primary key?
>>>>>>
>>>>>>
>>>>>> <xsd:complexType name="StatusChangeSubclass">
>>>>>> <xsd:sequence>
>>>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>>>> ref="gensec:meetingType" />
>>>>>> <xsd:element minOccurs="0" maxOccurs="1" ref="gensec:agent" />
>>>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>>>> ref="gensec:caeLifecycleType" />
>>>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>>>> ref="gensec:caeStatusType" />
>>>>>> <xsd:element ref="gensec:caeType" />
>>>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>>>> ref="gensec:entityIdentifier" />
>>>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>>>> ref="gensec:indicatorsType" />
>>>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>>>> ref="gensec:instrumentIdentifier" />
>>>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>>>> ref="gensec:issuerRef" />
>>>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>>>> ref="gensec:dataValueChange" />
>>>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>>>> ref="gensec:source" />
>>>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>>>> ref="gensec:relatedTo" />
>>>>>> </xsd:sequence>
>>>>>> <xsd:attribute name="id" type="xsd:int" use="optional" />
>>>>>> <xsd:attribute name="effectiveDate" type="xsd:dateTime"
>>>>>> use="optional" />
>>>>>> <xsd:attribute name="announcementDate" type="xsd:dateTime"
>>>>>> use="optional" />
>>>>>> <xsd:attribute name="meetingDate" type="xsd:dateTime"
>>>>>> use="optional" />
>>>>>> <xsd:attribute name="recordDate" type="xsd:dateTime"
>>>>>> use="optional" />
>>>>>> <xsd:attribute name="comment" type="xsd:string"
>>>>>> use="optional" />
>>>>>> <xsd:attribute name="documentURL" type="xsd:anyURI"
>>>>>> use="optional" />
>>>>>> <xsd:attribute name="caeIdentifier" type="xsd:string"
>>>>>> use="optional" />
>>>>>> <xsd:attribute name="eventDescription" type="xsd:string"
>>>>>> use="optional" />
>>>>>> <xsd:attribute name="caeDate" type="xsd:dateTime"
>>>>>> use="optional" />
>>>>>> </xsd:complexType>
>>>>>>
>>>>>>
>>>>>> Thanks,
>>>>>>
>>>>>> David
>>>>>>
>>>>>> Martin Taal wrote:
>>>>>>> Hi David,
>>>>>>> This occurs because the type has an id attribute and you set the
>>>>>>> PersistenceOptions.ID_COLUMN_NAME option to id. The
>>>>>>> PersistenceOptions.ID_COLUMN_NAME option is used to set the
>>>>>>> synthetic id column. The synthetic id is created if the type does
>>>>>>> not have an explicit id column. So what happens is that you have
>>>>>>> an id-attribute (which gets a column id) and because there is no
>>>>>>> explicit id for the type a synthetic id is created (which also
>>>>>>> gets column id).
>>>>>>>
>>>>>>> In your case you should annotate the id-feature with a @Id
>>>>>>> annotation as you want to use that feature as the id (afaics).
>>>>>>>
>>>>>>> gr. Marrtin
>>>>>>>
>>>>>>> david wrote:
>>>>>>>> Hi,
>>>>>>>>
>>>>>>>> I am getting and error I cannot see an obvious cause for .
>>>>>>>>
>>>>>>>> Based on the ecore generated from this
>>>>>>>>
>>>>>>>> <xsd:complexType name="StatusChangeSubclass">
>>>>>>>> <xsd:sequence>
>>>>>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>>>>>> ref="gensec:meetingType" />
>>>>>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>>>>>> ref="gensec:agent" />
>>>>>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>>>>>> ref="gensec:caeLifecycleType" />
>>>>>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>>>>>> ref="gensec:caeStatusType" />
>>>>>>>> <xsd:element ref="gensec:caeType" />
>>>>>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>>>>>> ref="gensec:entityIdentifier" />
>>>>>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>>>>>> ref="gensec:indicatorsType" />
>>>>>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>>>>>> ref="gensec:instrumentIdentifier" />
>>>>>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>>>>>> ref="gensec:issuerRef" />
>>>>>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>>>>>> ref="gensec:dataValueChange" />
>>>>>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>>>>>> ref="gensec:source" />
>>>>>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>>>>>> ref="gensec:relatedTo" />
>>>>>>>> </xsd:sequence>
>>>>>>>> <xsd:attribute name="id" type="xsd:int" use="optional" />
>>>>>>>> <xsd:attribute name="effectiveDate" type="xsd:dateTime"
>>>>>>>> use="optional" />
>>>>>>>> <xsd:attribute name="announcementDate" type="xsd:dateTime"
>>>>>>>> use="optional" />
>>>>>>>> <xsd:attribute name="meetingDate" type="xsd:dateTime"
>>>>>>>> use="optional" />
>>>>>>>> <xsd:attribute name="recordDate" type="xsd:dateTime"
>>>>>>>> use="optional" />
>>>>>>>> <xsd:attribute name="comment" type="xsd:string"
>>>>>>>> use="optional" />
>>>>>>>> <xsd:attribute name="documentURL" type="xsd:anyURI"
>>>>>>>> use="optional" />
>>>>>>>> <xsd:attribute name="caeIdentifier" type="xsd:string"
>>>>>>>> use="optional" />
>>>>>>>> <xsd:attribute name="eventDescription" type="xsd:string"
>>>>>>>> use="optional" />
>>>>>>>> <xsd:attribute name="caeDate" type="xsd:dateTime"
>>>>>>>> use="optional" />
>>>>>>>> </xsd:complexType>
>>>>>>>>
>>>>>>>> I am using
>>>>>>>>
>>>>>>>>
>>>>>>>> props.setProperty(PersistenceOptions.MAXIMUM_SQL_NAME_LENGTH ,
>>>>>>>> "30");
>>>>>>>>
>>>>>>>> props.setProperty(PersistenceOptions.JOIN_COLUMN_NAMING_STRA TEGY,
>>>>>>>> "simple");
>>>>>>>> props.setProperty(PersistenceOptions.ID_COLUMN_NAME, "id");
>>>>>>>>
>>>>>>>> props.setProperty(PersistenceOptions.ID_FEATURE_AS_PRIMARY_K EY,
>>>>>>>> "false");
>>>>>>>> props.setProperty(PersistenceOptions.ALSO_MAP_AS_CLASS,
>>>>>>>> "false");
>>>>>>>>
>>>>>>>> props.setProperty(PersistenceOptions.DEFAULT_TEMPORAL_VALUE,
>>>>>>>> "DATE");
>>>>>>>>
>>>>>>>> props.setProperty(PersistenceOptions.DISABLE_ECONTAINER_MAPP ING,
>>>>>>>> "true");
>>>>>>>> props.setProperty(PersistenceOptions.ALWAYS_VERSION,
>>>>>>>> "false");
>>>>>>>>
>>>>>>>> props.setProperty(PersistenceOptions.ALWAYS_MAP_LIST_AS_BAG,
>>>>>>>> "true");
>>>>>>>>
>>>>>>>> props.setProperty(PersistenceOptions.INHERITANCE_MAPPING,
>>>>>>>> "JOINED");
>>>>>>>>
>>>>>>>> The ID_COLUMN_NAME option I read as meaning it recognises the
>>>>>>>> model attribute with the name of "id" as the primary key
>>>>>>>>
>>>>>>>> There is only one id attribute, also in the ecore, so how come I
>>>>>>>> get the following error?
>>>>>>>>
>>>>>>>> I use Eclise 3.3, JDK 5 and Teneo from the 23rd April
>>>>>>>>
>>>>>>>> Exception in thread "main" org.hibernate.MappingException:
>>>>>>>> Repeated column in mapping for entity: StatusChangeSubclass
>>>>>>>> column: id (should be mapped with insert="false" update="false")
>>>>>>>> at
>>>>>>>> org.hibernate.mapping.PersistentClass.checkColumnDuplication (PersistentClass.java:652)
>>>>>>>>
>>>>>>>> at
>>>>>>>> org.hibernate.mapping.PersistentClass.checkPropertyColumnDup lication(PersistentClass.java:674)
>>>>>>>>
>>>>>>>>
>>>>>>>> Thx.
>>>>>>>>
>>>>>>>> David
>>>>>>>
>>>>>>>
>>>>>
>>>>>
>>>
>>>
>
>
|
|
|
Re: [Teneo] Unexpected repeated column error [message #618124 is a reply to message #122832] |
Thu, 22 May 2008 11:15 |
Martin Taal Messages: 5468 Registered: July 2009 |
Senior Member |
|
|
Hi David,
You did do a reload of the genmodel and regenerate of the java code?
Can you see the annotation in the generated PackageImpl somewhere?
Can you post the hbm which maps the id attribute and the id of the entity itself?
gr. Martin
david wrote:
> Hi,
>
> I have these options,
>
> props.setProperty(Environment.DRIVER, "com.mysql.jdbc.Driver");
> props.setProperty(Environment.USER, "tLoader");
> props.setProperty(Environment.PASS, "pass34w0rd");
> props.setProperty(Environment.URL,
> "jdbc:mysql://192.168.0.3:3306/" + dbName);
> props.setProperty(Environment.DIALECT,
> org.hibernate.dialect.MySQLInnoDBDialect.class.getName());
> props.setProperty(PersistenceOptions.MAXIMUM_SQL_NAME_LENGTH ,
> "30");
> props.setProperty(PersistenceOptions.ID_FEATURE_AS_PRIMARY_K EY,
> "true");
> props.setProperty(PersistenceOptions.DEFAULT_ID_FEATURE_NAME ,
> "id");
>
> props.setProperty(PersistenceOptions.JOIN_COLUMN_NAMING_STRA TEGY,
> "simple");
> props.setProperty(PersistenceOptions.ALSO_MAP_AS_CLASS, "false");
> props.setProperty(PersistenceOptions.DEFAULT_TEMPORAL_VALUE,
> "DATE");
>
> props.setProperty(PersistenceOptions.DISABLE_ECONTAINER_MAPP ING, "true");
> props.setProperty(PersistenceOptions.ALWAYS_VERSION, "false");
> props.setProperty(PersistenceOptions.ALWAYS_MAP_LIST_AS_BAG,
> "true");
> props.setProperty(PersistenceOptions.INHERITANCE_MAPPING,
> "JOINED");
>
>
> I added the
>
> <xsd:attribute name="id" type="xsd:int">
> <xsd:annotation>
> <xsd:appinfo source="teneo.jpa">@Id</xsd:appinfo>
> </xsd:annotation>
> </xsd:attribute>
>
> to all my elements.
>
> But I still get the e_id being produced as the primary key and the id
> column is not being used?
>
> Thx.
>
> David
>
>
>
> Martin Taal wrote:
>> Hi David,
>> It seems valid to me, you can check out if it works when you generate
>> the java model code from this. The @Id should then be somewhere in the
>> generated PackageImpl as a string in the initialization code.
>>
>> gr. Martin
>>
>> david wrote:
>>> Hi,
>>>
>>> This is were it gets confusing, as below I mentioned the id is
>>> actually an attribute, not an element. Since the annotations are
>>> contained within an element I was not sure if this same mechanism can
>>> be used for adding annotations to attributes as opposed to elements
>>> as all the examples show.
>>>
>>> Is this valid?
>>>
>>> <xsd:attribute name="id" type="xsd:int">
>>> <xsd:annotation>
>>> <xsd:appinfo source="teneo.jpa">@Id</xsd:appinfo>
>>> </xsd:annotation>
>>> </xsd:attribute>
>>>
>>> Thx.
>>>
>>> David
>>>
>>> Martin Taal wrote:
>>>> Hi David,
>>>> I don't think that you need to delete the id element from the xsd
>>>>
>>>> There are many examples here, did you find it?
>>>> http://www.elver.org/hibernate/ejb3_examples.html
>>>>
>>>> The id annotation in xml schema will be something like this:
>>>> <xsd:element name="id" type="xsd:long">
>>>> <xsd:annotation>
>>>> <xsd:appinfo source="teneo.jpa">@Id</xsd:appinfo>
>>>> </xsd:annotation>
>>>> </xsd:element>
>>>>
>>>> You can check the jpa spec for the syntax of the annotations.
>>>>
>>>> or instead of setting the annotation in the xml schema then having
>>>> the id element/attribute and set the option:
>>>> props.setProperty(PersistenceOptions.DEFAULT_ID_FEATURE_NAME , "id")
>>>> should work.
>>>>
>>>> gr. Martin
>>>>
>>>> david wrote:
>>>>> Hi,
>>>>>
>>>>> I ended up deleting the Id columns out of the xsd, and using the
>>>>>
>>>>> props.setProperty(PersistenceOptions.ID_COLUMN_NAME, "id");
>>>>>
>>>>> props.setProperty(PersistenceOptions.DEFAULT_ID_FEATURE_NAME , "id");
>>>>>
>>>>>
>>>>> But to confirm would the annotation look like this
>>>>>
>>>>> <xsd:complexType name="StatusChangeSubclass">
>>>>> <xsd:sequence>
>>>>> <xsd:annotation>
>>>>> <xsd:appinfo source="teneo.jpa">
>>>>> @Id(name="Id")
>>>>> </xsd:appinfo>
>>>>> </xsd:annotation>
>>>>> ....
>>>>>
>>>>> I could not find an explicit example amongst the samples on that page.
>>>>>
>>>>> Thx,
>>>>>
>>>>> David
>>>>>
>>>>>
>>>>> Martin Taal wrote:
>>>>>> Hi David,
>>>>>> Yes you are right the DEFAULT_ID_FEATURE_NAME option should also
>>>>>> work (forgot that one). You then don't need the @Id annotation or
>>>>>> the ID_COLUMN_NAME option.
>>>>>>
>>>>>> The @Id is a standard jpa annotation. Here are some examples to
>>>>>> define annotations in xml schema:
>>>>>> http://www.elver.org/hibernate/ejb3_examples.html#schemasamp les
>>>>>>
>>>>>> gr. Martin
>>>>>>
>>>>>> david wrote:
>>>>>>> Hi,
>>>>>>>
>>>>>>> I have been sifting through the elver website and cannot find the
>>>>>>> documentation on the specific @Id annotation. I checked the EJV
>>>>>>> Persistance document too, but it had Java annotations for the
>>>>>>> @Id. It is not clear to me how you add the @Id annotation to an
>>>>>>> attribute within the element in the xsd. Can you show me an example?
>>>>>>>
>>>>>>> Also adding this
>>>>>>> props.setProperty(PersistenceOptions.DEFAULT_ID_FEATURE_NAME , "id");
>>>>>>>
>>>>>>> Shouldn't that cause Teneo to recognisedall features named 'id'
>>>>>>> as the primary key?
>>>>>>>
>>>>>>>
>>>>>>> <xsd:complexType name="StatusChangeSubclass">
>>>>>>> <xsd:sequence>
>>>>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>>>>> ref="gensec:meetingType" />
>>>>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>>>>> ref="gensec:agent" />
>>>>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>>>>> ref="gensec:caeLifecycleType" />
>>>>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>>>>> ref="gensec:caeStatusType" />
>>>>>>> <xsd:element ref="gensec:caeType" />
>>>>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>>>>> ref="gensec:entityIdentifier" />
>>>>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>>>>> ref="gensec:indicatorsType" />
>>>>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>>>>> ref="gensec:instrumentIdentifier" />
>>>>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>>>>> ref="gensec:issuerRef" />
>>>>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>>>>> ref="gensec:dataValueChange" />
>>>>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>>>>> ref="gensec:source" />
>>>>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>>>>> ref="gensec:relatedTo" />
>>>>>>> </xsd:sequence>
>>>>>>> <xsd:attribute name="id" type="xsd:int" use="optional" />
>>>>>>> <xsd:attribute name="effectiveDate" type="xsd:dateTime"
>>>>>>> use="optional" />
>>>>>>> <xsd:attribute name="announcementDate" type="xsd:dateTime"
>>>>>>> use="optional" />
>>>>>>> <xsd:attribute name="meetingDate" type="xsd:dateTime"
>>>>>>> use="optional" />
>>>>>>> <xsd:attribute name="recordDate" type="xsd:dateTime"
>>>>>>> use="optional" />
>>>>>>> <xsd:attribute name="comment" type="xsd:string"
>>>>>>> use="optional" />
>>>>>>> <xsd:attribute name="documentURL" type="xsd:anyURI"
>>>>>>> use="optional" />
>>>>>>> <xsd:attribute name="caeIdentifier" type="xsd:string"
>>>>>>> use="optional" />
>>>>>>> <xsd:attribute name="eventDescription" type="xsd:string"
>>>>>>> use="optional" />
>>>>>>> <xsd:attribute name="caeDate" type="xsd:dateTime"
>>>>>>> use="optional" />
>>>>>>> </xsd:complexType>
>>>>>>>
>>>>>>>
>>>>>>> Thanks,
>>>>>>>
>>>>>>> David
>>>>>>>
>>>>>>> Martin Taal wrote:
>>>>>>>> Hi David,
>>>>>>>> This occurs because the type has an id attribute and you set the
>>>>>>>> PersistenceOptions.ID_COLUMN_NAME option to id. The
>>>>>>>> PersistenceOptions.ID_COLUMN_NAME option is used to set the
>>>>>>>> synthetic id column. The synthetic id is created if the type
>>>>>>>> does not have an explicit id column. So what happens is that you
>>>>>>>> have an id-attribute (which gets a column id) and because there
>>>>>>>> is no explicit id for the type a synthetic id is created (which
>>>>>>>> also gets column id).
>>>>>>>>
>>>>>>>> In your case you should annotate the id-feature with a @Id
>>>>>>>> annotation as you want to use that feature as the id (afaics).
>>>>>>>>
>>>>>>>> gr. Marrtin
>>>>>>>>
>>>>>>>> david wrote:
>>>>>>>>> Hi,
>>>>>>>>>
>>>>>>>>> I am getting and error I cannot see an obvious cause for .
>>>>>>>>>
>>>>>>>>> Based on the ecore generated from this
>>>>>>>>>
>>>>>>>>> <xsd:complexType name="StatusChangeSubclass">
>>>>>>>>> <xsd:sequence>
>>>>>>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>>>>>>> ref="gensec:meetingType" />
>>>>>>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>>>>>>> ref="gensec:agent" />
>>>>>>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>>>>>>> ref="gensec:caeLifecycleType" />
>>>>>>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>>>>>>> ref="gensec:caeStatusType" />
>>>>>>>>> <xsd:element ref="gensec:caeType" />
>>>>>>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>>>>>>> ref="gensec:entityIdentifier" />
>>>>>>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>>>>>>> ref="gensec:indicatorsType" />
>>>>>>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>>>>>>> ref="gensec:instrumentIdentifier" />
>>>>>>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>>>>>>> ref="gensec:issuerRef" />
>>>>>>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>>>>>>> ref="gensec:dataValueChange" />
>>>>>>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>>>>>>> ref="gensec:source" />
>>>>>>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>>>>>>> ref="gensec:relatedTo" />
>>>>>>>>> </xsd:sequence>
>>>>>>>>> <xsd:attribute name="id" type="xsd:int" use="optional" />
>>>>>>>>> <xsd:attribute name="effectiveDate" type="xsd:dateTime"
>>>>>>>>> use="optional" />
>>>>>>>>> <xsd:attribute name="announcementDate" type="xsd:dateTime"
>>>>>>>>> use="optional" />
>>>>>>>>> <xsd:attribute name="meetingDate" type="xsd:dateTime"
>>>>>>>>> use="optional" />
>>>>>>>>> <xsd:attribute name="recordDate" type="xsd:dateTime"
>>>>>>>>> use="optional" />
>>>>>>>>> <xsd:attribute name="comment" type="xsd:string"
>>>>>>>>> use="optional" />
>>>>>>>>> <xsd:attribute name="documentURL" type="xsd:anyURI"
>>>>>>>>> use="optional" />
>>>>>>>>> <xsd:attribute name="caeIdentifier" type="xsd:string"
>>>>>>>>> use="optional" />
>>>>>>>>> <xsd:attribute name="eventDescription" type="xsd:string"
>>>>>>>>> use="optional" />
>>>>>>>>> <xsd:attribute name="caeDate" type="xsd:dateTime"
>>>>>>>>> use="optional" />
>>>>>>>>> </xsd:complexType>
>>>>>>>>>
>>>>>>>>> I am using
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> props.setProperty(PersistenceOptions.MAXIMUM_SQL_NAME_LENGTH ,
>>>>>>>>> "30");
>>>>>>>>>
>>>>>>>>> props.setProperty(PersistenceOptions.JOIN_COLUMN_NAMING_STRA TEGY,
>>>>>>>>> "simple");
>>>>>>>>> props.setProperty(PersistenceOptions.ID_COLUMN_NAME,
>>>>>>>>> "id");
>>>>>>>>>
>>>>>>>>> props.setProperty(PersistenceOptions.ID_FEATURE_AS_PRIMARY_K EY,
>>>>>>>>> "false");
>>>>>>>>> props.setProperty(PersistenceOptions.ALSO_MAP_AS_CLASS,
>>>>>>>>> "false");
>>>>>>>>>
>>>>>>>>> props.setProperty(PersistenceOptions.DEFAULT_TEMPORAL_VALUE,
>>>>>>>>> "DATE");
>>>>>>>>>
>>>>>>>>> props.setProperty(PersistenceOptions.DISABLE_ECONTAINER_MAPP ING,
>>>>>>>>> "true");
>>>>>>>>> props.setProperty(PersistenceOptions.ALWAYS_VERSION,
>>>>>>>>> "false");
>>>>>>>>>
>>>>>>>>> props.setProperty(PersistenceOptions.ALWAYS_MAP_LIST_AS_BAG,
>>>>>>>>> "true");
>>>>>>>>>
>>>>>>>>> props.setProperty(PersistenceOptions.INHERITANCE_MAPPING,
>>>>>>>>> "JOINED");
>>>>>>>>>
>>>>>>>>> The ID_COLUMN_NAME option I read as meaning it recognises the
>>>>>>>>> model attribute with the name of "id" as the primary key
>>>>>>>>>
>>>>>>>>> There is only one id attribute, also in the ecore, so how come
>>>>>>>>> I get the following error?
>>>>>>>>>
>>>>>>>>> I use Eclise 3.3, JDK 5 and Teneo from the 23rd April
>>>>>>>>>
>>>>>>>>> Exception in thread "main" org.hibernate.MappingException:
>>>>>>>>> Repeated column in mapping for entity: StatusChangeSubclass
>>>>>>>>> column: id (should be mapped with insert="false" update="false")
>>>>>>>>> at
>>>>>>>>> org.hibernate.mapping.PersistentClass.checkColumnDuplication (PersistentClass.java:652)
>>>>>>>>>
>>>>>>>>> at
>>>>>>>>> org.hibernate.mapping.PersistentClass.checkPropertyColumnDup lication(PersistentClass.java:674)
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> Thx.
>>>>>>>>>
>>>>>>>>> David
>>>>>>>>
>>>>>>>>
>>>>>>
>>>>>>
>>>>
>>>>
>>
>>
--
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] Unexpected repeated column error [message #618135 is a reply to message #122843] |
Thu, 22 May 2008 14:06 |
David Wynter Messages: 4624 Registered: July 2009 |
Senior Member |
|
|
Hi,
It was my misunderstanding of how the generation was done. From previous
newsgroup messages I thought that either you generated the hbm file
and then used Hibernate to generate or you could use the programmatic
method as I had.
I had already regenerated the model, but I had not generated the hbm
file. I tried it again just generating the hbm file first and it then
programmatically generated using the HbDataStore initialize() method.
That worked correctly.
Thx.
David
Martin Taal wrote:
> Hi David,
> You did do a reload of the genmodel and regenerate of the java code?
> Can you see the annotation in the generated PackageImpl somewhere?
>
> Can you post the hbm which maps the id attribute and the id of the
> entity itself?
>
> gr. Martin
>
> david wrote:
>> Hi,
>>
>> I have these options,
>>
>> props.setProperty(Environment.DRIVER, "com.mysql.jdbc.Driver");
>> props.setProperty(Environment.USER, "tLoader");
>> props.setProperty(Environment.PASS, "pass34w0rd");
>> props.setProperty(Environment.URL,
>> "jdbc:mysql://192.168.0.3:3306/" + dbName);
>> props.setProperty(Environment.DIALECT,
>> org.hibernate.dialect.MySQLInnoDBDialect.class.getName());
>> props.setProperty(PersistenceOptions.MAXIMUM_SQL_NAME_LENGTH ,
>> "30");
>>
>> props.setProperty(PersistenceOptions.ID_FEATURE_AS_PRIMARY_K EY, "true");
>> props.setProperty(PersistenceOptions.DEFAULT_ID_FEATURE_NAME ,
>> "id");
>>
>> props.setProperty(PersistenceOptions.JOIN_COLUMN_NAMING_STRA TEGY,
>> "simple");
>> props.setProperty(PersistenceOptions.ALSO_MAP_AS_CLASS, "false");
>> props.setProperty(PersistenceOptions.DEFAULT_TEMPORAL_VALUE,
>> "DATE");
>>
>> props.setProperty(PersistenceOptions.DISABLE_ECONTAINER_MAPP ING, "true");
>> props.setProperty(PersistenceOptions.ALWAYS_VERSION, "false");
>> props.setProperty(PersistenceOptions.ALWAYS_MAP_LIST_AS_BAG,
>> "true");
>> props.setProperty(PersistenceOptions.INHERITANCE_MAPPING,
>> "JOINED");
>>
>>
>> I added the
>>
>> <xsd:attribute name="id" type="xsd:int">
>> <xsd:annotation>
>> <xsd:appinfo source="teneo.jpa">@Id</xsd:appinfo>
>> </xsd:annotation>
>> </xsd:attribute>
>>
>> to all my elements.
>>
>> But I still get the e_id being produced as the primary key and the id
>> column is not being used?
>>
>> Thx.
>>
>> David
>>
>>
>>
>> Martin Taal wrote:
>>> Hi David,
>>> It seems valid to me, you can check out if it works when you generate
>>> the java model code from this. The @Id should then be somewhere in
>>> the generated PackageImpl as a string in the initialization code.
>>>
>>> gr. Martin
>>>
>>> david wrote:
>>>> Hi,
>>>>
>>>> This is were it gets confusing, as below I mentioned the id is
>>>> actually an attribute, not an element. Since the annotations are
>>>> contained within an element I was not sure if this same mechanism
>>>> can be used for adding annotations to attributes as opposed to
>>>> elements as all the examples show.
>>>>
>>>> Is this valid?
>>>>
>>>> <xsd:attribute name="id" type="xsd:int">
>>>> <xsd:annotation>
>>>> <xsd:appinfo source="teneo.jpa">@Id</xsd:appinfo>
>>>> </xsd:annotation>
>>>> </xsd:attribute>
>>>>
>>>> Thx.
>>>>
>>>> David
>>>>
>>>> Martin Taal wrote:
>>>>> Hi David,
>>>>> I don't think that you need to delete the id element from the xsd
>>>>>
>>>>> There are many examples here, did you find it?
>>>>> http://www.elver.org/hibernate/ejb3_examples.html
>>>>>
>>>>> The id annotation in xml schema will be something like this:
>>>>> <xsd:element name="id" type="xsd:long">
>>>>> <xsd:annotation>
>>>>> <xsd:appinfo source="teneo.jpa">@Id</xsd:appinfo>
>>>>> </xsd:annotation>
>>>>> </xsd:element>
>>>>>
>>>>> You can check the jpa spec for the syntax of the annotations.
>>>>>
>>>>> or instead of setting the annotation in the xml schema then having
>>>>> the id element/attribute and set the option:
>>>>> props.setProperty(PersistenceOptions.DEFAULT_ID_FEATURE_NAME , "id")
>>>>> should work.
>>>>>
>>>>> gr. Martin
>>>>>
>>>>> david wrote:
>>>>>> Hi,
>>>>>>
>>>>>> I ended up deleting the Id columns out of the xsd, and using the
>>>>>>
>>>>>> props.setProperty(PersistenceOptions.ID_COLUMN_NAME, "id");
>>>>>>
>>>>>> props.setProperty(PersistenceOptions.DEFAULT_ID_FEATURE_NAME , "id");
>>>>>>
>>>>>>
>>>>>> But to confirm would the annotation look like this
>>>>>>
>>>>>> <xsd:complexType name="StatusChangeSubclass">
>>>>>> <xsd:sequence>
>>>>>> <xsd:annotation>
>>>>>> <xsd:appinfo source="teneo.jpa">
>>>>>> @Id(name="Id")
>>>>>> </xsd:appinfo>
>>>>>> </xsd:annotation>
>>>>>> ....
>>>>>>
>>>>>> I could not find an explicit example amongst the samples on that
>>>>>> page.
>>>>>>
>>>>>> Thx,
>>>>>>
>>>>>> David
>>>>>>
>>>>>>
>>>>>> Martin Taal wrote:
>>>>>>> Hi David,
>>>>>>> Yes you are right the DEFAULT_ID_FEATURE_NAME option should also
>>>>>>> work (forgot that one). You then don't need the @Id annotation or
>>>>>>> the ID_COLUMN_NAME option.
>>>>>>>
>>>>>>> The @Id is a standard jpa annotation. Here are some examples to
>>>>>>> define annotations in xml schema:
>>>>>>> http://www.elver.org/hibernate/ejb3_examples.html#schemasamp les
>>>>>>>
>>>>>>> gr. Martin
>>>>>>>
>>>>>>> david wrote:
>>>>>>>> Hi,
>>>>>>>>
>>>>>>>> I have been sifting through the elver website and cannot find
>>>>>>>> the documentation on the specific @Id annotation. I checked the
>>>>>>>> EJV Persistance document too, but it had Java annotations for
>>>>>>>> the @Id. It is not clear to me how you add the @Id annotation to
>>>>>>>> an attribute within the element in the xsd. Can you show me an
>>>>>>>> example?
>>>>>>>>
>>>>>>>> Also adding this
>>>>>>>> props.setProperty(PersistenceOptions.DEFAULT_ID_FEATURE_NAME ,
>>>>>>>> "id");
>>>>>>>>
>>>>>>>> Shouldn't that cause Teneo to recognisedall features named 'id'
>>>>>>>> as the primary key?
>>>>>>>>
>>>>>>>>
>>>>>>>> <xsd:complexType name="StatusChangeSubclass">
>>>>>>>> <xsd:sequence>
>>>>>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>>>>>> ref="gensec:meetingType" />
>>>>>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>>>>>> ref="gensec:agent" />
>>>>>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>>>>>> ref="gensec:caeLifecycleType" />
>>>>>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>>>>>> ref="gensec:caeStatusType" />
>>>>>>>> <xsd:element ref="gensec:caeType" />
>>>>>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>>>>>> ref="gensec:entityIdentifier" />
>>>>>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>>>>>> ref="gensec:indicatorsType" />
>>>>>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>>>>>> ref="gensec:instrumentIdentifier" />
>>>>>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>>>>>> ref="gensec:issuerRef" />
>>>>>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>>>>>> ref="gensec:dataValueChange" />
>>>>>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>>>>>> ref="gensec:source" />
>>>>>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>>>>>> ref="gensec:relatedTo" />
>>>>>>>> </xsd:sequence>
>>>>>>>> <xsd:attribute name="id" type="xsd:int" use="optional" />
>>>>>>>> <xsd:attribute name="effectiveDate" type="xsd:dateTime"
>>>>>>>> use="optional" />
>>>>>>>> <xsd:attribute name="announcementDate" type="xsd:dateTime"
>>>>>>>> use="optional" />
>>>>>>>> <xsd:attribute name="meetingDate" type="xsd:dateTime"
>>>>>>>> use="optional" />
>>>>>>>> <xsd:attribute name="recordDate" type="xsd:dateTime"
>>>>>>>> use="optional" />
>>>>>>>> <xsd:attribute name="comment" type="xsd:string"
>>>>>>>> use="optional" />
>>>>>>>> <xsd:attribute name="documentURL" type="xsd:anyURI"
>>>>>>>> use="optional" />
>>>>>>>> <xsd:attribute name="caeIdentifier" type="xsd:string"
>>>>>>>> use="optional" />
>>>>>>>> <xsd:attribute name="eventDescription" type="xsd:string"
>>>>>>>> use="optional" />
>>>>>>>> <xsd:attribute name="caeDate" type="xsd:dateTime"
>>>>>>>> use="optional" />
>>>>>>>> </xsd:complexType>
>>>>>>>>
>>>>>>>>
>>>>>>>> Thanks,
>>>>>>>>
>>>>>>>> David
>>>>>>>>
>>>>>>>> Martin Taal wrote:
>>>>>>>>> Hi David,
>>>>>>>>> This occurs because the type has an id attribute and you set
>>>>>>>>> the PersistenceOptions.ID_COLUMN_NAME option to id. The
>>>>>>>>> PersistenceOptions.ID_COLUMN_NAME option is used to set the
>>>>>>>>> synthetic id column. The synthetic id is created if the type
>>>>>>>>> does not have an explicit id column. So what happens is that
>>>>>>>>> you have an id-attribute (which gets a column id) and because
>>>>>>>>> there is no explicit id for the type a synthetic id is created
>>>>>>>>> (which also gets column id).
>>>>>>>>>
>>>>>>>>> In your case you should annotate the id-feature with a @Id
>>>>>>>>> annotation as you want to use that feature as the id (afaics).
>>>>>>>>>
>>>>>>>>> gr. Marrtin
>>>>>>>>>
>>>>>>>>> david wrote:
>>>>>>>>>> Hi,
>>>>>>>>>>
>>>>>>>>>> I am getting and error I cannot see an obvious cause for .
>>>>>>>>>>
>>>>>>>>>> Based on the ecore generated from this
>>>>>>>>>>
>>>>>>>>>> <xsd:complexType name="StatusChangeSubclass">
>>>>>>>>>> <xsd:sequence>
>>>>>>>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>>>>>>>> ref="gensec:meetingType" />
>>>>>>>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>>>>>>>> ref="gensec:agent" />
>>>>>>>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>>>>>>>> ref="gensec:caeLifecycleType" />
>>>>>>>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>>>>>>>> ref="gensec:caeStatusType" />
>>>>>>>>>> <xsd:element ref="gensec:caeType" />
>>>>>>>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>>>>>>>> ref="gensec:entityIdentifier" />
>>>>>>>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>>>>>>>> ref="gensec:indicatorsType" />
>>>>>>>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>>>>>>>> ref="gensec:instrumentIdentifier" />
>>>>>>>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>>>>>>>> ref="gensec:issuerRef" />
>>>>>>>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>>>>>>>> ref="gensec:dataValueChange" />
>>>>>>>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>>>>>>>> ref="gensec:source" />
>>>>>>>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>>>>>>>> ref="gensec:relatedTo" />
>>>>>>>>>> </xsd:sequence>
>>>>>>>>>> <xsd:attribute name="id" type="xsd:int" use="optional" />
>>>>>>>>>> <xsd:attribute name="effectiveDate" type="xsd:dateTime"
>>>>>>>>>> use="optional" />
>>>>>>>>>> <xsd:attribute name="announcementDate" type="xsd:dateTime"
>>>>>>>>>> use="optional" />
>>>>>>>>>> <xsd:attribute name="meetingDate" type="xsd:dateTime"
>>>>>>>>>> use="optional" />
>>>>>>>>>> <xsd:attribute name="recordDate" type="xsd:dateTime"
>>>>>>>>>> use="optional" />
>>>>>>>>>> <xsd:attribute name="comment" type="xsd:string"
>>>>>>>>>> use="optional" />
>>>>>>>>>> <xsd:attribute name="documentURL" type="xsd:anyURI"
>>>>>>>>>> use="optional" />
>>>>>>>>>> <xsd:attribute name="caeIdentifier" type="xsd:string"
>>>>>>>>>> use="optional" />
>>>>>>>>>> <xsd:attribute name="eventDescription" type="xsd:string"
>>>>>>>>>> use="optional" />
>>>>>>>>>> <xsd:attribute name="caeDate" type="xsd:dateTime"
>>>>>>>>>> use="optional" />
>>>>>>>>>> </xsd:complexType>
>>>>>>>>>>
>>>>>>>>>> I am using
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> props.setProperty(PersistenceOptions.MAXIMUM_SQL_NAME_LENGTH ,
>>>>>>>>>> "30");
>>>>>>>>>>
>>>>>>>>>> props.setProperty(PersistenceOptions.JOIN_COLUMN_NAMING_STRA TEGY,
>>>>>>>>>> "simple");
>>>>>>>>>> props.setProperty(PersistenceOptions.ID_COLUMN_NAME,
>>>>>>>>>> "id");
>>>>>>>>>>
>>>>>>>>>> props.setProperty(PersistenceOptions.ID_FEATURE_AS_PRIMARY_K EY,
>>>>>>>>>> "false");
>>>>>>>>>>
>>>>>>>>>> props.setProperty(PersistenceOptions.ALSO_MAP_AS_CLASS, "false");
>>>>>>>>>>
>>>>>>>>>> props.setProperty(PersistenceOptions.DEFAULT_TEMPORAL_VALUE,
>>>>>>>>>> "DATE");
>>>>>>>>>>
>>>>>>>>>> props.setProperty(PersistenceOptions.DISABLE_ECONTAINER_MAPP ING,
>>>>>>>>>> "true");
>>>>>>>>>> props.setProperty(PersistenceOptions.ALWAYS_VERSION,
>>>>>>>>>> "false");
>>>>>>>>>>
>>>>>>>>>> props.setProperty(PersistenceOptions.ALWAYS_MAP_LIST_AS_BAG,
>>>>>>>>>> "true");
>>>>>>>>>>
>>>>>>>>>> props.setProperty(PersistenceOptions.INHERITANCE_MAPPING,
>>>>>>>>>> "JOINED");
>>>>>>>>>>
>>>>>>>>>> The ID_COLUMN_NAME option I read as meaning it recognises the
>>>>>>>>>> model attribute with the name of "id" as the primary key
>>>>>>>>>>
>>>>>>>>>> There is only one id attribute, also in the ecore, so how come
>>>>>>>>>> I get the following error?
>>>>>>>>>>
>>>>>>>>>> I use Eclise 3.3, JDK 5 and Teneo from the 23rd April
>>>>>>>>>>
>>>>>>>>>> Exception in thread "main" org.hibernate.MappingException:
>>>>>>>>>> Repeated column in mapping for entity: StatusChangeSubclass
>>>>>>>>>> column: id (should be mapped with insert="false" update="false")
>>>>>>>>>> at
>>>>>>>>>> org.hibernate.mapping.PersistentClass.checkColumnDuplication (PersistentClass.java:652)
>>>>>>>>>>
>>>>>>>>>> at
>>>>>>>>>> org.hibernate.mapping.PersistentClass.checkPropertyColumnDup lication(PersistentClass.java:674)
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> Thx.
>>>>>>>>>>
>>>>>>>>>> David
>>>>>>>>>
>>>>>>>>>
>>>>>>>
>>>>>>>
>>>>>
>>>>>
>>>
>>>
>
>
|
|
|
Goto Forum:
Current Time: Thu Sep 26 22:11:28 GMT 2024
Powered by FUDForum. Page generated in 0.05846 seconds
|