<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Tallan&#039;s Technology Blog &#187; Enterprise Java</title>
	<atom:link href="http://blog.tallan.com/category/enterprise-java/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.tallan.com</link>
	<description>Tallan&#039;s Top Technologists Share Their Thoughts on Today&#039;s Technology Challenges</description>
	<lastBuildDate>Mon, 06 Feb 2012 02:15:46 +0000</lastBuildDate>
	
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Java EE 6 Overview</title>
		<link>http://blog.tallan.com/2011/02/01/java-ee-6-overview/</link>
		<comments>http://blog.tallan.com/2011/02/01/java-ee-6-overview/#comments</comments>
		<pubDate>Tue, 01 Feb 2011 00:26:59 +0000</pubDate>
		<dc:creator>Dylan Barrett</dc:creator>
				<category><![CDATA[Enterprise Java]]></category>
		<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://blog.tallan.com/?p=975</guid>
		<description><![CDATA[Introduction
For the past year or so I have been working on a web development project using Java.  Like many Java projects, the project I was working on used 3rd party frameworks like Spring and Hibernate rather than utilizing the official Java EE stack.  Many developers have turned to these frameworks because the official Java EE [...]]]></description>
			<content:encoded><![CDATA[<h2>Introduction</h2>
<p>For the past year or so I have been working on a web development project using Java.  Like many Java projects, the project I was working on used 3rd party frameworks like Spring and Hibernate rather than utilizing the official Java EE stack.  Many developers have turned to these frameworks because the official Java EE stack had been notoriously cumbersome and difficult to use.  That is starting to change.  Java EE 5 started moving Java EE in a new direction.  Inspired by the ideologies of the 3rd party frameworks, the JCP, the standards community that works on the Java specification, began to make radical changes to the core of Java EE.  These changes have continued in the latest iteration, Java EE 6.</p>
<p>Interested in comparing Java EE 6 to my experiences with Spring and Hibernate, I picked up a book on the topic and began playing around with some code.  It was easy to see the influence of Spring and Hibernate in components such as JPA, Java EE&#8217;s ORM solution; a dependency injection component; and a focus on using POJOs.  The purpose of this article will be to give a brief overview of the core Java EE 6 technologies.</p>
<h2>Java Persistence API</h2>
<p>The Java Persistence API (JPA) is Java EE&#8217;s ORM solution.  It is meant to be a replacement for EJB Entity Beans, which have been deprecated in Java EE 6.  If you are familiar with Hibernate, then you will feel right at home with JPA.  In fact, many Hibernate developers played a role in the design and development of JPA.  For those of you unfamiliar with Object-Relational Mapping (ORM); it is a technique used to map your programs domain objects to the tables of your database.  ORMs usually make it very easy to perform CRUD operations on your data as well provide you with methods to query the underlying database using your object model rather than a standard SQL query.  ORMs commonly abstract away the underlying database and present a clean, cross-database API for accessing data.  JPA, like the latest versions of Hibernate, allow two methods of mapping your classes to the database: XML and annotations.  Following the trends of the day, use of annotations is encouraged over XML, but both are fully supported.  Using JPA is easy.  You only have to create a single, simple XML file containing database connection information, place the appropriate JPA annotations on your, and then you are ready to go!</p>
<h2>Enterprise JavaBeans</h2>
<p>Enterprise JavaBeans (EJB) is Java EE&#8217;s business layer solution.  The EJBs are where you will place most of your business logic.  The EJB engine will take care of many cross cutting concerns such as transactions and security for you.  EJB was heavily frowned upon in previous versions for being very heavy-weight and complicated.  Starting with version 3, EJB received a complete makeover.  It is now much more lightweight.  You can work almost entirely with POJOs and no longer need to inherit from EJB classes.  Like the rest of Java EE 6, EJB uses convention over configuration so the very little configuration you do have to do can be done using simple annotations.  There are two main types of EJB: Session Beans and Message Driven Beans.</p>
<p>Session Beans themselves can be classified into three types: Stateless, Stateful, and Singleton.  Stateless session beans are great for functionality that does not need to maintain state.  For example, a bean that simply queries the database to received the latest news updates can be stateless.  Because state does not need to be maintained, stateless beans can be kept in a pool and reused for multiple requests.  Stateful Beans are good for situations where you need to maintain state, such as keeping track of a customers shopping cart.  Stateful beans stay alive for the duration of the session.  Finally, Singleton Beans can be used for logic that you want to have available globally.  Only a single copy of Singleton bean is created and it is shared by all requests.</p>
<p>Message Driven Beans (MDB) are used to receive messages from Java Message Service (JMS).  An MDB can subscribe to messaging queues and can act on messages that appear in the queue.</p>
<h2>JavaServer Faces</h2>
<p>JavaServer Faces (JSF) is Java EE&#8217;s presentation technology.  It is similar to ASP.NET Web Forms in that it uses controls, called components in JSF, that emit HTML code.  Unlike ASP.NET Web Forms, however, JSF is an MVC framework.  Previous versions of JSF used JSPs as the view engine.  In Java EE 6, Facelets are the default view engine.  Unlike JSPs, Facelets are valid XML files that work a lot better with the JSF component model.  The model can be accessed through something called a managed bean.  A managed bean is a simple POJO that is annotated as a managed bean.  The properties of the managed bean can be used directly in the facelet and can be bound to the components.</p>
<h2>Other Changes</h2>
<p>The latest version of Java EE also provides dependency injection functionality.  This makes your application more loosely coupled and also helps make unit testing easier.  As mentioned earlier, Java EE 6 favors the use of annotations over XML configuration.  The people who complained of &#8220;XML Hell&#8221; in previous versions of Java EE can breathe a sigh of relief.  Convention over configuration has also taken a hold in the Java EE world.  Instead of having developers create a ton of configuration, Java EE will default to using reasonable defaults and allow for configuration when you wish to override the defaults.  This combined with the use of annotations over XML allows you to hit the ground running with Java EE faster than ever before!</p>
<h2>Conclusion</h2>
<p>Overall, I feel that Java EE 6 is a huge step in the right direction.  I think JPA is great and very comparable to Hibernate.  EJB has been improved a lot and is now much easier to use.  As far as JSF goes, I prefer to use a framework like Spring MVC with JSPs as the view engine.  I think that the JSP view engine is very powerful and I like working close to the HTML rather than abstracting it away.  Others may definitely enjoy the power of JSF though.  I feel that dependency injection in Java EE is a little lacking compared to what is available in Spring.  I would say that if you are working on an existing project using Spring or another third party framework, you probably shouldn&#8217;t bother changing over to Java EE 6.  However, if you are starting out on a new project, I would take a look at Java EE 6.  It is powerful and much easier to use now, having learned a lot from frameworks like Spring and Hibernate.</p>
<h3>Want to learn more?</h3>
<p>I recommend the book <a href="http://www.amazon.com/Beginning-GlassFish-Experts-Voice-Technology/dp/143022889X/ref=sr_1_1?ie=UTF8&amp;qid=1296519896&amp;sr=8-1">Beginning Java EE 6 Platform with Glassfish 3</a> by Antonio Goncalves.  It is well written and gives a great overview of development with Java EE 6.</p>
<p>-Dylan</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.tallan.com/2011/02/01/java-ee-6-overview/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The Unstandard Tag Library: Using Constants Within JSPs</title>
		<link>http://blog.tallan.com/2010/07/01/the-unstandard-tag-library-using-constants-within-jsps/</link>
		<comments>http://blog.tallan.com/2010/07/01/the-unstandard-tag-library-using-constants-within-jsps/#comments</comments>
		<pubDate>Thu, 01 Jul 2010 14:18:20 +0000</pubDate>
		<dc:creator>Dylan Barrett</dc:creator>
				<category><![CDATA[Enterprise Java]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[JSP]]></category>

		<guid isPermaLink="false">http://blog.tallan.com/?p=536</guid>
		<description><![CDATA[Introduction
The Unstandard Tag Library is a JSP tag library that was developed as part of the Jakarta Project.  Its purpose is to provide a collection       of useful tags that people have been requesting for JSTL.  The library serves as a place to keep all of these tags [...]]]></description>
			<content:encoded><![CDATA[<h2>Introduction</h2>
<p>The Unstandard Tag Library is a JSP tag library that was developed as part of the Jakarta Project.  Its purpose is to provide a collection       of useful tags that people have been requesting for JSTL.  The library serves as a place to keep all of these tags until they are officially added to       the Standard Tag Library.  This article focuses on the use of one of the tags contained within the library, the useConstants tag.</p>
<h2>The Problem</h2>
<p>While working on a project for a client, I realized that they were using a Java class with constants to define strings used within the application.       The idea was to use the constants everywhere in the application where the strings were needed so they could easily be maintained in one location without       having to search through the whole application when making a change.  This makes sense, and is a common best practice.  I was working on a JSP page that       needed to use the constants from the class.  It is now considered bad practice to use Java Scriptlets in your JSP page.  It is much better to use the       Expression Language (EL) in combination with JSTL and other custom tags.  Trying to keep to this rule I quickly ran into a problem.  The EL does not allow       and easy way to access constants from a Java class.  That is where the Unstandard Tag Library&#8217;s useConstants tag comes in handy.</p>
<h2>How To Use It</h2>
<p>Once you have added the library to your project it is very simple to use.  Let&#8217;s assume we have a java class containing constants such as the one below:</p>
<pre class="brush: java;">
package com.tallan.unstandard;  

public class MyConstants {    

  public static final String MY_CONSTANT_1 = 'Hello World';
  public static final String MY_CONSTANT_2 = 'Goodbye World';  

}
</pre>
<p>Let&#8217;s also assume that we added the tag library to our page as follows:</p>
<pre class="brush: xml;">
&lt;%@ taglib uri=&quot;http://jakarta.apache.org/taglibs/unstandard-1.0&quot;
           prefix=&quot;un&quot;%&gt;
</pre>
<p>We can then utilize the useConstants tag as follows:</p>
<pre class="brush: xml;">
&lt;un:useConstants var=&quot;Constants&quot;
                 className=&quot;com.tallan.unstandard.MyConstants&quot; /&gt;
</pre>
<p>After we run this line of code, an object called Constants will be available for use on the page.  We can use it with the EL and access the constants as       properties of the object.  For example:</p>
<pre class="brush: xml;">
&lt;p&gt;${Constants.MY_CONSTANT_1}&lt;/p&gt;
</pre>
<p>This solves our problem of using constants from a Java class within a JSP page without relying on scriptlets.</p>
<h2>Where To Get It</h2>
<p>You may be thinking &#8220;This is great, but where can I find this library?&#8221;  Unfortunately the Jakarta project has stopped development of the library and no       longer makes it obvious where you can get the code.  If you look around on the Jakarta site you will find that they allow you to get the project out of       source control and build it with Maven, but this is a little bit of a hassle.  If you want an easier way to get the library just go       <a href="http://people.apache.org/builds/jakarta-taglibs-sandbox/nightly/projects/unstandard/jakarta-taglibs-sandbox-unstandard-20060829.zip">here</a>.       This site contains old binaries of the library and they should work just fine.</p>
<h2>Conclusion</h2>
<p>The Unstandard Tag Library contains many useful tags that can help in the development of our JSP pages.  While it is no longer being actively developed, it can still       be a very useful tool.  We covered how to access constants from a Java class using the library&#8217;s useConstants tag.</p>
<h3>Want to Learn More?</h3>
<p>If you want to learn more about the tags available in the Unstandard Tag Library and how to use them, then head over to the documentation page for the library       located <a href="http://jakarta.apache.org/taglibs/sandbox/doc/unstandard-doc/index.html">here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.tallan.com/2010/07/01/the-unstandard-tag-library-using-constants-within-jsps/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Java could be a pain to C# developers (Pass by Reference)</title>
		<link>http://blog.tallan.com/2009/03/06/java-could-be-a-pain-to-c-developers-pass-by-reference/</link>
		<comments>http://blog.tallan.com/2009/03/06/java-could-be-a-pain-to-c-developers-pass-by-reference/#comments</comments>
		<pubDate>Fri, 06 Mar 2009 20:18:04 +0000</pubDate>
		<dc:creator>seung</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[How To Guide]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Pass by Reference in Java]]></category>

		<guid isPermaLink="false">http://blogs.tallan.com/dotnetreflections/?p=108</guid>
		<description><![CDATA[In C++ and C#, developers have freedom to modify variables by directly having  access to memory location.
In C++,
#include &#60;stdio.h&#62;
void swapnum(int &#38;i, int &#38;j)
{
     int temp = i;
     i = j;
     j =  temp;
} 

int main(void)
{
     int a [...]]]></description>
			<content:encoded><![CDATA[<p>In C++ and C#, developers have freedom to modify variables by directly having  access to memory location.</p>
<p>In C++,</p>
<pre>#include &lt;stdio.h&gt;
void swapnum(int &amp;i, int &amp;j)
{
     int temp = i;
     i = j;
     j =  temp;
} 

int main(void)
{
     int a = 10;
     int b = 20;
     swapnum(a, b);
     printf("A is %d and B is %d\n", a, b);
     return  0;
}</pre>
<p>In C#,</p>
<pre>int a = 1;
modify(ref a); //now a=2
void modify(ref int a)
{
     a = 2;
}</pre>
<p>In Java, however, there&#8217;s no such thing as pass by reference. Even the  so-called pointers (created by &#8216;new&#8217; operator) are passed by copy of the  reference.</p>
<p>Thus, if you do the following,</p>
<pre>String a = "a";
modify(a); //a doesn't change, since a is being passed as  a copy of the pointer a.
void modify(String a)
{
     a = "b"
     //this a  is a different pointer, thus does not affect the real 'a' pointer outside of the  method.
}</pre>
<p>As you can see, there&#8217;s no direct way of modifying the variable. This has  become a problem for me in many cases, since from time to time, it is necessary  to have direct access to the variables.</p>
<p>The answer is by using a wrapper.</p>
<p>Here&#8217;s an example.</p>
<pre>String a = "a";
System.out.println(a); // 'a' gets printed
String[]  array = new String[]{a}; //add a copy of the pointer variable a to String  array
modify(array);
System.out.println(array[0]);

void modify(String[] array)
{
     array[0] = "b";
}</pre>
<p>This is not the most elegant way of doing it, but you get the idea.  <img src='http://blog.tallan.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>One thing to remember is that String[] array contains a copy of pointer &#8216;a&#8217;.  When you assign, or add, items to any collections such as array, you&#8217;re passing  a copy of a pointer. So the variable &#8216;a&#8217; in the example above still is pointing  to the value &#8216;a&#8217;, whereas array[0] points to &#8216;b&#8217;. In order to finalize the  pointer modification, you need to assign</p>
<pre>a = array[0].</pre>
<p>So, the basic idea is this: In Java, when you pass variables around, whether  they are pointers or primitive values, you&#8217;re always dealing with a copy of the  variables, not the variables themselves. If you understand the basic idea of  it, you can take advantage of the true &#8220;Pass by Reference&#8221;.</p>
<p>I hope this sort of &#8216;trick/hack&#8217; can be of help to you all. <img src='http://blog.tallan.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>-Seung Kim (SK)</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.tallan.com/2009/03/06/java-could-be-a-pain-to-c-developers-pass-by-reference/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Pass by reference</title>
		<link>http://blog.tallan.com/2009/03/06/pass-by-reference/</link>
		<comments>http://blog.tallan.com/2009/03/06/pass-by-reference/#comments</comments>
		<pubDate>Fri, 06 Mar 2009 20:00:31 +0000</pubDate>
		<dc:creator>seung</dc:creator>
				<category><![CDATA[Enterprise Java]]></category>
		<category><![CDATA[C++]]></category>
		<category><![CDATA[Pass by reference]]></category>
		<category><![CDATA[reference]]></category>

		<guid isPermaLink="false">http://www.blogenterprisejava.com/2009/03/06/pass-by-reference/</guid>
		<description><![CDATA[In C++ and C#, developers have freedom to modify variables by directly having access to memory location.
In C++,
#include &#60;stdio.h&#62;
void swapnum(int &#38;i, int &#38;j) {
int temp = i;
i = j;
j = temp;
}
int main(void) {
int a = 10;
int b = 20;
swapnum(a, b);
printf(&#8220;A is %d and B is %d\n&#8221;, a, b);
return 0;
}
In C#,
int a = 1;
modify(ref a); //now [...]]]></description>
			<content:encoded><![CDATA[<p>In C++ and C#, developers have freedom to modify variables by directly having access to memory location.</p>
<p>In C++,</p>
<p>#include &lt;stdio.h&gt;</p>
<p>void swapnum(int &amp;i, int &amp;j) {<br />
int temp = i;<br />
i = j;<br />
j = temp;<br />
}</p>
<p>int main(void) {<br />
int a = 10;<br />
int b = 20;</p>
<p>swapnum(a, b);<br />
printf(&#8220;A is %d and B is %d\n&#8221;, a, b);<br />
return 0;<br />
}</p>
<p>In C#,</p>
<p>int a = 1;</p>
<p>modify(ref a); //now a=2</p>
<p>void modify(ref int a)</p>
<p>{</p>
<p>a = 2;</p>
<p>}</p>
<p>In Java, however, there&#8217;s no such thing as pass by reference.  Even the so-called pointers (created by &#8216;new&#8217; operator) are passed by copy of the reference.</p>
<p>Thus, if you do the following,</p>
<p>String a = &#8220;a&#8221;;</p>
<p>modify(a); //a doesn&#8217;t change, since a is being passed as a copy of the pointer a.</p>
<p>void modify(String a)</p>
<p>{</p>
<p>a = &#8220;b&#8221; //this a is a different pointer, thus does not affect the real &#8216;a&#8217; pointer outside of the method.</p>
<p>}</p>
<p>As you can see, there&#8217;s no direct way of modifying the variable.  This has become a problem for me in many cases, since from time to time, it is necessary to have direct access to the variables.</p>
<p>The answer is by using a wrapper.</p>
<p>Here&#8217;s an example.</p>
<p>public class Test {<br />
public static void main(String[] args) {<br />
String a = &#8220;a&#8221;;<br />
System.out.println(a); // &#8216;a&#8217; gets printed<br />
String[] array = new String[]{a}; //adds a copy of pointer &#8216;a&#8217; to String array<br />
modify(array);<br />
System.out.println(array[0]);<br />
}<br />
public static void modify(String[] array) {<br />
array[0] = &#8220;b&#8221;;  //instantiating a new object &#8216;b&#8217; to the copy of variable a<br />
}<br />
}</p>
<p>This is not the most elegant way of doing it, but you get the idea. <img src='http://blog.tallan.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>One thing to remember is that String[] array contains a copy of pointer &#8216;a&#8217;.  When you assign, or add, items to any collections such as array, you&#8217;re passing a copy of a pointer.  So the variable &#8216;a&#8217; in the example above still is pointing to the value &#8216;a&#8217;, whereas array[0] points to &#8216;b&#8217;.  In order to finalize the pointer modification, you need to assign</p>
<p>a = array[0].</p>
<p>So, the basic idea is this:  In Java, when you pass variables around, whether they are pointers or primitive values, you&#8217;re always dealing with a copy of the variables, not the variables themselves.  If you understand the basic idea of it, you can take advantage of the true &#8220;Pass by Reference&#8221;.</p>
<p>I hope this sort of &#8216;trick/hack&#8217; can be of help to you all. <img src='http://blog.tallan.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>-Seung Kim (SK)</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.tallan.com/2009/03/06/pass-by-reference/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Cache as a cross-cutting concern</title>
		<link>http://blog.tallan.com/2008/12/11/cache-as-a-cross-cutting-concern/</link>
		<comments>http://blog.tallan.com/2008/12/11/cache-as-a-cross-cutting-concern/#comments</comments>
		<pubDate>Thu, 11 Dec 2008 20:41:05 +0000</pubDate>
		<dc:creator>seung</dc:creator>
				<category><![CDATA[Enterprise .NET]]></category>
		<category><![CDATA[Enterprise Java]]></category>
		<category><![CDATA[AOP]]></category>
		<category><![CDATA[Cache]]></category>
		<category><![CDATA[IoC]]></category>
		<category><![CDATA[Spring]]></category>
		<category><![CDATA[Spring.net]]></category>
		<category><![CDATA[SpringModules]]></category>

		<guid isPermaLink="false">http://www.blogenterprisejava.com/2008/12/11/cache-as-a-cross-cutting-concern/</guid>
		<description><![CDATA[I have been recently asked to look into the cache feature within Springmodule in Java community.
Since my current project utilizes spring and aop, I thought it would be a great idea to utilize AOP to cache data.
I actually wrote a prototype file and it was a very rudimentary yet working prototype.  However, I soon realized [...]]]></description>
			<content:encoded><![CDATA[<p>I have been recently asked to look into the cache feature within Springmodule in Java community.</p>
<p>Since my current project utilizes spring and aop, I thought it would be a great idea to utilize AOP to cache data.</p>
<p>I actually wrote a prototype file and it was a very rudimentary yet working prototype.  However, I soon realized that Springmodules already created such feature, and it toally is a great feature to use.</p>
<p>Using simple AOP concept, you intercept the method call and using method parameters as HashKeyGenerator input values, the Springmodules&#8217;s cache simply get/put data from/into cache storage.  Currently, I configured it to using OSCache for its native support by Springmodule Cache Provider.</p>
<p><a href="https://springmodules.dev.java.net/docs/reference/0.8/html/cache.html">https://springmodules.dev.java.net/docs/reference/0.8/html/cache.html</a></p>
<p>I believe as the frameworks such as Spring evolves, developers can truly focus on their logic and development without worries of logging, security, cache, and any other cross-cutting concerns.  AOP is truly revolutionlizing the software development industry.  I am very glad to see it happening.</p>
<p>Good news for .NET community is that spring.net also supports AOP based Cache.</p>
<p><a href="http://springframework.net/doc-latest/reference/html/aop-aspect-library.html">http://springframework.net/doc-latest/reference/html/aop-aspect-library.html</a></p>
<p>I think more and more developers should know of these great features that tremendously can help build great applications without any of the boiler-plate code.  AOP, IoC, ORM and other evolving industry standards truly the great assets that every developer should be aware of when developing/architecturing applications.</p>
<p>-Seung Kim (SK)</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.tallan.com/2008/12/11/cache-as-a-cross-cutting-concern/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Hibernate: Merge vs SaveOrUpdate</title>
		<link>http://blog.tallan.com/2008/09/18/hibernate-merge-vs-saveorupdate/</link>
		<comments>http://blog.tallan.com/2008/09/18/hibernate-merge-vs-saveorupdate/#comments</comments>
		<pubDate>Thu, 18 Sep 2008 23:02:03 +0000</pubDate>
		<dc:creator>seung</dc:creator>
				<category><![CDATA[Enterprise Java]]></category>
		<category><![CDATA[hibernate]]></category>
		<category><![CDATA[merge]]></category>
		<category><![CDATA[saveorupdate]]></category>

		<guid isPermaLink="false">http://www.blogenterprisejava.com/2008/09/18/hibernate-merge-vs-saveorupdate/</guid>
		<description><![CDATA[In my previous and current project, I have run into cases where I needed to save an object to database using hibernate, and from time to time, I run into some sort of Hibernate Session Exception.
 I did a bit of google search, and it turns out that when saving an object, I needed to make [...]]]></description>
			<content:encoded><![CDATA[<p>In my previous and current project, I have run into cases where I needed to save an object to database using hibernate, and from time to time, I run into some sort of Hibernate Session Exception.</p>
<p> I did a bit of google search, and it turns out that when saving an object, I needed to make sure the object was attached to Hibernate session.</p>
<p>This can be very tedious issue, since that means if you need to save an object that is not attached to a session, you need to do these.</p>
<ol>
<li>Retrieve the object using the Id value found within the object passed to you.</li>
<li>Update the property values one by one</li>
<li>Save the object back within the same Hibernate Session</li>
</ol>
<p>Here&#8217;s a quick summary that I found out about MERGE and SaveOrUpdate.</p>
<p>void saveOrUpdate(object)-&gt;object must be attached to a hibernate session (including all sub objects within the object), and once save/update is done, the object reflects the updated changes (e.g. primary key if saving a new object)<br />
<br />
Object merge(object)-&gt; object does not have to be attached to a hibernate session.  Once save/update is done, the object DOES NOT reflect the change.  The returned object reflects the changes, and it is attached to hibernate session.</p>
<p>MERGE method offers greater flexibility when it comes to saving data objects, since you need not worry about attaching object to Session.<br />
You can create an object, set Id, and other properties on your own, and save it without worrying about the Hibernate Session exception.<br />
If you&#8217;re using saveOrUpdate, the object saved MUST be attached to session.  I believe many people have experienced this issue.<br />
<br />
This means you can create a copy of object from Service layer and just pass the object to your DAO.  Hibernate takes care of MERGING the data to appropriate hibernate session attached object and saves the data.</p>
<p>The only downside of using MERGE is that the object passed does not reflect the changed information.  So, if you need to use the updated object, you must get it from the returned object, not the parameter object.</p>
<p>I hope this helps. <img src='http://blog.tallan.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>-SK</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.tallan.com/2008/09/18/hibernate-merge-vs-saveorupdate/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Java: Too many choices?</title>
		<link>http://blog.tallan.com/2008/05/15/java-too-many-choices/</link>
		<comments>http://blog.tallan.com/2008/05/15/java-too-many-choices/#comments</comments>
		<pubDate>Thu, 15 May 2008 15:58:11 +0000</pubDate>
		<dc:creator>Kim Stevens</dc:creator>
				<category><![CDATA[Misc]]></category>

		<guid isPermaLink="false">http://www.blogenterprisejava.com/2008/05/15/java-too-many-choices/</guid>
		<description><![CDATA[During my time with Tallan I have worked in both the MS camp and the Java camp. I prefer the Java side but I acknowledge that neither side is perfect.  One of the main issues I see on the Java side is the huge variety choices that an architect has when starting a new [...]]]></description>
			<content:encoded><![CDATA[<p><font size="2">During my time with Tallan I have worked in both the MS camp and the Java camp. I prefer the Java side but I acknowledge that neither side is perfect.  One of the main issues I see on the Java side is the huge variety choices that an architect has when starting a new project. I saw this article on DZone that seemed to summarize the situation well:</font></p>
<p><font size="2"><a href="https://mail.tallan.com/exchweb/bin/redir.asp?URL=http://icedjava.blogspot.com/2007/12/dear-java-thanks-for-complexity-of.html">http://icedjava.blogspot.com/2007/12/dear-java-thanks-for-complexity-of.html</a></font></p>
<p><font size="2">There is an interesting link from this blog posting. I have not read it in depth. It looked good on an initial skim. The author seems to be trying to be objective, rather than selling one framework over another. (Go past the pictures of his family&#8230; would be interesting to hear the presentation that goes along with this PDF):</font></p>
<p><font size="2">Comparison of frameworks:<br />
<a href="https://mail.tallan.com/exchweb/bin/redir.asp?URL=https://equinox.dev.java.net/framework-comparison/WebFrameworks.pdf">https://equinox.dev.java.net/framework-comparison/WebFrameworks.pdf</a></font></p>
<p><font size="2">I am interested in hearing others point of view on this (not looking to start a flame war but a skirmish maybe interesting <img src='http://blog.tallan.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  ).</font></p>
<p><font size="2">Thanks,</font></p>
<p><font size="2">Kim Stevens</font></p>
<p><font size="2">(Originally posted: 12/20/07)</font></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.tallan.com/2008/05/15/java-too-many-choices/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>mySQL &#8211;i-am-a-dummy</title>
		<link>http://blog.tallan.com/2008/03/25/mysql-i-am-a-dummy/</link>
		<comments>http://blog.tallan.com/2008/03/25/mysql-i-am-a-dummy/#comments</comments>
		<pubDate>Tue, 25 Mar 2008 18:18:05 +0000</pubDate>
		<dc:creator>Makarand Bhandari</dc:creator>
				<category><![CDATA[Misc]]></category>

		<guid isPermaLink="false">http://www.blogenterprisejava.com/2008/03/25/mysql-i-am-a-dummy/</guid>
		<description><![CDATA[Not Java related, but since most apps deal with databases, this is something new about mySQL I learned today!
(from the mySQL manual)
For beginners, a useful startup option is           --safe-updates (or           --i-am-a-dummy, which has the same [...]]]></description>
			<content:encoded><![CDATA[<p>Not Java related, but since most apps deal with databases, this is something new about mySQL I learned today!</p>
<p>(from the mySQL manual)</p>
<p>For beginners, a useful startup option is           <code class="option">--safe-updates</code> (or           <code class="option">--i-am-a-dummy</code>, which has the same effect).           This option was introduced in MySQL 3.23.11. It is helpful for           cases when you might have issued a <code class="literal">DELETE FROM           <em class="replaceable"><code>tbl_name</code></em></code> statement but           forgotten the <code class="literal">WHERE</code> clause. Normally, such           a statement deletes all rows from the table. With           <code class="option">--safe-updates</code>, you can delete rows only by           specifying the key values that identify them. This helps           prevent accidents.</p>
<p>When you use the <code class="option">--safe-updates</code> option,           <span><strong class="command">mysql</strong></span> issues the following statement when           it connects to the MySQL server:</p>
<pre class="programlisting">SET SQL_SAFE_UPDATES=1,SQL_SELECT_LIMIT=1000, SQL_MAX_JOIN_SIZE=1000000;</pre>
<p>See Section 12.5.3, “<code class="literal">SET</code> Syntax”.</p>
<p>The <code class="literal">SET</code> statement has the following           effects:</p>
<p class="itemizedlist">&nbsp;</p>
<ul>
<li>               You are not allowed to execute an               <code class="literal">UPDATE</code> or <code class="literal">DELETE</code>               statement unless you specify a key constraint in the               <code class="literal">WHERE</code> clause or provide a               <code class="literal">LIMIT</code> clause (or both). For example:
<pre class="programlisting">UPDATE <em class="replaceable"><code>tbl_name</code></em> SET <em class="replaceable"><code>not_key_column</code></em>=<em class="replaceable"><code>val</code></em> WHERE <em class="replaceable"><code>key_column</code></em>=<em class="replaceable"><code>val</code></em>;

UPDATE <em class="replaceable"><code>tbl_name</code></em> SET <em class="replaceable"><code>not_key_column</code></em>=<em class="replaceable"><code>val</code></em> LIMIT 1;</pre>
</li>
<li>               The server limits all large <code class="literal">SELECT</code>               results to 1,000 rows unless the statement includes a               <code class="literal">LIMIT</code> clause.</li>
<li>               The server aborts multiple-table <code class="literal">SELECT</code>               statements that probably need to examine more than               1,000,000 row combinations.</li>
</ul>
<p>To specify limits different from 1,000 and 1,000,000, you can           override the defaults by using the           <code class="option">--select_limit</code> and           <code class="option">--max_join_size</code> options:</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.tallan.com/2008/03/25/mysql-i-am-a-dummy/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>EclEmma &#8211; Unit Test Coverage Analysis in Eclipse</title>
		<link>http://blog.tallan.com/2008/03/24/eclemma-unit-test-coverage-analysis-in-eclipse/</link>
		<comments>http://blog.tallan.com/2008/03/24/eclemma-unit-test-coverage-analysis-in-eclipse/#comments</comments>
		<pubDate>Mon, 24 Mar 2008 19:42:43 +0000</pubDate>
		<dc:creator>Andrew Nichols</dc:creator>
				<category><![CDATA[Product Reviews]]></category>

		<guid isPermaLink="false">http://www.blogenterprisejava.com/2008/03/24/eclemma-unit-test-coverage-analysis-in-eclipse/</guid>
		<description><![CDATA[I was recently looking for a unit test coverage analyzer such as JCoverage for a project I&#8217;m working on.  After reviewing several tools I discovered an amazing free tool called EclEmma.
I&#8217;ve used JCoverage in the past and while it&#8217;s HTML based reports are useful for project managers they are less so for developers.  [...]]]></description>
			<content:encoded><![CDATA[<p>I was recently looking for a unit test coverage analyzer such as JCoverage for a project I&#8217;m working on.  After reviewing several tools I discovered an amazing free tool called <a href="http://eclemma.org/">EclEmma</a>.</p>
<p>I&#8217;ve used JCoverage in the past and while it&#8217;s HTML based reports are useful for project managers they are less so for developers.  This tool essentially gives you the same information, but directly in Eclipse.  You simply run the analyzer on either a single class or a set of classes and viola… you have your coverage report.</p>
<p>It even color codes each line of code within your editor window.</p>
<p><img src="http://blog.tallan.com/wp-content/uploads/2008/03/032408-1942-eclemmaunit1.png" /></p>
<p>Use the <a href="http://update.eclemma.org/">http://update.eclemma.org/</a> update site to install EclEmma.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.tallan.com/2008/03/24/eclemma-unit-test-coverage-analysis-in-eclipse/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

