<?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"
	>
<channel>
	<title>Comments on: How to get rid of Transfer Objects with EJB3 JPA? (Hint: Deprecate the Stateless Architecture!)</title>
	<atom:link href="http://www.michaelyuan.com/blog/2006/10/13/how-to-get-rid-of-transfer-objects-with-ejb3-jpa-hint-deprecate-the-stateless-architecture/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.michaelyuan.com/blog/2006/10/13/how-to-get-rid-of-transfer-objects-with-ejb3-jpa-hint-deprecate-the-stateless-architecture/</link>
	<description>"Science is a wonderful thing if one does not have to earn one's living at it" -- Albert Einstein</description>
	<pubDate>Wed, 07 Jan 2009 12:13:55 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.6</generator>
		<item>
		<title>By: Michael Yuan</title>
		<link>http://www.michaelyuan.com/blog/2006/10/13/how-to-get-rid-of-transfer-objects-with-ejb3-jpa-hint-deprecate-the-stateless-architecture/#comment-500</link>
		<dc:creator>Michael Yuan</dc:creator>
		<pubDate>Sat, 04 Nov 2006 03:47:36 +0000</pubDate>
		<guid isPermaLink="false">http://www.michaelyuan.com/blog/2006/10/13/how-to-get-rid-of-transfer-objects-with-ejb3-jpa-hint-deprecate-the-stateless-architecture/#comment-500</guid>
		<description>Hi Toddius,

I probably need to write another blog entry to properly address you questions. But here are some short answers: The key thing about Seam is that it offers "flexibility". Seam does provide support for stateless components and eager loading of data. So, if that is what you decide best for your application, you can use it with Seam. However, what if you *also* want to lazy load some data? Seam helps you do it correctly and efficiently.

You are right that lazy loading requires more round trips to the database, but without lazy loading, you might end up loading a big chunk of your entire database in one entity object if you have a complex schema. So, the performances pros and cons are all relative, you have to judge it for your own application.

On the other hand, Seam's stateful approach *reduces* database round trips by only flushing changes to the database at the end of each conversation. That is certainly useful if you read/write your DB a lot.

You also asked "What if my application is almost all read-only, yet highly personalized for the logged in user?". Now how do you develop such apps in the past? Do you push all stateful data into HTTP session? Seam manages the exact same amount of stateful data. So there is no performance / scalability loss. On the contrary, since Seam guard against memory leaks associated with long life HTTP sessions, you have significantly lower risk for memory leak in such applications with Seam.

cheers
Michael</description>
		<content:encoded><![CDATA[<p>Hi Toddius,</p>
<p>I probably need to write another blog entry to properly address you questions. But here are some short answers: The key thing about Seam is that it offers &#8220;flexibility&#8221;. Seam does provide support for stateless components and eager loading of data. So, if that is what you decide best for your application, you can use it with Seam. However, what if you *also* want to lazy load some data? Seam helps you do it correctly and efficiently.</p>
<p>You are right that lazy loading requires more round trips to the database, but without lazy loading, you might end up loading a big chunk of your entire database in one entity object if you have a complex schema. So, the performances pros and cons are all relative, you have to judge it for your own application.</p>
<p>On the other hand, Seam&#8217;s stateful approach *reduces* database round trips by only flushing changes to the database at the end of each conversation. That is certainly useful if you read/write your DB a lot.</p>
<p>You also asked &#8220;What if my application is almost all read-only, yet highly personalized for the logged in user?&#8221;. Now how do you develop such apps in the past? Do you push all stateful data into HTTP session? Seam manages the exact same amount of stateful data. So there is no performance / scalability loss. On the contrary, since Seam guard against memory leaks associated with long life HTTP sessions, you have significantly lower risk for memory leak in such applications with Seam.</p>
<p>cheers<br />
Michael</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Toddius Zho</title>
		<link>http://www.michaelyuan.com/blog/2006/10/13/how-to-get-rid-of-transfer-objects-with-ejb3-jpa-hint-deprecate-the-stateless-architecture/#comment-495</link>
		<dc:creator>Toddius Zho</dc:creator>
		<pubDate>Fri, 03 Nov 2006 23:36:22 +0000</pubDate>
		<guid isPermaLink="false">http://www.michaelyuan.com/blog/2006/10/13/how-to-get-rid-of-transfer-objects-with-ejb3-jpa-hint-deprecate-the-stateless-architecture/#comment-495</guid>
		<description>What if you want the same Business Object to also handle stateless Web Services? Would your answer be to use SEAM to back the Web Service as well, and now make them *stateful* Web Services?

I don't understand how SEAM can afford to maintain conversational state for thousands of concurrent users. If we are lazy-loading, how does a Conversation magically save me a round-trip to the database when traversing to a finer granularity? If the data was already out-of-the-database and held by the Conversation, then how can one still call that lazy-loading? Just because the web tier didn't get it yet?

Where do we incur most of the expense? Getting data out of the table in the first place? Or the later transformation into something the web tier can use?

What if my application is almost all read-only, yet highly personalized for the logged in user? Virtually none of the information is shareable! immutable != shareable. Middle-tier caching now *hinders* my application, not help it.</description>
		<content:encoded><![CDATA[<p>What if you want the same Business Object to also handle stateless Web Services? Would your answer be to use SEAM to back the Web Service as well, and now make them *stateful* Web Services?</p>
<p>I don&#8217;t understand how SEAM can afford to maintain conversational state for thousands of concurrent users. If we are lazy-loading, how does a Conversation magically save me a round-trip to the database when traversing to a finer granularity? If the data was already out-of-the-database and held by the Conversation, then how can one still call that lazy-loading? Just because the web tier didn&#8217;t get it yet?</p>
<p>Where do we incur most of the expense? Getting data out of the table in the first place? Or the later transformation into something the web tier can use?</p>
<p>What if my application is almost all read-only, yet highly personalized for the logged in user? Virtually none of the information is shareable! immutable != shareable. Middle-tier caching now *hinders* my application, not help it.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Michael Yuan</title>
		<link>http://www.michaelyuan.com/blog/2006/10/13/how-to-get-rid-of-transfer-objects-with-ejb3-jpa-hint-deprecate-the-stateless-architecture/#comment-47</link>
		<dc:creator>Michael Yuan</dc:creator>
		<pubDate>Sat, 14 Oct 2006 17:44:41 +0000</pubDate>
		<guid isPermaLink="false">http://www.michaelyuan.com/blog/2006/10/13/how-to-get-rid-of-transfer-objects-with-ejb3-jpa-hint-deprecate-the-stateless-architecture/#comment-47</guid>
		<description>Thanks Gavin. I really look forward to Seam 1.1!</description>
		<content:encoded><![CDATA[<p>Thanks Gavin. I really look forward to Seam 1.1!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Gavin</title>
		<link>http://www.michaelyuan.com/blog/2006/10/13/how-to-get-rid-of-transfer-objects-with-ejb3-jpa-hint-deprecate-the-stateless-architecture/#comment-46</link>
		<dc:creator>Gavin</dc:creator>
		<pubDate>Sat, 14 Oct 2006 16:32:20 +0000</pubDate>
		<guid isPermaLink="false">http://www.michaelyuan.com/blog/2006/10/13/how-to-get-rid-of-transfer-objects-with-ejb3-jpa-hint-deprecate-the-stateless-architecture/#comment-46</guid>
		<description>Exactly right, Michael, this problem was definitely anticipated and fixed by EJB3 and Seam. The solution is an extended persistence context with conversational scope.

By the way, the new release of Seam (due out this month) is optimized for use in an Ajax-based environment with many fine-grained, concurrent, asynchronous requests in the same session/conversation. In this kind of environment you absolutely *need* a stateful (and threadsafe) middle tier to avoid database traffic on every fine-grained request. (Traditional web application architectures not only suck at state management, they also suck at concurrency management.)</description>
		<content:encoded><![CDATA[<p>Exactly right, Michael, this problem was definitely anticipated and fixed by EJB3 and Seam. The solution is an extended persistence context with conversational scope.</p>
<p>By the way, the new release of Seam (due out this month) is optimized for use in an Ajax-based environment with many fine-grained, concurrent, asynchronous requests in the same session/conversation. In this kind of environment you absolutely *need* a stateful (and threadsafe) middle tier to avoid database traffic on every fine-grained request. (Traditional web application architectures not only suck at state management, they also suck at concurrency management.)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Michael Yuan</title>
		<link>http://www.michaelyuan.com/blog/2006/10/13/how-to-get-rid-of-transfer-objects-with-ejb3-jpa-hint-deprecate-the-stateless-architecture/#comment-45</link>
		<dc:creator>Michael Yuan</dc:creator>
		<pubDate>Fri, 13 Oct 2006 21:57:20 +0000</pubDate>
		<guid isPermaLink="false">http://www.michaelyuan.com/blog/2006/10/13/how-to-get-rid-of-transfer-objects-with-ejb3-jpa-hint-deprecate-the-stateless-architecture/#comment-45</guid>
		<description>Hi Diego,

Yes I understand that there are many factors you need to evaluate when choosing an architecture. But performance should not be a problem here. :)

1. You can always run Ajax servlets in separate Tomcat servers, but at the same time, you can generate all dynamic web pages in a JBoss container. Of course, I am not familiar your architecture (e.g., I do not know how much caching / DB saving you need from Ajax servlets).  So, maybe DTO is an okay trade-off in your situation. :)

2. "Modern" stateful architecture is is built on the same clustering technology as the HTTP session clustering. So, it should be at least as scalable as stateless + HTTP session. :)</description>
		<content:encoded><![CDATA[<p>Hi Diego,</p>
<p>Yes I understand that there are many factors you need to evaluate when choosing an architecture. But performance should not be a problem here. <img src='http://www.michaelyuan.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>1. You can always run Ajax servlets in separate Tomcat servers, but at the same time, you can generate all dynamic web pages in a JBoss container. Of course, I am not familiar your architecture (e.g., I do not know how much caching / DB saving you need from Ajax servlets).  So, maybe DTO is an okay trade-off in your situation. <img src='http://www.michaelyuan.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>2. &#8220;Modern&#8221; stateful architecture is is built on the same clustering technology as the HTTP session clustering. So, it should be at least as scalable as stateless + HTTP session. <img src='http://www.michaelyuan.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Diego Parrilla</title>
		<link>http://www.michaelyuan.com/blog/2006/10/13/how-to-get-rid-of-transfer-objects-with-ejb3-jpa-hint-deprecate-the-stateless-architecture/#comment-44</link>
		<dc:creator>Diego Parrilla</dc:creator>
		<pubDate>Fri, 13 Oct 2006 21:37:39 +0000</pubDate>
		<guid isPermaLink="false">http://www.michaelyuan.com/blog/2006/10/13/how-to-get-rid-of-transfer-objects-with-ejb3-jpa-hint-deprecate-the-stateless-architecture/#comment-44</guid>
		<description>I think SEAM can help, but I guess it does not fit with the projects I'm working because:

1) we want to split physically the EJBs running in JBOSS and the Web app running in TOMCAT. Why? We have identified that AJAX applications increase dramatically the number of hits to the Servlet container (obvious) but most of these request returns Read Only data, hence easy cacheable to avoid unnecesary requests to the middlelayer and the database. So the ratio of JVM running TOMCAT and JVM running JBOSS can be 3 to 1 or 5 to 1 (in my projects, of course, this is not a rule of thumb). Also, we push the use of JMS as resource contention manager in the middle layer: web developers does not need to know about JMS inners.

2) Stateful architectures are not evil, but they are harder to scale than Stateless architecture. I'm not quite sure of this assertion nowadays, but I like to be conservative when building highly scalable architectures.

Please correct me if I'm wrong with some of my opinions. 
Thank very much for your feedback.</description>
		<content:encoded><![CDATA[<p>I think SEAM can help, but I guess it does not fit with the projects I&#8217;m working because:</p>
<p>1) we want to split physically the EJBs running in JBOSS and the Web app running in TOMCAT. Why? We have identified that AJAX applications increase dramatically the number of hits to the Servlet container (obvious) but most of these request returns Read Only data, hence easy cacheable to avoid unnecesary requests to the middlelayer and the database. So the ratio of JVM running TOMCAT and JVM running JBOSS can be 3 to 1 or 5 to 1 (in my projects, of course, this is not a rule of thumb). Also, we push the use of JMS as resource contention manager in the middle layer: web developers does not need to know about JMS inners.</p>
<p>2) Stateful architectures are not evil, but they are harder to scale than Stateless architecture. I&#8217;m not quite sure of this assertion nowadays, but I like to be conservative when building highly scalable architectures.</p>
<p>Please correct me if I&#8217;m wrong with some of my opinions.<br />
Thank very much for your feedback.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
