<?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: EJB 3.0 Persistence &#8211; ManyToMany relations or the objectification of the intersection table</title>
	<atom:link href="http://technology.amis.nl/2006/01/02/ejb-30-persistence-manytomany-relations-or-the-objectification-of-the-intersection-table/feed/" rel="self" type="application/rss+xml" />
	<link>http://technology.amis.nl/2006/01/02/ejb-30-persistence-manytomany-relations-or-the-objectification-of-the-intersection-table/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=ejb-30-persistence-manytomany-relations-or-the-objectification-of-the-intersection-table</link>
	<description></description>
	<lastBuildDate>Fri, 12 Apr 2013 10:04:09 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5.1</generator>
	<item>
		<title>By: Peter</title>
		<link>http://technology.amis.nl/2006/01/02/ejb-30-persistence-manytomany-relations-or-the-objectification-of-the-intersection-table/#comment-2752</link>
		<dc:creator>Peter</dc:creator>
		<pubDate>Sat, 07 Jun 2008 08:00:43 +0000</pubDate>
		<guid isPermaLink="false">http://technology.amis.nl/blog/?p=972#comment-2752</guid>
		<description><![CDATA[The refresh() exception is not a contradiction to the specification.  Per the specification, the entity passed to the merge() method becomes unmanaged, and the method returns a new T entity that IS managed.  For the example, the following code would be successful:

tx.begin();
jsf.setTitle(jsf.getTitle()+&quot;?&quot;);
jsf = libraryService.getEntityManager().merge(jsf);
libraryService.getEntityManager().refresh(jsf);
tx.commit();

Make sure you don&#039;t lose managed objects through the merge() operation -- or many methods could throw the same exception refresh() did.

--PE]]></description>
		<content:encoded><![CDATA[<p>The refresh() exception is not a contradiction to the specification.  Per the specification, the entity passed to the merge() method becomes unmanaged, and the method returns a new T entity that IS managed.  For the example, the following code would be successful:</p>
<p>tx.begin();<br />
jsf.setTitle(jsf.getTitle()+&#8221;?&#8221;);<br />
jsf = libraryService.getEntityManager().merge(jsf);<br />
libraryService.getEntityManager().refresh(jsf);<br />
tx.commit();</p>
<p>Make sure you don&#8217;t lose managed objects through the merge() operation &#8212; or many methods could throw the same exception refresh() did.</p>
<p>&#8211;PE</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: mario kofler</title>
		<link>http://technology.amis.nl/2006/01/02/ejb-30-persistence-manytomany-relations-or-the-objectification-of-the-intersection-table/#comment-2751</link>
		<dc:creator>mario kofler</dc:creator>
		<pubDate>Thu, 13 Dec 2007 14:10:23 +0000</pubDate>
		<guid isPermaLink="false">http://technology.amis.nl/blog/?p=972#comment-2751</guid>
		<description><![CDATA[hello jim,

i believe he is doing this because he wants to have the possibility to delete the data in the join_table starting from both entities (author and book). if one would be mapped by the &quot;mappedBy&quot; parameter starting the deletion from this entity would not be possible because it is not the &quot;owning&quot; side of the relation.]]></description>
		<content:encoded><![CDATA[<p>hello jim,</p>
<p>i believe he is doing this because he wants to have the possibility to delete the data in the join_table starting from both entities (author and book). if one would be mapped by the &#8220;mappedBy&#8221; parameter starting the deletion from this entity would not be possible because it is not the &#8220;owning&#8221; side of the relation.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jim McCollom</title>
		<link>http://technology.amis.nl/2006/01/02/ejb-30-persistence-manytomany-relations-or-the-objectification-of-the-intersection-table/#comment-2750</link>
		<dc:creator>Jim McCollom</dc:creator>
		<pubDate>Tue, 23 Oct 2007 15:43:08 +0000</pubDate>
		<guid isPermaLink="false">http://technology.amis.nl/blog/?p=972#comment-2750</guid>
		<description><![CDATA[Great article. I was wondering why you mapped both of your classes with the @JoinTable annotation, instead of using the mappedBy parameter.
Like:
In Books.java:

@ManyToMany(cascade=CascadeType.ALL)
    @JoinTable(table = @Table(name = &quot;als_authorships&quot;), joinColumns = {
           @JoinColumn(name = &quot;bok_id&quot;)
       }, inverseJoinColumns = {
           @JoinColumn(name = &quot;atr_id&quot;)
       })
    public Collection getAuthors() {
        return this.authors;
    }

And in Authors.java

@ManyToMany(mappedBy=&quot;authors&quot;, cascade=CascadeType.ALL)
    public Collection getBooks() {
        return this.books;
    }]]></description>
		<content:encoded><![CDATA[<p>Great article. I was wondering why you mapped both of your classes with the @JoinTable annotation, instead of using the mappedBy parameter.<br />
Like:<br />
In Books.java:</p>
<p>@ManyToMany(cascade=CascadeType.ALL)<br />
    @JoinTable(table = @Table(name = &#8220;als_authorships&#8221;), joinColumns = {<br />
           @JoinColumn(name = &#8220;bok_id&#8221;)<br />
       }, inverseJoinColumns = {<br />
           @JoinColumn(name = &#8220;atr_id&#8221;)<br />
       })<br />
    public Collection getAuthors() {<br />
        return this.authors;<br />
    }</p>
<p>And in Authors.java</p>
<p>@ManyToMany(mappedBy=&#8221;authors&#8221;, cascade=CascadeType.ALL)<br />
    public Collection getBooks() {<br />
        return this.books;<br />
    }</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: jeroen dijkmeijer</title>
		<link>http://technology.amis.nl/2006/01/02/ejb-30-persistence-manytomany-relations-or-the-objectification-of-the-intersection-table/#comment-2749</link>
		<dc:creator>jeroen dijkmeijer</dc:creator>
		<pubDate>Wed, 03 Oct 2007 13:35:10 +0000</pubDate>
		<guid isPermaLink="false">http://technology.amis.nl/blog/?p=972#comment-2749</guid>
		<description><![CDATA[Good article,
but i&#039;m not sure whether the whole many-to-many mapping option in jpa is the right approach for use case like this, read my blog http://jdijkmeijer.blogspot.com/2007/10/many-to-many-jsf-solutions.html for some information and 2 short examples on how to implement it.
Jeroen.]]></description>
		<content:encoded><![CDATA[<p>Good article,<br />
but i&#8217;m not sure whether the whole many-to-many mapping option in jpa is the right approach for use case like this, read my blog <a href="http://jdijkmeijer.blogspot.com/2007/10/many-to-many-jsf-solutions.html" rel="nofollow">http://jdijkmeijer.blogspot.com/2007/10/many-to-many-jsf-solutions.html</a> for some information and 2 short examples on how to implement it.<br />
Jeroen.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Iner</title>
		<link>http://technology.amis.nl/2006/01/02/ejb-30-persistence-manytomany-relations-or-the-objectification-of-the-intersection-table/#comment-2748</link>
		<dc:creator>Iner</dc:creator>
		<pubDate>Tue, 02 Oct 2007 20:21:26 +0000</pubDate>
		<guid isPermaLink="false">http://technology.amis.nl/blog/?p=972#comment-2748</guid>
		<description><![CDATA[Hello,

Thanks for the article.
Having a bit of trouble though, you fill the tables with data from your als_data.sql.
Could you provide some code on how a fill up the book and the author, does the &#039;ALS_AUTHORSHIPS&#039;-table
get filled in some &#039;magical&#039; way ? I mean we do not have an Entity-class for that table.
So how would I write the correct code for inserting the books - would like to do that from a small web-page.

seen some examples out there, but they are full with errors.

hope that you can provide som help.

regards, Iner]]></description>
		<content:encoded><![CDATA[<p>Hello,</p>
<p>Thanks for the article.<br />
Having a bit of trouble though, you fill the tables with data from your als_data.sql.<br />
Could you provide some code on how a fill up the book and the author, does the &#8216;ALS_AUTHORSHIPS&#8217;-table<br />
get filled in some &#8216;magical&#8217; way ? I mean we do not have an Entity-class for that table.<br />
So how would I write the correct code for inserting the books &#8211; would like to do that from a small web-page.</p>
<p>seen some examples out there, but they are full with errors.</p>
<p>hope that you can provide som help.</p>
<p>regards, Iner</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Thomas</title>
		<link>http://technology.amis.nl/2006/01/02/ejb-30-persistence-manytomany-relations-or-the-objectification-of-the-intersection-table/#comment-2747</link>
		<dc:creator>Thomas</dc:creator>
		<pubDate>Sun, 23 Sep 2007 13:02:01 +0000</pubDate>
		<guid isPermaLink="false">http://technology.amis.nl/blog/?p=972#comment-2747</guid>
		<description><![CDATA[Good article :) I&#039;m also wondering how to get the intersection table attribute Contributor Type.
An Author has contributed to many books (stored in the Collection books), but it doesn&#039;t store if the author wrote the whole book or drew the illustrations. What is the best way to solve that?]]></description>
		<content:encoded><![CDATA[<p>Good article <img src='http://technology.amis.nl/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  I&#8217;m also wondering how to get the intersection table attribute Contributor Type.<br />
An Author has contributed to many books (stored in the Collection books), but it doesn&#8217;t store if the author wrote the whole book or drew the illustrations. What is the best way to solve that?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Roger Allen</title>
		<link>http://technology.amis.nl/2006/01/02/ejb-30-persistence-manytomany-relations-or-the-objectification-of-the-intersection-table/#comment-2746</link>
		<dc:creator>Roger Allen</dc:creator>
		<pubDate>Thu, 15 Feb 2007 18:37:06 +0000</pubDate>
		<guid isPermaLink="false">http://technology.amis.nl/blog/?p=972#comment-2746</guid>
		<description><![CDATA[I was just wondering how you would get to the intersection table attribute Contributor Type.]]></description>
		<content:encoded><![CDATA[<p>I was just wondering how you would get to the intersection table attribute Contributor Type.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Lucas Jellema</title>
		<link>http://technology.amis.nl/2006/01/02/ejb-30-persistence-manytomany-relations-or-the-objectification-of-the-intersection-table/#comment-2745</link>
		<dc:creator>Lucas Jellema</dc:creator>
		<pubDate>Mon, 16 Oct 2006 08:01:37 +0000</pubDate>
		<guid isPermaLink="false">http://technology.amis.nl/blog/?p=972#comment-2745</guid>
		<description><![CDATA[Good point. I was a bit sloppy when coding the example. Thanks for the correction.

Lucas]]></description>
		<content:encoded><![CDATA[<p>Good point. I was a bit sloppy when coding the example. Thanks for the correction.</p>
<p>Lucas</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Chris</title>
		<link>http://technology.amis.nl/2006/01/02/ejb-30-persistence-manytomany-relations-or-the-objectification-of-the-intersection-table/#comment-2744</link>
		<dc:creator>Chris</dc:creator>
		<pubDate>Thu, 22 Jun 2006 18:00:30 +0000</pubDate>
		<guid isPermaLink="false">http://technology.amis.nl/blog/?p=972#comment-2744</guid>
		<description><![CDATA[Great writeup.  One thing I&#039;d like to mention though is the merge/refresh functionality.  Refresh is only to be used on Managed entities, where as merge is used on detatched entities and will return the managed instance with the changes merged into it.  So to avoid the exception, your code really should be:

managedJsf = libraryService.getEntityManager().merge(jsf);
libraryService.getEntityManager().refresh(managedJsf );

Though it might be better just to call find and then refresh on the returned entity.

Best Regards]]></description>
		<content:encoded><![CDATA[<p>Great writeup.  One thing I&#8217;d like to mention though is the merge/refresh functionality.  Refresh is only to be used on Managed entities, where as merge is used on detatched entities and will return the managed instance with the changes merged into it.  So to avoid the exception, your code really should be:</p>
<p>managedJsf = libraryService.getEntityManager().merge(jsf);<br />
libraryService.getEntityManager().refresh(managedJsf );</p>
<p>Though it might be better just to call find and then refresh on the returned entity.</p>
<p>Best Regards</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: John</title>
		<link>http://technology.amis.nl/2006/01/02/ejb-30-persistence-manytomany-relations-or-the-objectification-of-the-intersection-table/#comment-2743</link>
		<dc:creator>John</dc:creator>
		<pubDate>Fri, 14 Apr 2006 02:43:41 +0000</pubDate>
		<guid isPermaLink="false">http://technology.amis.nl/blog/?p=972#comment-2743</guid>
		<description><![CDATA[Very good articles you wrote.  Thank you very much for sharing.]]></description>
		<content:encoded><![CDATA[<p>Very good articles you wrote.  Thank you very much for sharing.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
