<?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: A Delicious and Simple JPA Mapping tutorial: The Pizza Shop</title>
	<atom:link href="http://www.mikedesjardins.net/content/2008/01/new-jpa-tutorial-pizza-shop/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.mikedesjardins.net/content/2008/01/new-jpa-tutorial-pizza-shop/</link>
	<description>freelance software developer consultant in portland, maine</description>
	<lastBuildDate>Wed, 02 Feb 2011 18:16:08 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.3</generator>
	<item>
		<title>By: .mike</title>
		<link>http://www.mikedesjardins.net/content/2008/01/new-jpa-tutorial-pizza-shop/comment-page-1/#comment-77</link>
		<dc:creator>.mike</dc:creator>
		<pubDate>Mon, 31 Mar 2008 18:04:00 +0000</pubDate>
		<guid isPermaLink="false">http://mikedesjardins.us/wordpress/2008/01/a-delicious-and-simple-jpa-mapping-tutorial-the-pizza-shop/#comment-77</guid>
		<description>@Madhan - I can&#039;t think of a way to do that.  Populating the CreatedBy/ModifiedBy columns on the rest of the tables is relatively straightforward (I&#039;d do it with an EventListener... hey... that gives me an idea for my next post!).  But JPA can&#039;t really &quot;get at&quot; the contents of the JoinTable very easily.&lt;br/&gt;&lt;br/&gt;I guess I&#039;d ask &lt;br/&gt;1.) Under what circumstances you&#039;d be modifying the contents of the join table directly?  By its nature, a join table is comprised of a compound primary key, and little else.  It&#039;s &lt;i&gt;generally&lt;/i&gt; a bad idea to create a data model in which you&#039;re modifying primary keys... so if you&#039;re doing this often, you might want to rethink your data model a bit.   &lt;br/&gt;2.) Assuming that you&#039;re &lt;i&gt;not&lt;/i&gt; directly modifying the contents of the join table, then there should be little need for a ModifiedBy column.  That leaves CreatedBy.  And I can&#039;t think of an easy solution for that.&lt;br/&gt;&lt;br/&gt;If it&#039;s critical to have an audit trail of all inserts and updates, you might consider storing all of the changes in a separate auditing/log table.  You could then programatically populate the audit table using event listeners and/or specialized code.  E.g,. if a user were to add a Topping to a Pizza, you could capture that event in a listener and write a row to an audit table with the username of the user who performed that action.&lt;br/&gt;&lt;br/&gt;hth!</description>
		<content:encoded><![CDATA[<p>@Madhan &#8211; I can&#8217;t think of a way to do that.  Populating the CreatedBy/ModifiedBy columns on the rest of the tables is relatively straightforward (I&#8217;d do it with an EventListener&#8230; hey&#8230; that gives me an idea for my next post!).  But JPA can&#8217;t really &#8220;get at&#8221; the contents of the JoinTable very easily.</p>
<p>I guess I&#8217;d ask <br />1.) Under what circumstances you&#8217;d be modifying the contents of the join table directly?  By its nature, a join table is comprised of a compound primary key, and little else.  It&#8217;s <i>generally</i> a bad idea to create a data model in which you&#8217;re modifying primary keys&#8230; so if you&#8217;re doing this often, you might want to rethink your data model a bit.   <br />2.) Assuming that you&#8217;re <i>not</i> directly modifying the contents of the join table, then there should be little need for a ModifiedBy column.  That leaves CreatedBy.  And I can&#8217;t think of an easy solution for that.</p>
<p>If it&#8217;s critical to have an audit trail of all inserts and updates, you might consider storing all of the changes in a separate auditing/log table.  You could then programatically populate the audit table using event listeners and/or specialized code.  E.g,. if a user were to add a Topping to a Pizza, you could capture that event in a listener and write a row to an audit table with the username of the user who performed that action.</p>
<p>hth!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Anonymous</title>
		<link>http://www.mikedesjardins.net/content/2008/01/new-jpa-tutorial-pizza-shop/comment-page-1/#comment-75</link>
		<dc:creator>Anonymous</dc:creator>
		<pubDate>Fri, 28 Mar 2008 02:26:00 +0000</pubDate>
		<guid isPermaLink="false">http://mikedesjardins.us/wordpress/2008/01/a-delicious-and-simple-jpa-mapping-tutorial-the-pizza-shop/#comment-75</guid>
		<description>sehr gut...</description>
		<content:encoded><![CDATA[<p>sehr gut&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Anonymous</title>
		<link>http://www.mikedesjardins.net/content/2008/01/new-jpa-tutorial-pizza-shop/comment-page-1/#comment-74</link>
		<dc:creator>Anonymous</dc:creator>
		<pubDate>Thu, 27 Mar 2008 23:08:00 +0000</pubDate>
		<guid isPermaLink="false">http://mikedesjardins.us/wordpress/2008/01/a-delicious-and-simple-jpa-mapping-tutorial-the-pizza-shop/#comment-74</guid>
		<description>Mike,&lt;br/&gt;Sorry for the delayed response. &lt;br/&gt;Here is my experience when I used oracle:&lt;br/&gt;The application failed throwing the following error:&lt;br/&gt;&lt;br/&gt;Caused by: org.apache.openjpa.persistence.PersistenceException: ORA-01400: cannot insert NULL into (&quot;FSTCTLADM&quot;.&quot;PIZZA_TOPPING&quot;.&quot;PIZZA_TOPPING_ID&quot;)&lt;br/&gt;{prepstmnt 1967682888 INSERT INTO PIZZA_TOPPING (pizza_id, topping_id) VALUES (?, ?) [params=(int) 7, (int) 1]} [code=1400, state=23000]&lt;br/&gt;&lt;br/&gt;The thing is, in Oracle we need to use sequence to generate the id. But I couldn&#039;t define the @manyToMany annotation  to use &lt;br/&gt;the sequence. I don&#039;t know how to do it. &lt;br/&gt;Please let me know if there is a way in JPA to define the ID generator for the join table used in &lt;br/&gt;ManyToMany cases. &lt;br/&gt;&lt;br/&gt;To overcome this, I wrote a trigger for the join table PIZZA_TOPPING, to generate the ids using the sequence.&lt;br/&gt;Then the application worked. &lt;br/&gt;&lt;br/&gt;Still, I have a question: &lt;br/&gt;Let us consider I am adding  &#039;CreatedBy&#039;  and &#039;ModifiedBy&#039; columns in all the tables to be &lt;br/&gt;used for audit purposes. Ideally these columns would be populated by the user id who has logged into the application. &lt;br/&gt;This will work for all the tables except the join table PIZZA_TOPPING.&lt;br/&gt;Because, the application is going to supply only the&lt;br/&gt;&#039;pizza_id&#039; and the &#039;topping_id&#039; defined in the @JoinTable annotation. &lt;br/&gt;And my trigger is going to supply only the &#039;pizza_topping_id&#039;&lt;br/&gt;using a sequence. But how do the CreatedBy and ModifiedBy columns will be populated? The trigger can not do that as it wouldn&#039;t be aware of the fact that which user has logged into the application. Is there a way to populate additional fields in a join table used in manytomany case with JPA??&lt;br/&gt;&lt;br/&gt;Plz let me know your thoughts.&lt;br/&gt;&lt;br/&gt;Cheers&lt;br/&gt;Madhan</description>
		<content:encoded><![CDATA[<p>Mike,<br />Sorry for the delayed response. <br />Here is my experience when I used oracle:<br />The application failed throwing the following error:</p>
<p>Caused by: org.apache.openjpa.persistence.PersistenceException: ORA-01400: cannot insert NULL into (&#8220;FSTCTLADM&#8221;.&#8221;PIZZA_TOPPING&#8221;.&#8221;PIZZA_TOPPING_ID&#8221;)<br />{prepstmnt 1967682888 INSERT INTO PIZZA_TOPPING (pizza_id, topping_id) VALUES (?, ?) [params=(int) 7, (int) 1]} [code=1400, state=23000]</p>
<p>The thing is, in Oracle we need to use sequence to generate the id. But I couldn't define the @manyToMany annotation  to use <br />the sequence. I don't know how to do it. <br />Please let me know if there is a way in JPA to define the ID generator for the join table used in <br />ManyToMany cases. </p>
<p>To overcome this, I wrote a trigger for the join table PIZZA_TOPPING, to generate the ids using the sequence.<br />Then the application worked. </p>
<p>Still, I have a question: <br />Let us consider I am adding  'CreatedBy'  and 'ModifiedBy' columns in all the tables to be <br />used for audit purposes. Ideally these columns would be populated by the user id who has logged into the application. <br />This will work for all the tables except the join table PIZZA_TOPPING.<br />Because, the application is going to supply only the<br />'pizza_id' and the 'topping_id' defined in the @JoinTable annotation. <br />And my trigger is going to supply only the 'pizza_topping_id'<br />using a sequence. But how do the CreatedBy and ModifiedBy columns will be populated? The trigger can not do that as it wouldn't be aware of the fact that which user has logged into the application. Is there a way to populate additional fields in a join table used in manytomany case with JPA??</p>
<p>Plz let me know your thoughts.</p>
<p>Cheers<br />Madhan</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: .mike</title>
		<link>http://www.mikedesjardins.net/content/2008/01/new-jpa-tutorial-pizza-shop/comment-page-1/#comment-64</link>
		<dc:creator>.mike</dc:creator>
		<pubDate>Wed, 19 Mar 2008 18:48:00 +0000</pubDate>
		<guid isPermaLink="false">http://mikedesjardins.us/wordpress/2008/01/a-delicious-and-simple-jpa-mapping-tutorial-the-pizza-shop/#comment-64</guid>
		<description>@Madhan - believe it or not, I&#039;ve *never* used Oracle with JPA, so I don&#039;t know for sure how it would work!  I would expect that it&#039;d work a lot like Postgres, and for Postgres, the identities for the mapping table are handled automatically.  Is it not working that way?  Let me know what you find, &#039;cuz as someone who&#039;s never dealt with Oracle before, I&#039;d really like to know!</description>
		<content:encoded><![CDATA[<p>@Madhan &#8211; believe it or not, I&#8217;ve *never* used Oracle with JPA, so I don&#8217;t know for sure how it would work!  I would expect that it&#8217;d work a lot like Postgres, and for Postgres, the identities for the mapping table are handled automatically.  Is it not working that way?  Let me know what you find, &#8216;cuz as someone who&#8217;s never dealt with Oracle before, I&#8217;d really like to know!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Anonymous</title>
		<link>http://www.mikedesjardins.net/content/2008/01/new-jpa-tutorial-pizza-shop/comment-page-1/#comment-63</link>
		<dc:creator>Anonymous</dc:creator>
		<pubDate>Wed, 19 Mar 2008 18:38:00 +0000</pubDate>
		<guid isPermaLink="false">http://mikedesjardins.us/wordpress/2008/01/a-delicious-and-simple-jpa-mapping-tutorial-the-pizza-shop/#comment-63</guid>
		<description>It really is a great post Mike. Hats off!!&lt;br/&gt;I have a doubt. I am using oracle database. And I&#039;m using the sequence objects &lt;br/&gt;for generating the ids. And in the java classes I&#039;m using the following annotations to create the ids.&lt;br/&gt;&lt;br/&gt;@Id&lt;br/&gt;@GeneratedValue(generator=&quot;SEQUENCE_NAME&quot;)&lt;br/&gt;@SequenceGenerator(name=&quot;SEQUENCE_NAME&quot;,sequenceName=&quot;SEQUENCE_NAME&quot;)&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;My question is, how do I generate the ids for the mapping table (PIZZA_TOPPING)?&lt;br/&gt;Thanks in advance. Looking forword for your other posts.&lt;br/&gt;&lt;br/&gt;Cheers&lt;br/&gt;Madhan</description>
		<content:encoded><![CDATA[<p>It really is a great post Mike. Hats off!!<br />I have a doubt. I am using oracle database. And I&#8217;m using the sequence objects <br />for generating the ids. And in the java classes I&#8217;m using the following annotations to create the ids.</p>
<p>@Id<br />@GeneratedValue(generator=&#8221;SEQUENCE_NAME&#8221;)<br />@SequenceGenerator(name=&#8221;SEQUENCE_NAME&#8221;,sequenceName=&#8221;SEQUENCE_NAME&#8221;)</p>
<p>My question is, how do I generate the ids for the mapping table (PIZZA_TOPPING)?<br />Thanks in advance. Looking forword for your other posts.</p>
<p>Cheers<br />Madhan</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: .mike</title>
		<link>http://www.mikedesjardins.net/content/2008/01/new-jpa-tutorial-pizza-shop/comment-page-1/#comment-56</link>
		<dc:creator>.mike</dc:creator>
		<pubDate>Wed, 06 Feb 2008 21:36:00 +0000</pubDate>
		<guid isPermaLink="false">http://mikedesjardins.us/wordpress/2008/01/a-delicious-and-simple-jpa-mapping-tutorial-the-pizza-shop/#comment-56</guid>
		<description>Ooh - good catch!  I&#039;ll fix the diagram in a few hours, thanks!</description>
		<content:encoded><![CDATA[<p>Ooh &#8211; good catch!  I&#8217;ll fix the diagram in a few hours, thanks!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Anonymous</title>
		<link>http://www.mikedesjardins.net/content/2008/01/new-jpa-tutorial-pizza-shop/comment-page-1/#comment-55</link>
		<dc:creator>Anonymous</dc:creator>
		<pubDate>Wed, 06 Feb 2008 21:31:00 +0000</pubDate>
		<guid isPermaLink="false">http://mikedesjardins.us/wordpress/2008/01/a-delicious-and-simple-jpa-mapping-tutorial-the-pizza-shop/#comment-55</guid>
		<description>I think that connection between Pizza and Pizza_Order are wrong on ER diagram Same problem has connection between Pizza and Pizza_Special_Instructions.&lt;br/&gt;&lt;br/&gt;Thanks for good blog entry</description>
		<content:encoded><![CDATA[<p>I think that connection between Pizza and Pizza_Order are wrong on ER diagram Same problem has connection between Pizza and Pizza_Special_Instructions.</p>
<p>Thanks for good blog entry</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Anonymous</title>
		<link>http://www.mikedesjardins.net/content/2008/01/new-jpa-tutorial-pizza-shop/comment-page-1/#comment-54</link>
		<dc:creator>Anonymous</dc:creator>
		<pubDate>Wed, 06 Feb 2008 14:30:00 +0000</pubDate>
		<guid isPermaLink="false">http://mikedesjardins.us/wordpress/2008/01/a-delicious-and-simple-jpa-mapping-tutorial-the-pizza-shop/#comment-54</guid>
		<description>No comments ? Thanks Mike I don&#039;t know you but you are a star.</description>
		<content:encoded><![CDATA[<p>No comments ? Thanks Mike I don&#8217;t know you but you are a star.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

