Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF "Technology" (Ecore Tools, EMFatic, etc)  » Extra Primary Key Join Column
Extra Primary Key Join Column [message #116033] Thu, 27 March 2008 02:46 Go to next message
Eclipse UserFriend
Originally posted by: pavata.vsp.com

Hi,
I am having an issue related to Primary key join column in an inheritance
strategy "JOINED". There is a custom join column mapping using
@PrimaryKeyJoinColumn(name="MyColumnName") between a parent class and sub
class. But teneo code recognizes the parent class and adds another primary
key join column based on the annotaton @Id and the generated name is a
combination of ParentClassName_ColumnNameofIDColumn and gets truncated by
ClassicSQLNameStrategy (specific class the is performing this functionality
is . So I am ending up with two primary key join columns.
Can you guide me if there is an option by which I can stop this this extra
primary key join column getting added.

Thanks!!

- Pavan
Re: Extra Primary Key Join Column [message #116053 is a reply to message #116033] Thu, 27 March 2008 09:01 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Pavan,
Seems like a bug, can you post the mapping of the subclass? Then I can see how it is mapped.

gr. Martin

Pavan Tata wrote:
> Hi,
> I am having an issue related to Primary key join column in an inheritance
> strategy "JOINED". There is a custom join column mapping using
> @PrimaryKeyJoinColumn(name="MyColumnName") between a parent class and sub
> class. But teneo code recognizes the parent class and adds another primary
> key join column based on the annotaton @Id and the generated name is a
> combination of ParentClassName_ColumnNameofIDColumn and gets truncated by
> ClassicSQLNameStrategy (specific class the is performing this functionality
> is . So I am ending up with two primary key join columns.
> Can you guide me if there is an option by which I can stop this this extra
> primary key join column getting added.
>
> Thanks!!
>
> - Pavan
>
>


--

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: Extra Primary Key Join Column [message #116234 is a reply to message #116053] Thu, 27 March 2008 18:36 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: pavata.vsp.com

Hi Martin,
Here I am giving you both XSD and the hibernate mapping that are generated.
I have stripped out other info and giving here only the required.
Parent Class XSD mapping:
<xsd:complexType name="ConsumerAssociation" abstract="true">
<xsd:annotation>
<xsd:appinfo source="teneo.jpa">
@Table(name="CMR3603T",uniqueConstraints =
@UniqueConstraint(columnNames="CONSUMER_ASSCTN_SK"}))
@Inheritance(strategy=InheritanceType.JOINED) </xsd:appinfo>
</xsd:annotation>
<xsd:sequence>
<xsd:element name="consumerAssociationSK" type="xsd:int">
<xsd:annotation> <xsd:appinfo source="teneo.jpa">
@Id @Column(name="CONSUMER_ASSCTN_SK" nullable="false" insertable=false
updatable=false)
@GeneratedValue(strategy=SEQUENCE generator="SEQ_CMR3603T")
</xsd:appinfo>
</xsd:annotation>
</xsd:element>
</xsd:complexType>

If I add an annotation @PrimaryKeyJoinColumn(name="CONSUMER_ASSCTN_SK") in
the child class, it throws an error while generating the hibernate mapping
as below and it doesn't even generate a hbm file:
org.hibernate.MappingException: Foreign key (FKBFC28A9A5E702277:member
[consumer_assctn_sk,cnsmersscitin_cnsmerasscitinsk])) must have same number
of columns as the referenced primary key (cmr3603t [consumer_assctn_sk])

But if I don't add the primary key join column in subclass, then it
generates the hbm file with a default join column as below:
<joined-subclass name="com.vsp.consumer.model.impl.MemberImpl"
entity-name="Member" abstract="false" lazy="false"
extends="ConsumerAssociation" table="member">
<meta attribute="eclassName">Member</meta>
<meta attribute="epackage">http://model.consumer.vsp.com</meta>
<key>
<column name="cnsmersscitin_cnsmerasscitinsk"/>
</key>
But I would rather want to have a custom column name above.
Let me know if you want more details.

- Pavan


"Martin Taal" <mtaal@elver.org> wrote in message
news:fsfnpi$shd$1@build.eclipse.org...
> Hi Pavan,
> Seems like a bug, can you post the mapping of the subclass? Then I can see
> how it is mapped.
>
> gr. Martin
>
> Pavan Tata wrote:
>> Hi,
>> I am having an issue related to Primary key join column in an
>> inheritance strategy "JOINED". There is a custom join column mapping
>> using @PrimaryKeyJoinColumn(name="MyColumnName") between a parent class
>> and sub class. But teneo code recognizes the parent class and adds
>> another primary key join column based on the annotaton @Id and the
>> generated name is a combination of ParentClassName_ColumnNameofIDColumn
>> and gets truncated by ClassicSQLNameStrategy (specific class the is
>> performing this functionality is . So I am ending up with two primary key
>> join columns.
>> Can you guide me if there is an option by which I can stop this this
>> extra primary key join column getting added.
>>
>> Thanks!!
>>
>> - Pavan
>
>
> --
>
> 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: Extra Primary Key Join Column [message #116247 is a reply to message #116234] Thu, 27 March 2008 19:35 Go to previous message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Pavan,
Okay thanks, can you enter a bugzilla for this?
Teneo currently only tests for the primarykeyjoincolumn in case of a one-to-one it is clear that
also the superclass case should be tested (and work properly).

gr. Martin

Pavan Tata wrote:
> Hi Martin,
> Here I am giving you both XSD and the hibernate mapping that are generated.
> I have stripped out other info and giving here only the required.
> Parent Class XSD mapping:
> <xsd:complexType name="ConsumerAssociation" abstract="true">
> <xsd:annotation>
> <xsd:appinfo source="teneo.jpa">
> @Table(name="CMR3603T",uniqueConstraints =
> @UniqueConstraint(columnNames="CONSUMER_ASSCTN_SK"}))
> @Inheritance(strategy=InheritanceType.JOINED) </xsd:appinfo>
> </xsd:annotation>
> <xsd:sequence>
> <xsd:element name="consumerAssociationSK" type="xsd:int">
> <xsd:annotation> <xsd:appinfo source="teneo.jpa">
> @Id @Column(name="CONSUMER_ASSCTN_SK" nullable="false" insertable=false
> updatable=false)
> @GeneratedValue(strategy=SEQUENCE generator="SEQ_CMR3603T")
> </xsd:appinfo>
> </xsd:annotation>
> </xsd:element>
> </xsd:complexType>
>
> If I add an annotation @PrimaryKeyJoinColumn(name="CONSUMER_ASSCTN_SK") in
> the child class, it throws an error while generating the hibernate mapping
> as below and it doesn't even generate a hbm file:
> org.hibernate.MappingException: Foreign key (FKBFC28A9A5E702277:member
> [consumer_assctn_sk,cnsmersscitin_cnsmerasscitinsk])) must have same number
> of columns as the referenced primary key (cmr3603t [consumer_assctn_sk])
>
> But if I don't add the primary key join column in subclass, then it
> generates the hbm file with a default join column as below:
> <joined-subclass name="com.vsp.consumer.model.impl.MemberImpl"
> entity-name="Member" abstract="false" lazy="false"
> extends="ConsumerAssociation" table="member">
> <meta attribute="eclassName">Member</meta>
> <meta attribute="epackage">http://model.consumer.vsp.com</meta>
> <key>
> <column name="cnsmersscitin_cnsmerasscitinsk"/>
> </key>
> But I would rather want to have a custom column name above.
> Let me know if you want more details.
>
> - Pavan
>
>
> "Martin Taal" <mtaal@elver.org> wrote in message
> news:fsfnpi$shd$1@build.eclipse.org...
>> Hi Pavan,
>> Seems like a bug, can you post the mapping of the subclass? Then I can see
>> how it is mapped.
>>
>> gr. Martin
>>
>> Pavan Tata wrote:
>>> Hi,
>>> I am having an issue related to Primary key join column in an
>>> inheritance strategy "JOINED". There is a custom join column mapping
>>> using @PrimaryKeyJoinColumn(name="MyColumnName") between a parent class
>>> and sub class. But teneo code recognizes the parent class and adds
>>> another primary key join column based on the annotaton @Id and the
>>> generated name is a combination of ParentClassName_ColumnNameofIDColumn
>>> and gets truncated by ClassicSQLNameStrategy (specific class the is
>>> performing this functionality is . So I am ending up with two primary key
>>> join columns.
>>> Can you guide me if there is an option by which I can stop this this
>>> extra primary key join column getting added.
>>>
>>> Thanks!!
>>>
>>> - Pavan
>>
>> --
>>
>> With Regards, Martin Taal
>>
>> Springsite/Elver.org
>> Office: Hardwareweg 4, 3821 BV Amersfoort
>> Postal: Nassaulaan 7, 3941 EC Doorn
>> The Netherlands
>> Tel: +31 (0)84 420 2397
>> Fax: +31 (0)84 225 9307
>> Mail: mtaal@springsite.com - mtaal@elver.org
>> Web: www.springsite.com - www.elver.org
>
>


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@springsite.com - mtaal@elver.org
Web: www.springsite.com - www.elver.org
Re: Extra Primary Key Join Column [message #616003 is a reply to message #116033] Thu, 27 March 2008 09:01 Go to previous message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Pavan,
Seems like a bug, can you post the mapping of the subclass? Then I can see how it is mapped.

gr. Martin

Pavan Tata wrote:
> Hi,
> I am having an issue related to Primary key join column in an inheritance
> strategy "JOINED". There is a custom join column mapping using
> @PrimaryKeyJoinColumn(name="MyColumnName") between a parent class and sub
> class. But teneo code recognizes the parent class and adds another primary
> key join column based on the annotaton @Id and the generated name is a
> combination of ParentClassName_ColumnNameofIDColumn and gets truncated by
> ClassicSQLNameStrategy (specific class the is performing this functionality
> is . So I am ending up with two primary key join columns.
> Can you guide me if there is an option by which I can stop this this extra
> primary key join column getting added.
>
> Thanks!!
>
> - Pavan
>
>


--

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: Extra Primary Key Join Column [message #616017 is a reply to message #116053] Thu, 27 March 2008 18:36 Go to previous message
Eclipse UserFriend
Originally posted by: pavata.vsp.com

Hi Martin,
Here I am giving you both XSD and the hibernate mapping that are generated.
I have stripped out other info and giving here only the required.
Parent Class XSD mapping:
<xsd:complexType name="ConsumerAssociation" abstract="true">
<xsd:annotation>
<xsd:appinfo source="teneo.jpa">
@Table(name="CMR3603T",uniqueConstraints =
@UniqueConstraint(columnNames="CONSUMER_ASSCTN_SK"}))
@Inheritance(strategy=InheritanceType.JOINED) </xsd:appinfo>
</xsd:annotation>
<xsd:sequence>
<xsd:element name="consumerAssociationSK" type="xsd:int">
<xsd:annotation> <xsd:appinfo source="teneo.jpa">
@Id @Column(name="CONSUMER_ASSCTN_SK" nullable="false" insertable=false
updatable=false)
@GeneratedValue(strategy=SEQUENCE generator="SEQ_CMR3603T")
</xsd:appinfo>
</xsd:annotation>
</xsd:element>
</xsd:complexType>

If I add an annotation @PrimaryKeyJoinColumn(name="CONSUMER_ASSCTN_SK") in
the child class, it throws an error while generating the hibernate mapping
as below and it doesn't even generate a hbm file:
org.hibernate.MappingException: Foreign key (FKBFC28A9A5E702277:member
[consumer_assctn_sk,cnsmersscitin_cnsmerasscitinsk])) must have same number
of columns as the referenced primary key (cmr3603t [consumer_assctn_sk])

But if I don't add the primary key join column in subclass, then it
generates the hbm file with a default join column as below:
<joined-subclass name="com.vsp.consumer.model.impl.MemberImpl"
entity-name="Member" abstract="false" lazy="false"
extends="ConsumerAssociation" table="member">
<meta attribute="eclassName">Member</meta>
<meta attribute="epackage">http://model.consumer.vsp.com</meta>
<key>
<column name="cnsmersscitin_cnsmerasscitinsk"/>
</key>
But I would rather want to have a custom column name above.
Let me know if you want more details.

- Pavan


"Martin Taal" <mtaal@elver.org> wrote in message
news:fsfnpi$shd$1@build.eclipse.org...
> Hi Pavan,
> Seems like a bug, can you post the mapping of the subclass? Then I can see
> how it is mapped.
>
> gr. Martin
>
> Pavan Tata wrote:
>> Hi,
>> I am having an issue related to Primary key join column in an
>> inheritance strategy "JOINED". There is a custom join column mapping
>> using @PrimaryKeyJoinColumn(name="MyColumnName") between a parent class
>> and sub class. But teneo code recognizes the parent class and adds
>> another primary key join column based on the annotaton @Id and the
>> generated name is a combination of ParentClassName_ColumnNameofIDColumn
>> and gets truncated by ClassicSQLNameStrategy (specific class the is
>> performing this functionality is . So I am ending up with two primary key
>> join columns.
>> Can you guide me if there is an option by which I can stop this this
>> extra primary key join column getting added.
>>
>> Thanks!!
>>
>> - Pavan
>
>
> --
>
> 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: Extra Primary Key Join Column [message #616018 is a reply to message #116234] Thu, 27 March 2008 19:35 Go to previous message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Pavan,
Okay thanks, can you enter a bugzilla for this?
Teneo currently only tests for the primarykeyjoincolumn in case of a one-to-one it is clear that
also the superclass case should be tested (and work properly).

gr. Martin

Pavan Tata wrote:
> Hi Martin,
> Here I am giving you both XSD and the hibernate mapping that are generated.
> I have stripped out other info and giving here only the required.
> Parent Class XSD mapping:
> <xsd:complexType name="ConsumerAssociation" abstract="true">
> <xsd:annotation>
> <xsd:appinfo source="teneo.jpa">
> @Table(name="CMR3603T",uniqueConstraints =
> @UniqueConstraint(columnNames="CONSUMER_ASSCTN_SK"}))
> @Inheritance(strategy=InheritanceType.JOINED) </xsd:appinfo>
> </xsd:annotation>
> <xsd:sequence>
> <xsd:element name="consumerAssociationSK" type="xsd:int">
> <xsd:annotation> <xsd:appinfo source="teneo.jpa">
> @Id @Column(name="CONSUMER_ASSCTN_SK" nullable="false" insertable=false
> updatable=false)
> @GeneratedValue(strategy=SEQUENCE generator="SEQ_CMR3603T")
> </xsd:appinfo>
> </xsd:annotation>
> </xsd:element>
> </xsd:complexType>
>
> If I add an annotation @PrimaryKeyJoinColumn(name="CONSUMER_ASSCTN_SK") in
> the child class, it throws an error while generating the hibernate mapping
> as below and it doesn't even generate a hbm file:
> org.hibernate.MappingException: Foreign key (FKBFC28A9A5E702277:member
> [consumer_assctn_sk,cnsmersscitin_cnsmerasscitinsk])) must have same number
> of columns as the referenced primary key (cmr3603t [consumer_assctn_sk])
>
> But if I don't add the primary key join column in subclass, then it
> generates the hbm file with a default join column as below:
> <joined-subclass name="com.vsp.consumer.model.impl.MemberImpl"
> entity-name="Member" abstract="false" lazy="false"
> extends="ConsumerAssociation" table="member">
> <meta attribute="eclassName">Member</meta>
> <meta attribute="epackage">http://model.consumer.vsp.com</meta>
> <key>
> <column name="cnsmersscitin_cnsmerasscitinsk"/>
> </key>
> But I would rather want to have a custom column name above.
> Let me know if you want more details.
>
> - Pavan
>
>
> "Martin Taal" <mtaal@elver.org> wrote in message
> news:fsfnpi$shd$1@build.eclipse.org...
>> Hi Pavan,
>> Seems like a bug, can you post the mapping of the subclass? Then I can see
>> how it is mapped.
>>
>> gr. Martin
>>
>> Pavan Tata wrote:
>>> Hi,
>>> I am having an issue related to Primary key join column in an
>>> inheritance strategy "JOINED". There is a custom join column mapping
>>> using @PrimaryKeyJoinColumn(name="MyColumnName") between a parent class
>>> and sub class. But teneo code recognizes the parent class and adds
>>> another primary key join column based on the annotaton @Id and the
>>> generated name is a combination of ParentClassName_ColumnNameofIDColumn
>>> and gets truncated by ClassicSQLNameStrategy (specific class the is
>>> performing this functionality is . So I am ending up with two primary key
>>> join columns.
>>> Can you guide me if there is an option by which I can stop this this
>>> extra primary key join column getting added.
>>>
>>> Thanks!!
>>>
>>> - Pavan
>>
>> --
>>
>> With Regards, Martin Taal
>>
>> Springsite/Elver.org
>> Office: Hardwareweg 4, 3821 BV Amersfoort
>> Postal: Nassaulaan 7, 3941 EC Doorn
>> The Netherlands
>> Tel: +31 (0)84 420 2397
>> Fax: +31 (0)84 225 9307
>> Mail: mtaal@springsite.com - mtaal@elver.org
>> Web: www.springsite.com - www.elver.org
>
>


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@springsite.com - mtaal@elver.org
Web: www.springsite.com - www.elver.org
Previous Topic:How to copy eResources such that xmi ids are maintained across resources
Next Topic:Nullable does not work
Goto Forum:
  


Current Time: Sat Apr 20 00:08:02 GMT 2024

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

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

Back to the top