<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Hibernate annotations: The many-to-many association with composite key</title>
	<atom:link href="http://boris.kirzner.info/blog/archives/2008/07/19/hibernate-annotations-the-many-to-many-association-with-composite-key/feed/" rel="self" type="application/rss+xml" />
	<link>http://boris.kirzner.info/blog/archives/2008/07/19/hibernate-annotations-the-many-to-many-association-with-composite-key/</link>
	<description>Only empty files are bugless</description>
	<lastBuildDate>Wed, 21 Dec 2011 15:04:14 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.1</generator>
	<item>
		<title>By: Marc</title>
		<link>http://boris.kirzner.info/blog/archives/2008/07/19/hibernate-annotations-the-many-to-many-association-with-composite-key/comment-page-2/#comment-44838</link>
		<dc:creator>Marc</dc:creator>
		<pubDate>Wed, 21 Dec 2011 15:04:14 +0000</pubDate>
		<guid isPermaLink="false">http://boris.kirzner.info/blog/archives/2008/07/19/hibernate-annotations-the-many-to-many-association-with-composite-key/#comment-44838</guid>
		<description>Do you have an idea how to map a Hibernate Search @DocumentId in the above solution? Since there isn&#039;t really an id field.

I tried 
public class ProductItem {
 
    private ProductItemPk pk = new ProductItemPk();
 
    @EmbeddedId
    private ProductItemPk getPk() {
        return pk;
    }
[..]
@Embeddable
public class ProductItemPk implements Serializable {
                @DocumentId
		@Transient
		public Long getProductId(){
			return product.getId();
		}
		
		@DocumentId
		@Transient
		public Long getItemId(){
			return item.getId();
		}</description>
		<content:encoded><![CDATA[<p>Do you have an idea how to map a Hibernate Search @DocumentId in the above solution? Since there isn&#8217;t really an id field.</p>
<p>I tried<br />
public class ProductItem {</p>
<p>    private ProductItemPk pk = new ProductItemPk();</p>
<p>    @EmbeddedId<br />
    private ProductItemPk getPk() {<br />
        return pk;<br />
    }<br />
[..]<br />
@Embeddable<br />
public class ProductItemPk implements Serializable {<br />
                @DocumentId<br />
		@Transient<br />
		public Long getProductId(){<br />
			return product.getId();<br />
		}</p>
<p>		@DocumentId<br />
		@Transient<br />
		public Long getItemId(){<br />
			return item.getId();<br />
		}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Denys</title>
		<link>http://boris.kirzner.info/blog/archives/2008/07/19/hibernate-annotations-the-many-to-many-association-with-composite-key/comment-page-2/#comment-44744</link>
		<dc:creator>Denys</dc:creator>
		<pubDate>Fri, 16 Dec 2011 21:24:40 +0000</pubDate>
		<guid isPermaLink="false">http://boris.kirzner.info/blog/archives/2008/07/19/hibernate-annotations-the-many-to-many-association-with-composite-key/#comment-44744</guid>
		<description>Hello.
Your idea is great on first look. But from hibernate sql logging i see the hibernate hasn&#039;t
persisted ProductItem entity at all when I&#039;ve been  trying execute new productItemDAO.save(productItem). 
Thanks in advance for any help.</description>
		<content:encoded><![CDATA[<p>Hello.<br />
Your idea is great on first look. But from hibernate sql logging i see the hibernate hasn&#8217;t<br />
persisted ProductItem entity at all when I&#8217;ve been  trying execute new productItemDAO.save(productItem).<br />
Thanks in advance for any help.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jem</title>
		<link>http://boris.kirzner.info/blog/archives/2008/07/19/hibernate-annotations-the-many-to-many-association-with-composite-key/comment-page-2/#comment-40255</link>
		<dc:creator>Jem</dc:creator>
		<pubDate>Wed, 29 Jun 2011 07:58:51 +0000</pubDate>
		<guid isPermaLink="false">http://boris.kirzner.info/blog/archives/2008/07/19/hibernate-annotations-the-many-to-many-association-with-composite-key/#comment-40255</guid>
		<description>I tried to follow the example but I bumped into this error.
Can you please help me? I would greatly appreciate any help.
Thank you very much!

Exception in thread &quot;main&quot; org.hibernate.AnnotationException: Use of @OneToMany or @ManyToMany targeting an unmapped class: com.hp.gdas.capman.domain.Product.productItems[com.hp.gdas.capman.domain.ProductItem]</description>
		<content:encoded><![CDATA[<p>I tried to follow the example but I bumped into this error.<br />
Can you please help me? I would greatly appreciate any help.<br />
Thank you very much!</p>
<p>Exception in thread &#8220;main&#8221; org.hibernate.AnnotationException: Use of @OneToMany or @ManyToMany targeting an unmapped class: com.hp.gdas.capman.domain.Product.productItems[com.hp.gdas.capman.domain.ProductItem]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Generic1</title>
		<link>http://boris.kirzner.info/blog/archives/2008/07/19/hibernate-annotations-the-many-to-many-association-with-composite-key/comment-page-2/#comment-38977</link>
		<dc:creator>Generic1</dc:creator>
		<pubDate>Wed, 20 Apr 2011 07:36:27 +0000</pubDate>
		<guid isPermaLink="false">http://boris.kirzner.info/blog/archives/2008/07/19/hibernate-annotations-the-many-to-many-association-with-composite-key/#comment-38977</guid>
		<description>Hi again,

I have uploaded a small example which represents my problem.
Maybe you can have a look at my example. 
Thanks a lot and all the best
Generic1

http://www.file-upload.net/download-3372677/SpringHibernate.zip.html</description>
		<content:encoded><![CDATA[<p>Hi again,</p>
<p>I have uploaded a small example which represents my problem.<br />
Maybe you can have a look at my example.<br />
Thanks a lot and all the best<br />
Generic1</p>
<p><a href="http://www.file-upload.net/download-3372677/SpringHibernate.zip.html" rel="nofollow">http://www.file-upload.net/download-3372677/SpringHibernate.zip.html</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Generic1</title>
		<link>http://boris.kirzner.info/blog/archives/2008/07/19/hibernate-annotations-the-many-to-many-association-with-composite-key/comment-page-2/#comment-38965</link>
		<dc:creator>Generic1</dc:creator>
		<pubDate>Tue, 19 Apr 2011 21:26:28 +0000</pubDate>
		<guid isPermaLink="false">http://boris.kirzner.info/blog/archives/2008/07/19/hibernate-annotations-the-many-to-many-association-with-composite-key/#comment-38965</guid>
		<description>Hi,

I&#039;am also very glad because of this tutorial but I have some problems to implement it. I always get the Exception &quot;Column &#039;item_id&#039; cannot be null&quot; 
Does anyone know what I&#039;am doing wong?
Thanks a lot,
All the best,
Generic1</description>
		<content:encoded><![CDATA[<p>Hi,</p>
<p>I&#8217;am also very glad because of this tutorial but I have some problems to implement it. I always get the Exception &#8220;Column &#8216;item_id&#8217; cannot be null&#8221;<br />
Does anyone know what I&#8217;am doing wong?<br />
Thanks a lot,<br />
All the best,<br />
Generic1</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Stefan135</title>
		<link>http://boris.kirzner.info/blog/archives/2008/07/19/hibernate-annotations-the-many-to-many-association-with-composite-key/comment-page-2/#comment-38741</link>
		<dc:creator>Stefan135</dc:creator>
		<pubDate>Thu, 07 Apr 2011 14:54:12 +0000</pubDate>
		<guid isPermaLink="false">http://boris.kirzner.info/blog/archives/2008/07/19/hibernate-annotations-the-many-to-many-association-with-composite-key/#comment-38741</guid>
		<description>Last Update for today:
I added @Column(nullable=false) after both @ManyToOne Annotations in the ProductListPk class. Now the table is being created, but both columns are varchar and not Integer. Now I get the error: 
SQL0538 SQLCODE -538   SQLSTATE 42830
Explanation: Foreign key attributes do not match parent key. 

Where is my problem?</description>
		<content:encoded><![CDATA[<p>Last Update for today:<br />
I added @Column(nullable=false) after both @ManyToOne Annotations in the ProductListPk class. Now the table is being created, but both columns are varchar and not Integer. Now I get the error:<br />
SQL0538 SQLCODE -538   SQLSTATE 42830<br />
Explanation: Foreign key attributes do not match parent key. </p>
<p>Where is my problem?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Stefan135</title>
		<link>http://boris.kirzner.info/blog/archives/2008/07/19/hibernate-annotations-the-many-to-many-association-with-composite-key/comment-page-2/#comment-38738</link>
		<dc:creator>Stefan135</dc:creator>
		<pubDate>Thu, 07 Apr 2011 14:00:08 +0000</pubDate>
		<guid isPermaLink="false">http://boris.kirzner.info/blog/archives/2008/07/19/hibernate-annotations-the-many-to-many-association-with-composite-key/#comment-38738</guid>
		<description>Sorry, covered by @Column(name = &quot;item_id&quot;, nullable = false) and @Column(name = &quot;product_id&quot;, nullable = false)</description>
		<content:encoded><![CDATA[<p>Sorry, covered by @Column(name = &#8220;item_id&#8221;, nullable = false) and @Column(name = &#8220;product_id&#8221;, nullable = false)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Stefan135</title>
		<link>http://boris.kirzner.info/blog/archives/2008/07/19/hibernate-annotations-the-many-to-many-association-with-composite-key/comment-page-2/#comment-38737</link>
		<dc:creator>Stefan135</dc:creator>
		<pubDate>Thu, 07 Apr 2011 13:57:44 +0000</pubDate>
		<guid isPermaLink="false">http://boris.kirzner.info/blog/archives/2008/07/19/hibernate-annotations-the-many-to-many-association-with-composite-key/#comment-38737</guid>
		<description>Okay, now that I got SLF4J to run I know, that DB2 returns an error, that there is a problem with a possibly nullable primary key:

INFO: Running hbm2ddl schema export
07.04.2011 15:54:18 org.hibernate.tool.hbm2ddl.SchemaExport execute
INFO: exporting generated schema to database
07.04.2011 15:54:19 org.hibernate.tool.hbm2ddl.SchemaExport create
FATAL: Unsuccessful: create table product_item (item_id integer, product_id integer, primary key (item_id, product_id))
07.04.2011 15:54:19 org.hibernate.tool.hbm2ddl.SchemaExport create
FATAL: DB2 SQL Error: SQLCODE=-542, SQLSTATE=42831, SQLERRMC=ITEM_ID, DRIVER=4.9.78
07.04.2011 15:54:19 org.hibernate.tool.hbm2ddl.SchemaExport create
FATAL: Unsuccessful: alter table product_item add constraint FK3C742463F24F48C9 foreign key (item_id) references item
07.04.2011 15:54:19 org.hibernate.tool.hbm2ddl.SchemaExport create
FATAL: DB2 SQL Error: SQLCODE=-204, SQLSTATE=42704, SQLERRMC=DB2ADMIN.PRODUCT_ITEM, DRIVER=4.9.78
07.04.2011 15:54:19 org.hibernate.tool.hbm2ddl.SchemaExport create
FATAL: Unsuccessful: alter table product_item add constraint FK3C742463253F490B foreign key (product_id) references product
07.04.2011 15:54:19 org.hibernate.tool.hbm2ddl.SchemaExport create
FATAL: DB2 SQL Error: SQLCODE=-204, SQLSTATE=42704, SQLERRMC=DB2ADMIN.PRODUCT_ITEM, DRIVER=4.9.78
07.04.2011 15:54:19 org.hibernate.tool.hbm2ddl.SchemaExport execute

I expected, that this is covered by the @OneToMany Annotation, where nullable=false is set.

Any idea? Thanks!</description>
		<content:encoded><![CDATA[<p>Okay, now that I got SLF4J to run I know, that DB2 returns an error, that there is a problem with a possibly nullable primary key:</p>
<p>INFO: Running hbm2ddl schema export<br />
07.04.2011 15:54:18 org.hibernate.tool.hbm2ddl.SchemaExport execute<br />
INFO: exporting generated schema to database<br />
07.04.2011 15:54:19 org.hibernate.tool.hbm2ddl.SchemaExport create<br />
FATAL: Unsuccessful: create table product_item (item_id integer, product_id integer, primary key (item_id, product_id))<br />
07.04.2011 15:54:19 org.hibernate.tool.hbm2ddl.SchemaExport create<br />
FATAL: DB2 SQL Error: SQLCODE=-542, SQLSTATE=42831, SQLERRMC=ITEM_ID, DRIVER=4.9.78<br />
07.04.2011 15:54:19 org.hibernate.tool.hbm2ddl.SchemaExport create<br />
FATAL: Unsuccessful: alter table product_item add constraint FK3C742463F24F48C9 foreign key (item_id) references item<br />
07.04.2011 15:54:19 org.hibernate.tool.hbm2ddl.SchemaExport create<br />
FATAL: DB2 SQL Error: SQLCODE=-204, SQLSTATE=42704, SQLERRMC=DB2ADMIN.PRODUCT_ITEM, DRIVER=4.9.78<br />
07.04.2011 15:54:19 org.hibernate.tool.hbm2ddl.SchemaExport create<br />
FATAL: Unsuccessful: alter table product_item add constraint FK3C742463253F490B foreign key (product_id) references product<br />
07.04.2011 15:54:19 org.hibernate.tool.hbm2ddl.SchemaExport create<br />
FATAL: DB2 SQL Error: SQLCODE=-204, SQLSTATE=42704, SQLERRMC=DB2ADMIN.PRODUCT_ITEM, DRIVER=4.9.78<br />
07.04.2011 15:54:19 org.hibernate.tool.hbm2ddl.SchemaExport execute</p>
<p>I expected, that this is covered by the @OneToMany Annotation, where nullable=false is set.</p>
<p>Any idea? Thanks!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Stefan135</title>
		<link>http://boris.kirzner.info/blog/archives/2008/07/19/hibernate-annotations-the-many-to-many-association-with-composite-key/comment-page-2/#comment-38736</link>
		<dc:creator>Stefan135</dc:creator>
		<pubDate>Thu, 07 Apr 2011 13:27:27 +0000</pubDate>
		<guid isPermaLink="false">http://boris.kirzner.info/blog/archives/2008/07/19/hibernate-annotations-the-many-to-many-association-with-composite-key/#comment-38736</guid>
		<description>Has anybody an idea, why the product_item table is not being created by Hibernate? In my first attempt I had some typos, so I decided to copy&amp;paste the whole stuff. However I had to add &quot;implements Serializable&quot; to the item, product and productItem class. Otherwise I got an error in the ProductItemPk class, that Product is not a basic type.

I am using DB2 and Hibernate 3.62 with Netbeans. The project runs, also inserts my four items and my two products. But I don&#039;t see the association table. Please help!
Thanks!</description>
		<content:encoded><![CDATA[<p>Has anybody an idea, why the product_item table is not being created by Hibernate? In my first attempt I had some typos, so I decided to copy&amp;paste the whole stuff. However I had to add &#8220;implements Serializable&#8221; to the item, product and productItem class. Otherwise I got an error in the ProductItemPk class, that Product is not a basic type.</p>
<p>I am using DB2 and Hibernate 3.62 with Netbeans. The project runs, also inserts my four items and my two products. But I don&#8217;t see the association table. Please help!<br />
Thanks!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: roboto</title>
		<link>http://boris.kirzner.info/blog/archives/2008/07/19/hibernate-annotations-the-many-to-many-association-with-composite-key/comment-page-2/#comment-38534</link>
		<dc:creator>roboto</dc:creator>
		<pubDate>Sun, 27 Mar 2011 18:20:47 +0000</pubDate>
		<guid isPermaLink="false">http://boris.kirzner.info/blog/archives/2008/07/19/hibernate-annotations-the-many-to-many-association-with-composite-key/#comment-38534</guid>
		<description>Also is how to instantiate ProductItem  object?</description>
		<content:encoded><![CDATA[<p>Also is how to instantiate ProductItem  object?</p>
]]></content:encoded>
	</item>
</channel>
</rss>

