<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss 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/" xmlns:creativeCommons="http://backend.userland.com/creativeCommonsRssModule" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>Loiane Groner</title>
	
	<link>http://loianegroner.com</link>
	<description>My development notes</description>
	<lastBuildDate>Mon, 02 Jan 2012 11:13:09 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/LoianeGroner" /><feedburner:info uri="loianegroner" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><creativeCommons:license>http://creativecommons.org/licenses/by-sa/2.0/</creativeCommons:license><feedburner:emailServiceId>LoianeGroner</feedburner:emailServiceId><feedburner:feedburnerHostname>http://feedburner.google.com</feedburner:feedburnerHostname><item>
		<title>ExtJS 4 First Look: Sample Chapter Available</title>
		<link>http://feedproxy.google.com/~r/LoianeGroner/~3/-Oo5UrLDkzk/</link>
		<comments>http://loianegroner.com/2011/12/extjs-4-first-look-sample-chapter-available/#comments</comments>
		<pubDate>Thu, 22 Dec 2011 11:36:59 +0000</pubDate>
		<dc:creator>Loiane</dc:creator>
				<category><![CDATA[Ext JS 4]]></category>
		<category><![CDATA[Book]]></category>
		<category><![CDATA[Ext JS 4 book]]></category>

		<guid isPermaLink="false">http://loianegroner.com/?p=1279</guid>
		<description><![CDATA[Hi everyone, I finally finished writing my ExtJS 4 book a couple of months ago and now the book was already uploaded to the printers. Just waiting to be published! Meanwhile, you can check out a sample chapter. It is chapter 04, and it is about charts. You can buy the book at the publisher&#8217;s [...]]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop Automatic --><!-- End Shareaholic LikeButtonSetTop Automatic --><p>Hi everyone,</p>
<p>I finally finished writing my ExtJS 4 book a couple of months ago and now the book was already uploaded to the printers. Just waiting to be published!</p>
<p>Meanwhile, you can check out a sample chapter. It is chapter 04, and it is about charts.</p>
<p>You can buy the book at the <a href="http://www.packtpub.com/ext-js-4-first-look/book" target="_blank">publisher&#8217;s website</a> or <a href="http://www.amazon.com/dp/1849516669/ref=as_li_qf_sp_asin_til?tag=loiagron-20&amp;camp=14573&amp;creative=327641&amp;linkCode=as1&amp;creativeASIN=1849516669&amp;adid=0S5CSH7MMNVD8P76T4QF&amp;&amp;ref-refURL=http%3A%2F%2Floianegroner.com%2F2011%2F08%2Fmy-book-extjs-4-first-look%2F" target="_blank">amazon.com</a></p>
<p>I hope you enjoy it!</p>
<p><a style="margin: 12px auto 6px auto; font-family: Helvetica,Arial,Sans-serif; font-style: normal; font-variant: normal; font-weight: normal; font-size: 14px; line-height: normal; font-size-adjust: none; font-stretch: normal; -x-system-font: none; display: block; text-decoration: underline;" title="View ExtJS 4 First Look - book - sample chapter: Upgraded Charts on Scribd" href="http://www.scribd.com/doc/76258563/ExtJS-4-First-Look-book-sample-chapter-Upgraded-Charts">ExtJS 4 First Look &#8211; book &#8211; sample chapter: Upgraded Charts</a><iframe id="doc_57353" src="http://www.scribd.com/embeds/76258563/content?start_page=1&amp;view_mode=list&amp;access_key=key-222sul7pudkynzlqxywl" frameborder="0" scrolling="no" width="100%" height="600" data-auto-height="true" data-aspect-ratio="0.772727272727273"></iframe><script type="text/javascript">// <![CDATA[
 (function() { var scribd = document.createElement("script"); scribd.type = "text/javascript"; scribd.async = true; scribd.src = "http://www.scribd.com/javascripts/embed_code/inject.js"; var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(scribd, s); })();
// ]]&gt;</script></p>
<div class="shr-publisher-1279"></div><!-- Start Shareaholic LikeButtonSetBottom Automatic --><!-- End Shareaholic LikeButtonSetBottom Automatic --><img src="http://loianegroner.com/?ak_action=api_record_view&id=1279&type=feed" alt="" /><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/LoianeGroner?a=-Oo5UrLDkzk:ibubeG1fAKg:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/LoianeGroner?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/LoianeGroner?a=-Oo5UrLDkzk:ibubeG1fAKg:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/LoianeGroner?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/LoianeGroner?a=-Oo5UrLDkzk:ibubeG1fAKg:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/LoianeGroner?i=-Oo5UrLDkzk:ibubeG1fAKg:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/LoianeGroner?a=-Oo5UrLDkzk:ibubeG1fAKg:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/LoianeGroner?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/LoianeGroner?a=-Oo5UrLDkzk:ibubeG1fAKg:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/LoianeGroner?i=-Oo5UrLDkzk:ibubeG1fAKg:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/LoianeGroner?a=-Oo5UrLDkzk:ibubeG1fAKg:I9og5sOYxJI"><img src="http://feeds.feedburner.com/~ff/LoianeGroner?d=I9og5sOYxJI" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/LoianeGroner/~4/-Oo5UrLDkzk" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://loianegroner.com/2011/12/extjs-4-first-look-sample-chapter-available/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://loianegroner.com/2011/12/extjs-4-first-look-sample-chapter-available/</feedburner:origLink></item>
		<item>
		<title>How to Load or Save Image using Hibernate – MySQL</title>
		<link>http://feedproxy.google.com/~r/LoianeGroner/~3/5VSY0CwjTzc/</link>
		<comments>http://loianegroner.com/2011/10/how-to-load-or-save-image-using-hibernate-mysql/#comments</comments>
		<pubDate>Tue, 18 Oct 2011 11:00:42 +0000</pubDate>
		<dc:creator>Loiane</dc:creator>
				<category><![CDATA[Hibernate]]></category>
		<category><![CDATA[annotations]]></category>
		<category><![CDATA[hibernate 3]]></category>
		<category><![CDATA[Hibernate 3.5]]></category>
		<category><![CDATA[hibernate annotations]]></category>
		<category><![CDATA[Load Image Hibernate]]></category>
		<category><![CDATA[Save Image Hibernate]]></category>

		<guid isPermaLink="false">http://loianegroner.com/?p=1226</guid>
		<description><![CDATA[This tutorial will walk you throughout how to save and load an image from database (MySQL) using Hibernate. Requirements For this sampel project, we are going to use: Eclipse IDE (you can use your favorite IDE); MySQL (you can use any other database, make sure to change the column type if required); Hibernate jars and dependencies [...]]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop Automatic --><!-- End Shareaholic LikeButtonSetTop Automatic --><p>This tutorial will walk you throughout how to save and load an image from database (<a href="http://www.mysql.com/" target="_blank">MySQL</a>) using <a href="http://www.hibernate.org/" target="_blank">Hibernate</a>.</p>
<h3>Requirements</h3>
<p>For this sampel project, we are going to use:</p>
<ul>
<li><a href="http://www.eclipse.org/" target="_blank">Eclipse IDE</a> (you can use your favorite IDE);</li>
<li><a href="http://www.mysql.com/" target="_blank">MySQL</a> (you can use any other database, make sure to change the column type if required);</li>
<li><a href="http://www.hibernate.org/" target="_blank">Hibernate </a>jars and dependencies (you can download the sample project with all required jars);</li>
<li><a href="http://www.junit.org/" target="_blank">JUnit </a>- for testing (jar also included in the sample project).</li>
</ul>
<h3>PrintScreen</h3>
<p>When we finish implementing this sample projeto, it should look like this:</p>
<p><a href="http://loianegroner.com/wp-content/uploads/2011/10/hibernate-image-loiane-01.png"><img class="aligncenter size-full wp-image-1254" title="hibernate-image-loiane-01" src="http://loianegroner.com/wp-content/uploads/2011/10/hibernate-image-loiane-01.png" alt="" width="257" height="326" /></a></p>
<h3>Database Model</h3>
<p><a href="http://loianegroner.com/wp-content/uploads/2011/10/hibernate-image-loiane-02.png"><img class="aligncenter size-full wp-image-1255" title="hibernate-image-loiane-02" src="http://loianegroner.com/wp-content/uploads/2011/10/hibernate-image-loiane-02.png" alt="" width="192" height="127" /></a></p>
<p>Before we get started with the sample projet, we have to run this sql script into <a href="http://www.mysql.com/" target="_blank">MySQL</a>:</p>
<pre class="brush: sql; collapse: false; first-line: 1; title: ; toolbar: true; wrap-lines: false; notranslate">
DROP SCHEMA IF EXISTS `blog` ;
CREATE SCHEMA IF NOT EXISTS `blog` DEFAULT CHARACTER SET latin1 COLLATE latin1_swedish_ci ;
USE `blog` ;

-- -----------------------------------------------------
-- Table `blog`.`BOOK`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `blog`.`BOOK` ;

CREATE  TABLE IF NOT EXISTS `blog`.`BOOK` (
  `BOOK_ID` INT NOT NULL AUTO_INCREMENT ,
  `BOOK_NAME` VARCHAR(45) NOT NULL ,
  `BOOK_IMAGE` MEDIUMBLOB NOT NULL ,
  PRIMARY KEY (`BOOK_ID`) )
ENGINE = InnoDB;
</pre>
<p>This script will create a table <em><strong>BOOK</strong></em>, which we are going to use in this tutorial.</p>
<h3>Book POJO</h3>
<p>We are going to use a simple <em><strong>POJO</strong></em> in this project. A <em>Book</em> has an <em>ID</em>, a <em>name</em> and an <em>image</em>, which is represented by an array of <em>bytes</em>.</p>
<p>As we are going to persist an image into the database, we have to use the <strong><em>BLOB</em></strong> type. <a href="http://www.mysql.com/" target="_blank">MySQL</a>has some variations of <em>BLOBs</em>, you can check the difference between them <a href="http://dev.mysql.com/doc/refman/5.0/en/blob.html" target="_blank">here</a>. In this example, we are going to use the <strong><em>Medium Blob</em></strong>, which can store <em>L + 3 bytes, where L &lt; 2^24</em>.</p>
<p>Make sure you do not forget to add the <em>column definition</em> on the <em>Column</em> annotation.</p>
<pre class="brush: java; collapse: false; first-line: 1; highlight: [22,23]; title: ; toolbar: true; wrap-lines: false; notranslate">
package com.loiane.model;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Lob;
import javax.persistence.Table;

@Entity
@Table(name=&quot;BOOK&quot;)
public class Book {

	@Id
	@GeneratedValue
	@Column(name=&quot;BOOK_ID&quot;)
	private long id;

	@Column(name=&quot;BOOK_NAME&quot;, nullable=false)
	private String name;

	@Lob
	@Column(name=&quot;BOOK_IMAGE&quot;, nullable=false, columnDefinition=&quot;mediumblob&quot;)
	private byte[] image;

	public long getId() {
		return id;
	}

	public void setId(long id) {
		this.id = id;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public byte[] getImage() {
		return image;
	}

	public void setImage(byte[] image) {
		this.image = image;
	}
}
</pre>
<h3>Hibernate Config</h3>
<p>This configuration file contains the required info used to connect to the database.</p>
<pre class="brush: xml; collapse: false; first-line: 1; title: ; toolbar: true; wrap-lines: false; notranslate">
&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
&lt;!DOCTYPE hibernate-configuration PUBLIC
		&quot;-//Hibernate/Hibernate Configuration DTD 3.0//EN&quot;
		&quot;http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd&quot;&gt;
&lt;hibernate-configuration&gt;
    &lt;session-factory&gt;
        &lt;property name=&quot;hibernate.connection.driver_class&quot;&gt;com.mysql.jdbc.Driver&lt;/property&gt;
        &lt;property name=&quot;hibernate.connection.url&quot;&gt;jdbc:mysql://localhost/blog&lt;/property&gt;
        &lt;property name=&quot;hibernate.connection.username&quot;&gt;root&lt;/property&gt;
        &lt;property name=&quot;hibernate.connection.password&quot;&gt;root&lt;/property&gt;
        &lt;property name=&quot;hibernate.dialect&quot;&gt;org.hibernate.dialect.MySQLDialect&lt;/property&gt;
    	&lt;property name=&quot;connection.pool_size&quot;&gt;1&lt;/property&gt;
    	&lt;property name=&quot;show_sql&quot;&gt;true&lt;/property&gt;
    &lt;/session-factory&gt;
&lt;/hibernate-configuration&gt;
</pre>
<h3>Hibernate Util</h3>
<p>The <em>HibernateUtil</em> class helps in creating the <em>SessionFactory</em> from the Hibernate configuration file.</p>
<pre class="brush: java; collapse: false; first-line: 1; title: ; toolbar: true; wrap-lines: false; notranslate">
package com.loiane.hibernate;

import org.hibernate.SessionFactory;
import org.hibernate.cfg.AnnotationConfiguration;

import com.loiane.model.Book;

public class HibernateUtil {

	private static final SessionFactory sessionFactory;

	static {
		try {
			sessionFactory = new AnnotationConfiguration()
								.configure()
								.addPackage(&quot;com.loiane.model&quot;) //the fully qualified package name
								.addAnnotatedClass(Book.class)
								.buildSessionFactory();

		} catch (Throwable ex) {
			System.err.println(&quot;Initial SessionFactory creation failed.&quot; + ex);
			throw new ExceptionInInitializerError(ex);
		}
	}

	public static SessionFactory getSessionFactory() {
		return sessionFactory;
	}
}
</pre>
<h3>DAO</h3>
<p>In this class, we created two methods: one to save a <em>Book</em> instance into the database and another one to load a <em>Book</em> instance from the database.</p>
<pre class="brush: java; collapse: false; first-line: 1; title: ; toolbar: true; wrap-lines: false; notranslate">
package com.loiane.dao;

import org.hibernate.HibernateException;
import org.hibernate.Session;
import org.hibernate.Transaction;

import com.loiane.hibernate.HibernateUtil;
import com.loiane.model.Book;

public class BookDAOImpl {

	/**
	 * Inserts a row in the BOOK table.
	 * Do not need to pass the id, it will be generated.
	 * @param book
	 * @return an instance of the object Book
	 */
	public Book saveBook(Book book)
	{
		Session session = HibernateUtil.getSessionFactory().openSession();
		Transaction transaction = null;
		try {
			transaction = session.beginTransaction();
			session.save(book);
			transaction.commit();
		} catch (HibernateException e) {
			transaction.rollback();
			e.printStackTrace();
		} finally {
			session.close();
		}
		return book;
	}

	/**
	 * Delete a book from database
	 * @param bookId id of the book to be retrieved
	 */
	public Book getBook(Long bookId)
	{
		Session session = HibernateUtil.getSessionFactory().openSession();
		try {
			Book book = (Book) session.get(Book.class, bookId);
			return book;
		} catch (HibernateException e) {
			e.printStackTrace();
		} finally {
			session.close();
		}
		return null;
	}
}
</pre>
<h3>Test</h3>
<p>To test it, first we need to create a <em>Book</em> instance and set an image to the image attribute. To do so, we need to load an image from the hard drive, and we are going to use the one located in the images folder. Then we can call the DAO class and save into the database.</p>
<p>Then we can try to load the image. Just to make sure it is the same image we loaded, we are going to save it in the hard drive.</p>
<pre class="brush: java; collapse: false; first-line: 1; title: ; toolbar: true; wrap-lines: false; notranslate">
package com.loiane.test;

import static org.junit.Assert.assertNotNull;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;

import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;

import com.loiane.dao.BookDAOImpl;
import com.loiane.model.Book;

public class TestBookDAO {

	private static BookDAOImpl bookDAO;

	@BeforeClass
	public static  void runBeforeClass() {
		bookDAO = new BookDAOImpl();
	}

	@AfterClass
	public static void runAfterClass() {
		bookDAO = null;
	}

	/**
	 * Test method for {@link com.loiane.dao.BookDAOImpl#saveBook()}.
	 */
	@Test
	public void testSaveBook() {

		//File file = new File(&quot;images\\extjsfirstlook.jpg&quot;); //windows
		File file = new File(&quot;images/extjsfirstlook.jpg&quot;);
        byte[] bFile = new byte[(int) file.length()];

        try {
	        FileInputStream fileInputStream = new FileInputStream(file);
	        fileInputStream.read(bFile);
	        fileInputStream.close();
        } catch (Exception e) {
	        e.printStackTrace();
        }

        Book book = new Book();
        book.setName(&quot;Ext JS 4 First Look&quot;);
        book.setImage(bFile);

        bookDAO.saveBook(book);

        assertNotNull(book.getId());
	}

	/**
	 * Test method for {@link com.loiane.dao.BookDAOImpl#getBook()}.
	 */
	@Test
	public void testGetBook() {

		Book book = bookDAO.getBook((long) 1);

		assertNotNull(book);

		try{
        	//FileOutputStream fos = new FileOutputStream(&quot;images\\output.jpg&quot;);  //windows
        	FileOutputStream fos = new FileOutputStream(&quot;images/output.jpg&quot;);
            fos.write(book.getImage());
            fos.close();
        }catch(Exception e){
        	e.printStackTrace();
        }
	}
}
</pre>
<p>To verify if it was really saved, let&#8217;s check the table <em>Book</em>:</p>
<p><a href="http://loianegroner.com/wp-content/uploads/2011/10/hibernate-image-loiane-03.png"><img class="aligncenter size-full wp-image-1256" title="hibernate-image-loiane-03" src="http://loianegroner.com/wp-content/uploads/2011/10/hibernate-image-loiane-03.png" alt="" width="337" height="83" /></a></p>
<p>and if we right click&#8230;</p>
<p><a href="http://loianegroner.com/wp-content/uploads/2011/10/hibernate-image-loiane-04.png"><img class="aligncenter size-full wp-image-1257" title="hibernate-image-loiane-04" src="http://loianegroner.com/wp-content/uploads/2011/10/hibernate-image-loiane-04.png" alt="" width="313" height="336" /></a></p>
<p>and choose to see the image we just saved, we will see it:</p>
<p style="text-align: center;"><a href="http://loianegroner.com/wp-content/uploads/2011/10/hibernate-image-loiane-05.png"><img class="aligncenter size-full wp-image-1258" title="hibernate-image-loiane-05" src="http://loianegroner.com/wp-content/uploads/2011/10/hibernate-image-loiane-05.png" alt="" width="568" height="333" /></a></p>
<h3>Source Code Download</h3>
<p>You can download the complete source code (or <em>fork/clone</em> the project &#8211; <em>git</em>) from:</p>
<p><em><strong>Github</strong></em>: <a href="https://github.com/loiane/hibernate-image-example" target="_blank">https://github.com/loiane/hibernate-image-example</a></p>
<p><em><strong>BitBucket</strong></em>: <a href="https://bitbucket.org/loiane/hibernate-image-example/downloads" target="_blank">https://bitbucket.org/loiane/hibernate-image-example/downloads</a></p>
<p>Happy Coding!</p>
<div class="shr-publisher-1226"></div><!-- Start Shareaholic LikeButtonSetBottom Automatic --><!-- End Shareaholic LikeButtonSetBottom Automatic --><img src="http://loianegroner.com/?ak_action=api_record_view&id=1226&type=feed" alt="" /><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/LoianeGroner?a=5VSY0CwjTzc:bIjTL-q3cSk:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/LoianeGroner?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/LoianeGroner?a=5VSY0CwjTzc:bIjTL-q3cSk:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/LoianeGroner?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/LoianeGroner?a=5VSY0CwjTzc:bIjTL-q3cSk:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/LoianeGroner?i=5VSY0CwjTzc:bIjTL-q3cSk:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/LoianeGroner?a=5VSY0CwjTzc:bIjTL-q3cSk:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/LoianeGroner?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/LoianeGroner?a=5VSY0CwjTzc:bIjTL-q3cSk:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/LoianeGroner?i=5VSY0CwjTzc:bIjTL-q3cSk:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/LoianeGroner?a=5VSY0CwjTzc:bIjTL-q3cSk:I9og5sOYxJI"><img src="http://feeds.feedburner.com/~ff/LoianeGroner?d=I9og5sOYxJI" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/LoianeGroner/~4/5VSY0CwjTzc" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://loianegroner.com/2011/10/how-to-load-or-save-image-using-hibernate-mysql/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		<feedburner:origLink>http://loianegroner.com/2011/10/how-to-load-or-save-image-using-hibernate-mysql/</feedburner:origLink></item>
		<item>
		<title>[Screencast] Spket: Setting up Eclipse IDE for Ext JS 4 development</title>
		<link>http://feedproxy.google.com/~r/LoianeGroner/~3/ZoNVUU5wuZg/</link>
		<comments>http://loianegroner.com/2011/10/screencast-spket-setting-up-eclipse-ide-for-ext-js-4-development/#comments</comments>
		<pubDate>Fri, 14 Oct 2011 12:27:00 +0000</pubDate>
		<dc:creator>Loiane</dc:creator>
				<category><![CDATA[Ext JS 4]]></category>
		<category><![CDATA[Screencasts]]></category>
		<category><![CDATA[Eclipse]]></category>
		<category><![CDATA[ExtJS 4]]></category>
		<category><![CDATA[Spket]]></category>

		<guid isPermaLink="false">http://loianegroner.com/?p=1266</guid>
		<description><![CDATA[This screencast will walk you through how to set up Eclipse IDE for Ext JS 4 development with Spekt Eclipse plugin. It demonstrates how to enable the autocomplete feature on Eclipse or Aptana I wrote a tutorial about it a while ago, but it demonstrates how to configure Spket with Ext JS 3. This is an updated tutorial [...]]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop Automatic --><!-- End Shareaholic LikeButtonSetTop Automatic --><p>This screencast will walk you through how to set up <a href="http://www.eclipse.org/" target="_blank">Eclipse IDE</a> for <a href="http://www.sencha.com/products/extjs/" target="_blank">Ext JS 4</a> development with <a href="http://spket.com/" target="_blank">Spekt Eclipse plugin</a>. It demonstrates how to enable the autocomplete feature on <a href="http://www.eclipse.org/" target="_blank">Eclipse </a>or <a href="http://www.aptana.com/" target="_blank">Aptana</a></p>
<p><a title="Spket: Setting up Eclipse IDE for Ext JS and JQuery development" href="http://loianegroner.com/2010/11/spket-setting-up-eclipse-ide-for-ext-js-and-jquery-development/">I wrote a tutorial about it a while ago, but it demonstrates how to configure Spket with Ext JS 3</a>. This is an updated tutorial for <a href="http://www.sencha.com/products/extjs/" target="_blank">Ext JS 4</a>.</p>
<p style="text-align: center;"><iframe src="http://player.vimeo.com/video/30308177?title=0&amp;byline=0&amp;portrait=0" frameborder="0" width="550" height="344"></iframe></p>
<p><a href="http://vimeo.com/30308177">Spket: Setting up Eclipse IDE for Ext JS 4 development</a> from <a href="http://vimeo.com/loiane">Loiane Groner</a> on <a href="http://vimeo.com">Vimeo</a>.</p>
<p>This is a new category on my blog. On the next screencasts I will try to say something instead of writing! Hope you liked it!</p>
<p>Happy Coding! <img src='http://loianegroner.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<div class="shr-publisher-1266"></div><!-- Start Shareaholic LikeButtonSetBottom Automatic --><!-- End Shareaholic LikeButtonSetBottom Automatic --><img src="http://loianegroner.com/?ak_action=api_record_view&id=1266&type=feed" alt="" /><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/LoianeGroner?a=ZoNVUU5wuZg:TF-QMn0NDl8:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/LoianeGroner?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/LoianeGroner?a=ZoNVUU5wuZg:TF-QMn0NDl8:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/LoianeGroner?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/LoianeGroner?a=ZoNVUU5wuZg:TF-QMn0NDl8:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/LoianeGroner?i=ZoNVUU5wuZg:TF-QMn0NDl8:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/LoianeGroner?a=ZoNVUU5wuZg:TF-QMn0NDl8:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/LoianeGroner?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/LoianeGroner?a=ZoNVUU5wuZg:TF-QMn0NDl8:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/LoianeGroner?i=ZoNVUU5wuZg:TF-QMn0NDl8:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/LoianeGroner?a=ZoNVUU5wuZg:TF-QMn0NDl8:I9og5sOYxJI"><img src="http://feeds.feedburner.com/~ff/LoianeGroner?d=I9og5sOYxJI" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/LoianeGroner/~4/ZoNVUU5wuZg" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://loianegroner.com/2011/10/screencast-spket-setting-up-eclipse-ide-for-ext-js-4-development/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		<feedburner:origLink>http://loianegroner.com/2011/10/screencast-spket-setting-up-eclipse-ide-for-ext-js-4-development/</feedburner:origLink></item>
		<item>
		<title>ExtJS 4: How to add Tooltip to Grid Header</title>
		<link>http://feedproxy.google.com/~r/LoianeGroner/~3/iLwt9ifDXl0/</link>
		<comments>http://loianegroner.com/2011/10/extjs-4-how-to-add-tooltip-to-grid-header/#comments</comments>
		<pubDate>Tue, 04 Oct 2011 09:00:05 +0000</pubDate>
		<dc:creator>Loiane</dc:creator>
				<category><![CDATA[Ext JS 4]]></category>
		<category><![CDATA[ExtJS]]></category>
		<category><![CDATA[ExtJS 4]]></category>
		<category><![CDATA[ExtJS Grid]]></category>
		<category><![CDATA[Grid Header Tooltip]]></category>

		<guid isPermaLink="false">http://loianegroner.com/?p=1184</guid>
		<description><![CDATA[This tutorial will walk through out how to add a tooltip to a Grid Header. This feature is not natively supported by Ext JS 4 API. Fortunately,  there is a third-party plugin we can use to do it. To get started, I created a JavaScript project on Eclipse IDE and it looks like this: Plugin Code The first [...]]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop Automatic --><!-- End Shareaholic LikeButtonSetTop Automatic --><p style="text-align: justify;">This tutorial will walk through out how to add a tooltip to a Grid Header. This feature is not natively supported by Ext JS 4 API. Fortunately,  there is a third-party plugin we can use to do it.</p>
<p style="text-align: justify;">To get started, I created a JavaScript project on <a href="http://eclipse.org/" target="_blank">Eclipse IDE</a> and it looks like this:</p>
<p style="text-align: justify;"><a href="http://loianegroner.com/wp-content/uploads/2011/08/extjs4-grid-header-tooltip-loiane-01.png"><img class="aligncenter size-full wp-image-1190" title="extjs4-grid-header-tooltip-loiane-01" src="http://loianegroner.com/wp-content/uploads/2011/08/extjs4-grid-header-tooltip-loiane-01.png" alt="" width="244" height="190" /></a></p>
<h3 style="text-align: justify;">Plugin Code</h3>
<p style="text-align: justify;">The first thing we have to add (after Ext JS 4 SDK) is the plugin. To do so, I created a folder ux (for plugins) and a folder called grid (inside ux) because it is a plugin for Ext 4 grid. Then I created a file name HeaderToolTip.js with the following content:</p>
<pre class="brush: jscript; collapse: false; first-line: 1; title: ; toolbar: true; wrap-lines: false; notranslate">
/**
 * @class Ext.ux.grid.HeaderToolTip
 * @namespace ux.grid
 *
 *  Text tooltips should be stored in the grid column definition
 *
 *  Sencha forum url:
 *  http://www.sencha.com/forum/showthread.php?132637-Ext.ux.grid.HeaderToolTip
 */
Ext.define('Ext.ux.grid.HeaderToolTip', {
    alias: 'plugin.headertooltip',
    init : function(grid) {
        var headerCt = grid.headerCt;
        grid.headerCt.on(&quot;afterrender&quot;, function(g) {
            grid.tip = Ext.create('Ext.tip.ToolTip', {
                target: headerCt.el,
                delegate: &quot;.x-column-header&quot;,
                trackMouse: true,
                renderTo: Ext.getBody(),
                listeners: {
                    beforeshow: function(tip) {
                        var c = headerCt.down('gridcolumn[id=' + tip.triggerElement.id  +']');
                        if (c  &amp;&amp; c.tooltip)
                            tip.update(c.tooltip);
                        else
                            return false;
                    }
                }
            });
        });
    }
});
</pre>
<h3 style="text-align: justify;">Grid with Header Tooltip</h3>
<p style="text-align: justify;">Now we need to build the application code. To test, simply create a data grid:</p>
<pre class="brush: jscript; collapse: false; first-line: 1; highlight: [1,3,4,5,6,7,35,42]; title: ; toolbar: true; wrap-lines: false; notranslate">
Ext.Loader.setConfig({enabled: true});

Ext.require([
    'Ext.grid.*',
    'Ext.data.*',
    'Ext.ux.grid.HeaderToolTip'
]);

Ext.onReady(function() {

    var myData = [
        ['3m Co'],
        ['Alcoa Inc'],
        ['Altria Group Inc'],
        ['American Express Company'],
        ['American International Group, Inc.'],
        ['AT&amp;T Inc.'],
        ['Boeing Co.'],
        ['Caterpillar Inc.'],
        ['Citigroup, Inc.'],
        ['E.I. du Pont de Nemours and Company'],
        ['Exxon Mobil Corp'],
        ['General Electric Company']
    ];

    var store = Ext.create('Ext.data.ArrayStore', {
        fields: [
           {name: 'company'}
        ],
        data: myData
    });

    Ext.create('Ext.grid.Panel', {
        store: store,
        plugins: ['headertooltip'],
        columns: [
            {
                text     : 'Company',
                flex     : 1,
                sortable : false,
                dataIndex: 'company',
                tooltip: 'Some tooltip'
            }
        ],
        height: 200,
        width: 200,
        title: 'Grid with Header Tooltip',
        renderTo: 'grid-example',
        viewConfig: {
            stripeRows: true
        }
    });
});
</pre>
<p style="text-align: justify;">On line 1, we have to enable the Ext.Loader so Ext can dynamic loading the files we need.</p>
<p style="text-align: justify;">On lines 3-7 we declared the components we need to have loaded before loading our application. Note the Ext.ux.grid.HeaderTooltip.js is included as well. This way, Ext JS knows it has to look for a file called HeaderTooltip.js inside the folder ux/grid.</p>
<p style="text-align: justify;">Then on line 35 we have to include the HeaderTooltip plugin as a plugin of the grid we want to display a header tooltip.</p>
<p style="text-align: justify;">And finally, on line 42 we need to declared a column config called <em>tooltip</em> with the header tooltip we want to display.</p>
<h3 style="text-align: justify;">HTML Page</h3>
<p style="text-align: justify;">Then we can create an HTML file we can run on a browser:</p>
<pre class="brush: xml; collapse: false; first-line: 1; title: ; toolbar: true; wrap-lines: false; notranslate">
&lt;html&gt;
&lt;head&gt;
    &lt;title&gt;Grid with Header Tooltip&lt;/title&gt;

    &lt;link rel=&quot;stylesheet&quot; type=&quot;text/css&quot; href=&quot;ext4/resources/css/ext-all.css&quot; /&gt;
    &lt;script type=&quot;text/javascript&quot; src=&quot;ext4/ext-all.js&quot;&gt;&lt;/script&gt;

    &lt;script type=&quot;text/javascript&quot; src=&quot;app.js&quot;&gt;&lt;/script&gt;
&lt;/head&gt;
&lt;body&gt;
    &lt;div id=&quot;grid-example&quot; style=&quot;padding:20px;&quot;&gt;&lt;/div&gt;
&lt;/body&gt;
&lt;/html&gt;
</pre>
<p style="text-align: justify;">And when we execute the application, we will get the following:</p>
<p style="text-align: justify;"><a href="http://loianegroner.com/wp-content/uploads/2011/08/extjs4-grid-header-tooltip-loiane-02.png"><img class="aligncenter size-full wp-image-1191" title="extjs4-grid-header-tooltip-loiane-02" src="http://loianegroner.com/wp-content/uploads/2011/08/extjs4-grid-header-tooltip-loiane-02.png" alt="" width="514" height="424" /></a></p>
<p style="text-align: justify;">And it is done!</p>
<blockquote><p><em><strong>Disclaimer</strong>: I am not the author of this HeaderTooltip plugin. So if you get any errors, please contact the author of the plugin on Sencha Forum: <a href="http://www.sencha.com/forum/showthread.php?132637-Ext.ux.grid.HeaderToolTip" target="_blank">http://www.sencha.com/forum/showthread.php?132637-Ext.ux.grid.HeaderToolTip</a>. I simply demonstrated how to use the plugin on this tutorial.</em></p></blockquote>
<p style="text-align: justify;">I&#8217;m using Ext JS 4.0.2a (open source version) on this project.</p>
<h3 style="text-align: justify;">Download the Source Code:</h3>
<p style="text-align: justify;">You can download the source code from:</p>
<p style="text-align: justify;"><strong>My github:</strong> <a href="https://github.com/loiane/extjs4-grid-header-tooltip" target="_blank">https://github.com/loiane/extjs4-grid-header-tooltip</a></p>
<p style="text-align: justify;">Happy Coding! <img src='http://loianegroner.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<div class="shr-publisher-1184"></div><!-- Start Shareaholic LikeButtonSetBottom Automatic --><!-- End Shareaholic LikeButtonSetBottom Automatic --><img src="http://loianegroner.com/?ak_action=api_record_view&id=1184&type=feed" alt="" /><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/LoianeGroner?a=iLwt9ifDXl0:o8os1ZX8Rro:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/LoianeGroner?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/LoianeGroner?a=iLwt9ifDXl0:o8os1ZX8Rro:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/LoianeGroner?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/LoianeGroner?a=iLwt9ifDXl0:o8os1ZX8Rro:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/LoianeGroner?i=iLwt9ifDXl0:o8os1ZX8Rro:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/LoianeGroner?a=iLwt9ifDXl0:o8os1ZX8Rro:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/LoianeGroner?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/LoianeGroner?a=iLwt9ifDXl0:o8os1ZX8Rro:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/LoianeGroner?i=iLwt9ifDXl0:o8os1ZX8Rro:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/LoianeGroner?a=iLwt9ifDXl0:o8os1ZX8Rro:I9og5sOYxJI"><img src="http://feeds.feedburner.com/~ff/LoianeGroner?d=I9og5sOYxJI" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/LoianeGroner/~4/iLwt9ifDXl0" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://loianegroner.com/2011/10/extjs-4-how-to-add-tooltip-to-grid-header/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		<feedburner:origLink>http://loianegroner.com/2011/10/extjs-4-how-to-add-tooltip-to-grid-header/</feedburner:origLink></item>
		<item>
		<title>ExtJS 4 Plugin: PagingToolbarResizer</title>
		<link>http://feedproxy.google.com/~r/LoianeGroner/~3/6vL-5Ry3E90/</link>
		<comments>http://loianegroner.com/2011/09/extjs-4-plugin-pagingtoolbarresizer/#comments</comments>
		<pubDate>Mon, 26 Sep 2011 09:00:34 +0000</pubDate>
		<dc:creator>Loiane</dc:creator>
				<category><![CDATA[Ext JS 4]]></category>
		<category><![CDATA[ExtJS 4]]></category>
		<category><![CDATA[ExtJS 4 Plugin]]></category>
		<category><![CDATA[PagingToolbarResizer]]></category>

		<guid isPermaLink="false">http://loianegroner.com/?p=1219</guid>
		<description><![CDATA[For Ext JS 3, I implemented a plugin called PagingToolbarResizer. However, ExtJS 4 introduced some changes on the API and the plugin does not work for this new version, so I ported it to Ext JS 4. Download The complete source code with a complete example of how to use it you can find in my [...]]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop Automatic --><!-- End Shareaholic LikeButtonSetTop Automatic --><p><a title="ExtJS plugin: PagingToolbarResizer" href="http://loianegroner.com/2010/08/extjs-plugin-pagingtoolbarresizer/" target="_blank">For Ext JS 3, I implemented a plugin called PagingToolbarResizer</a>. However, ExtJS 4 introduced some changes on the API and the plugin does not work for this new version, so I ported it to Ext JS 4.</p>
<h3>Download</h3>
<p>The complete source code with a complete example of how to use it you can find in my github account: <a href="https://github.com/loiane/extjs4-ux-paging-toolbar-resizer" target="_blank">https://github.com/loiane/extjs4-ux-paging-toolbar-resizer</a></p>
<h3>Demo</h3>
<p>Working demo: <a href="http://loianegroner.com/extjs/examples/extjs4-ux-paging-toolbar-resizer/">http://loianegroner.com/extjs/examples/extjs4-ux-paging-toolbar-resizer/</a></p>
<h3>How to use it</h3>
<p>To use it, is is very simple. Simply place the <em><strong>ux</strong></em> folder in your project and call the plugin like the following:</p>
<pre class="brush: jscript; collapse: false; first-line: 1; highlight: [16]; title: ; toolbar: true; wrap-lines: false; notranslate">
bbar: Ext.create('Ext.PagingToolbar', {
    store: store,
    displayInfo: true,
    displayMsg: 'Displaying topics {0} - {1} of {2}',
    emptyMsg: &quot;No topics to display&quot;,
    items:[
		'-', {
		text: 'Show Preview',
		pressed: pluginExpanded,
		enableToggle: true,
		toggleHandler: function(btn, pressed) {
			var preview = Ext.getCmp('gv').getPlugin('preview');
			preview.toggleExpanded(pressed);
		}
    }],
    plugins : [new Ext.create('Ext.ux.PagingToolbarResizer',{options : [ 5, 10, 15, 20, 25 ]})]
})
</pre>
<p>And then you will have a combobox with some paging values available on the Ext JS Grid Paging Toolbar.</p>
<p><a href="http://loianegroner.com/wp-content/uploads/2011/09/extjs4-plugin-pagetoolbar-resizer-loiane.png" target="_blank"><img class="aligncenter size-full wp-image-1220" title="extjs4-plugin-pagetoolbar-resizer-loiane" src="http://loianegroner.com/wp-content/uploads/2011/09/extjs4-plugin-pagetoolbar-resizer-loiane.png" alt="" width="562" height="402" /></a></p>
<p>Happy coding!</p>
<div class="shr-publisher-1219"></div><!-- Start Shareaholic LikeButtonSetBottom Automatic --><!-- End Shareaholic LikeButtonSetBottom Automatic --><img src="http://loianegroner.com/?ak_action=api_record_view&id=1219&type=feed" alt="" /><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/LoianeGroner?a=6vL-5Ry3E90:tLm0mZEoT8E:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/LoianeGroner?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/LoianeGroner?a=6vL-5Ry3E90:tLm0mZEoT8E:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/LoianeGroner?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/LoianeGroner?a=6vL-5Ry3E90:tLm0mZEoT8E:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/LoianeGroner?i=6vL-5Ry3E90:tLm0mZEoT8E:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/LoianeGroner?a=6vL-5Ry3E90:tLm0mZEoT8E:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/LoianeGroner?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/LoianeGroner?a=6vL-5Ry3E90:tLm0mZEoT8E:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/LoianeGroner?i=6vL-5Ry3E90:tLm0mZEoT8E:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/LoianeGroner?a=6vL-5Ry3E90:tLm0mZEoT8E:I9og5sOYxJI"><img src="http://feeds.feedburner.com/~ff/LoianeGroner?d=I9og5sOYxJI" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/LoianeGroner/~4/6vL-5Ry3E90" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://loianegroner.com/2011/09/extjs-4-plugin-pagingtoolbarresizer/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		<feedburner:origLink>http://loianegroner.com/2011/09/extjs-4-plugin-pagingtoolbarresizer/</feedburner:origLink></item>
		<item>
		<title>ExtJS 4 x ExtJS 3 Class Names</title>
		<link>http://feedproxy.google.com/~r/LoianeGroner/~3/0EWU2UBX_WI/</link>
		<comments>http://loianegroner.com/2011/09/extjs-4-x-extjs-3-class-names/#comments</comments>
		<pubDate>Wed, 21 Sep 2011 09:00:12 +0000</pubDate>
		<dc:creator>Loiane</dc:creator>
				<category><![CDATA[Ext JS 4]]></category>
		<category><![CDATA[ExtJS]]></category>
		<category><![CDATA[Ext JS 3]]></category>
		<category><![CDATA[ExtJS 3]]></category>
		<category><![CDATA[ExtJS 4]]></category>
		<category><![CDATA[ExtJS 4 x ExtJS 3]]></category>

		<guid isPermaLink="false">http://loianegroner.com/?p=1212</guid>
		<description><![CDATA[Ext JS 4 reorganized the API packages names and as a consequence, some classes has a new class name now. The Ext JS 3 class names are still valid in Ext JS 4, but when we are migrating an app from Ext JS 3 to Ext JS 4, it is recommended to change the class [...]]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop Automatic --><!-- End Shareaholic LikeButtonSetTop Automatic --><p><strong>Ext JS 4</strong> reorganized the API packages names and as a consequence, some classes has a new class name now. The <strong>Ext JS 3</strong> class names are still valid in <strong>Ext JS 4</strong>, but when we are <strong>migrating</strong> an app from <strong>Ext JS 3</strong> to <strong>Ext JS 4</strong>, it is recommended to change the class name as well.</p>
<p><a href="http://loianegroner.com/wp-content/uploads/2011/09/extjs4xextjs3_classnames_loiane.png"><img class="aligncenter size-full wp-image-1213" title="extjs4xextjs3_classnames_loiane" src="http://loianegroner.com/wp-content/uploads/2011/09/extjs4xextjs3_classnames_loiane.png" alt="" width="592" height="351" /></a></p>
<p>That being said, I created a simple application where you can quickly search for a <strong>Ext JS 3</strong> class name and find its correspondent <strong>Ext JS 4</strong> class name. <em>This application contains only the classes which name <em>have </em> changed</em>.</p>
<p>I hope this can help someone.</p>
<p>And I am open for suggestions to improve this app.</p>
<p>Link: <a href="http://loianegroner.com/extjs/examples/ext4-ext3-class-names/" target="_blank">http://loianegroner.com/extjs/examples/ext4-ext3-class-names/</a></p>
<p>Happy coding!</p>
<div class="shr-publisher-1212"></div><!-- Start Shareaholic LikeButtonSetBottom Automatic --><!-- End Shareaholic LikeButtonSetBottom Automatic --><img src="http://loianegroner.com/?ak_action=api_record_view&id=1212&type=feed" alt="" /><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/LoianeGroner?a=0EWU2UBX_WI:WmFjK4XRJNY:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/LoianeGroner?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/LoianeGroner?a=0EWU2UBX_WI:WmFjK4XRJNY:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/LoianeGroner?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/LoianeGroner?a=0EWU2UBX_WI:WmFjK4XRJNY:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/LoianeGroner?i=0EWU2UBX_WI:WmFjK4XRJNY:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/LoianeGroner?a=0EWU2UBX_WI:WmFjK4XRJNY:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/LoianeGroner?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/LoianeGroner?a=0EWU2UBX_WI:WmFjK4XRJNY:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/LoianeGroner?i=0EWU2UBX_WI:WmFjK4XRJNY:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/LoianeGroner?a=0EWU2UBX_WI:WmFjK4XRJNY:I9og5sOYxJI"><img src="http://feeds.feedburner.com/~ff/LoianeGroner?d=I9og5sOYxJI" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/LoianeGroner/~4/0EWU2UBX_WI" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://loianegroner.com/2011/09/extjs-4-x-extjs-3-class-names/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		<feedburner:origLink>http://loianegroner.com/2011/09/extjs-4-x-extjs-3-class-names/</feedburner:origLink></item>
		<item>
		<title>ExtJS 4: Grid Printer Plugin</title>
		<link>http://feedproxy.google.com/~r/LoianeGroner/~3/yYyymJz3buE/</link>
		<comments>http://loianegroner.com/2011/09/extjs-4-grid-printer-plugin/#comments</comments>
		<pubDate>Wed, 07 Sep 2011 09:00:27 +0000</pubDate>
		<dc:creator>Loiane</dc:creator>
				<category><![CDATA[Ext JS 4]]></category>
		<category><![CDATA[Ext JS]]></category>
		<category><![CDATA[ExtJS]]></category>
		<category><![CDATA[ExtJS 4]]></category>
		<category><![CDATA[ExtJS Grid]]></category>
		<category><![CDATA[ExtJS Plugin]]></category>
		<category><![CDATA[grid printer]]></category>
		<category><![CDATA[grid printer plugin]]></category>
		<category><![CDATA[print button]]></category>

		<guid isPermaLink="false">http://loianegroner.com/?p=1199</guid>
		<description><![CDATA[Ed Spencer created a plugin that is capable of creating a print version of an ExtJS grid. This plugin was originally created for ExtJS 3.x. I ported it to ExtJS 4, in case someone need it. The plugin can be downloaded on the following link: https://github.com/loiane/extjs4-ux-gridprinter/archives/master The zip file contains the source code of the plugin [...]]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop Automatic --><!-- End Shareaholic LikeButtonSetTop Automatic --><p style="text-align: justify;"><a href="http://edspencer.net/2009/07/printing-grids-with-ext-js.html" target="_blank">Ed Spencer created a plugin that is capable of creating a print version of an ExtJS grid</a>. This plugin was originally created for ExtJS 3.x. I ported it to ExtJS 4, in case someone need it.</p>
<p style="text-align: justify;">The plugin can be downloaded on the following link: <a href="https://github.com/loiane/extjs4-ux-gridprinter/archives/master" target="_blank">https://github.com/loiane/extjs4-ux-gridprinter/archives/master</a></p>
<p style="text-align: justify;">The zip file contains the source code of the plugin plus an example of how to use it. To run the example page, simply open it on any browser (you will need an internet connection).</p>
<p style="text-align: justify;">To use the plugin in your project, copy the <em><strong>ux</strong></em> folder and paste it on your project, as the following sample project I created:</p>
<p style="text-align: justify;"><a href="http://loianegroner.com/wp-content/uploads/2011/09/extjs4-ux-gridprinter-loiane-03.png"><img class="aligncenter size-full wp-image-1204" title="extjs4-ux-gridprinter-loiane-03" src="http://loianegroner.com/wp-content/uploads/2011/09/extjs4-ux-gridprinter-loiane-03.png" alt="" width="566" height="403" /></a><span class="Apple-style-span" style="font-size: 15px; font-weight: bold;">Plugin Code:</span></p>
<pre class="brush: jscript; collapse: false; first-line: 1; title: ; toolbar: true; wrap-lines: false; notranslate">
/**
 * @class Ext.ux.grid.Printer
 * @author Ed Spencer (edward@domine.co.uk)
 * Helper class to easily print the contents of a grid. Will open a new window with a table where the first row
 * contains the headings from your column model, and with a row for each item in your grid's store. When formatted
 * with appropriate CSS it should look very similar to a default grid. If renderers are specified in your column
 * model, they will be used in creating the table. Override headerTpl and bodyTpl to change how the markup is generated
 *
 * Usage:
 *
 * 1 - Add Ext.Require Before the Grid code
 * Ext.require([
 *   'Ext.ux.grid.GridPrinter',
 * ]);
 *
 * 2 - Declare the Grid
 * var grid = Ext.create('Ext.grid.Panel', {
 *   columns: //some column model,
 *   store   : //some store
 * });
 *
 * 3 - Print!
 * Ext.ux.grid.Printer.print(grid);
 *
 * Original url: http://edspencer.net/2009/07/printing-grids-with-ext-js.html
 *
 * Modified by Loiane Groner (me@loiane.com) - September 2011 - Ported to Ext JS 4
 * http://loianegroner.com (English)
 * http://loiane.com (Portuguese)
 */
Ext.define(&quot;Ext.ux.grid.Printer&quot;, {

	requires: 'Ext.XTemplate',

	statics: {
		/**
		 * Prints the passed grid. Reflects on the grid's column model to build a table, and fills it using the store
		 * @param {Ext.grid.Panel} grid The grid to print
		 */
		print: function(grid) {
			//We generate an XTemplate here by using 2 intermediary XTemplates - one to create the header,
			//the other to create the body (see the escaped {} below)
			var columns = grid.columns;

			//build a useable array of store data for the XTemplate
			var data = [];
			grid.store.data.each(function(item) {
				var convertedData = [];

				//apply renderers from column model
				for (var key in item.data) {
					var value = item.data[key];

					Ext.each(columns, function(column) {
						if (column.dataIndex == key) {
							convertedData[key] = column.renderer ? column.renderer(value) : value;
						}
					}, this);
				}

				data.push(convertedData);
			});

			//use the headerTpl and bodyTpl markups to create the main XTemplate below
			var headings = Ext.create('Ext.XTemplate', this.headerTpl).apply(columns);
			var body     = Ext.create('Ext.XTemplate', this.bodyTpl).apply(columns);

			var htmlMarkup = [
				'&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;&gt;',
				'&lt;html&gt;',
				  '&lt;head&gt;',
				    '&lt;meta content=&quot;text/html; charset=UTF-8&quot; http-equiv=&quot;Content-Type&quot; /&gt;',
				    '&lt;link href=&quot;' + this.stylesheetPath + '&quot; rel=&quot;stylesheet&quot; type=&quot;text/css&quot; media=&quot;screen,print&quot; /&gt;',
				    '&lt;title&gt;' + grid.title + '&lt;/title&gt;',
				  '&lt;/head&gt;',
				  '&lt;body&gt;',
				    '&lt;table&gt;',
				      headings,
				      '&lt;tpl for=&quot;.&quot;&gt;',
				        body,
				      '&lt;/tpl&gt;',
				    '&lt;/table&gt;',
				  '&lt;/body&gt;',
				'&lt;/html&gt;'
			];

			var html = Ext.create('Ext.XTemplate', htmlMarkup).apply(data); 

			//open up a new printing window, write to it, print it and close
			var win = window.open('', 'printgrid');

			win.document.write(html);

			if (this.printAutomatically){
				win.print();
				win.close();
			}
		},

		/**
		 * @property stylesheetPath
		 * @type String
		 * The path at which the print stylesheet can be found (defaults to 'ux/grid/gridPrinterCss/print.css')
		 */
		stylesheetPath: 'ux/grid/gridPrinterCss/print.css',

		/**
		 * @property printAutomatically
		 * @type Boolean
		 * True to open the print dialog automatically and close the window after printing. False to simply open the print version
		 * of the grid (defaults to true)
		 */
		printAutomatically: true,

		/**
		 * @property headerTpl
		 * @type {Object/Array} values
		 * The markup used to create the headings row. By default this just uses &lt;th&gt; elements, override to provide your own
		 */
		headerTpl: [
			'&lt;tr&gt;',
				'&lt;tpl for=&quot;.&quot;&gt;',
					'&lt;th&gt;{text}&lt;/th&gt;',
				'&lt;/tpl&gt;',
			'&lt;/tr&gt;'
		],

		/**
		 * @property bodyTpl
		 * @type {Object/Array} values
		 * The XTemplate used to create each row. This is used inside the 'print' function to build another XTemplate, to which the data
		 * are then applied (see the escaped dataIndex attribute here - this ends up as &quot;{dataIndex}&quot;)
		 */
		bodyTpl: [
			'&lt;tr&gt;',
				'&lt;tpl for=&quot;.&quot;&gt;',
					'&lt;td&gt;\{{dataIndex}\}&lt;/td&gt;',
				'&lt;/tpl&gt;',
			'&lt;/tr&gt;'
		]
	}
});
</pre>
<h3 style="text-align: justify;">Usage:</h3>
<p style="text-align: justify;">To use the plugin you can create a button and in the handler function you can call the static function of the plugin (you need to pass a grid instance as argument to the print function).</p>
<pre class="brush: jscript; collapse: false; first-line: 1; highlight: [131,132]; title: ; toolbar: true; wrap-lines: false; notranslate">
Ext.Loader.setConfig({enabled: true});

Ext.require([
    'Ext.grid.*',
    'Ext.data.*',
    'Ext.ux.grid.Printer',
]);

Ext.onReady(function() {

    // sample static data for the store
    var myData = [
        ['3m Co',                               71.72, 0.02,  0.03,  '9/1 12:00am'],
        ['Alcoa Inc',                           29.01, 0.42,  1.47,  '9/1 12:00am'],
        ['Altria Group Inc',                    83.81, 0.28,  0.34,  '9/1 12:00am'],
        ['American Express Company',            52.55, 0.01,  0.02,  '9/1 12:00am'],
        ['American International Group, Inc.',  64.13, 0.31,  0.49,  '9/1 12:00am'],
        ['AT&amp;T Inc.',                           31.61, -0.48, -1.54, '9/1 12:00am'],
        ['Boeing Co.',                          75.43, 0.53,  0.71,  '9/1 12:00am'],
        ['Caterpillar Inc.',                    67.27, 0.92,  1.39,  '9/1 12:00am'],
        ['Citigroup, Inc.',                     49.37, 0.02,  0.04,  '9/1 12:00am'],
        ['E.I. du Pont de Nemours and Company', 40.48, 0.51,  1.28,  '9/1 12:00am'],
        ['Exxon Mobil Corp',                    68.1,  -0.43, -0.64, '9/1 12:00am'],
        ['General Electric Company',            34.14, -0.08, -0.23, '9/1 12:00am'],
        ['General Motors Corporation',          30.27, 1.09,  3.74,  '9/1 12:00am'],
        ['Hewlett-Packard Co.',                 36.53, -0.03, -0.08, '9/1 12:00am'],
        ['Honeywell Intl Inc',                  38.77, 0.05,  0.13,  '9/1 12:00am'],
        ['Intel Corporation',                   19.88, 0.31,  1.58,  '9/1 12:00am'],
        ['International Business Machines',     81.41, 0.44,  0.54,  '9/1 12:00am'],
        ['Johnson &amp; Johnson',                   64.72, 0.06,  0.09,  '9/1 12:00am'],
        ['JP Morgan &amp; Chase &amp; Co',              45.73, 0.07,  0.15,  '9/1 12:00am'],
        ['McDonalds Corporation',               36.76, 0.86,  2.40,  '9/1 12:00am'],
        ['Merck &amp; Co., Inc.',                   40.96, 0.41,  1.01,  '9/1 12:00am'],
        ['Microsoft Corporation',               25.84, 0.14,  0.54,  '9/1 12:00am'],
        ['Pfizer Inc',                          27.96, 0.4,   1.45,  '9/1 12:00am'],
        ['The Coca-Cola Company',               45.07, 0.26,  0.58,  '9/1 12:00am'],
        ['The Home Depot, Inc.',                34.64, 0.35,  1.02,  '9/1 12:00am'],
        ['The Procter &amp; Gamble Company',        61.91, 0.01,  0.02,  '9/1 12:00am'],
        ['United Technologies Corporation',     63.26, 0.55,  0.88,  '9/1 12:00am'],
        ['Verizon Communications',              35.57, 0.39,  1.11,  '9/1 12:00am'],
        ['Wal-Mart Stores, Inc.',               45.45, 0.73,  1.63,  '9/1 12:00am']
    ];

    /**
     * Custom function used for column renderer
     * @param {Object} val
     */
    function change(val) {
        if (val &gt; 0) {
            return '&lt;span style=&quot;color:green;&quot;&gt;' + val + '&lt;/span&gt;';
        } else if (val &lt; 0) {
            return '&lt;span style=&quot;color:red;&quot;&gt;' + val + '&lt;/span&gt;';
        }
        return val;
    }

    /**
     * Custom function used for column renderer
     * @param {Object} val
     */
    function pctChange(val) {
        if (val &gt; 0) {
            return '&lt;span style=&quot;color:green;&quot;&gt;' + val + '%&lt;/span&gt;';
        } else if (val &lt; 0) {
            return '&lt;span style=&quot;color:red;&quot;&gt;' + val + '%&lt;/span&gt;';
        }
        return val;
    }

    // create the data store
    var store = Ext.create('Ext.data.ArrayStore', {
        fields: [
           {name: 'company'},
           {name: 'price',      type: 'float'},
           {name: 'change',     type: 'float'},
           {name: 'pctChange',  type: 'float'},
           {name: 'lastChange', type: 'date', dateFormat: 'n/j h:ia'}
        ],
        data: myData
    });

    // create the Grid
    var grid = Ext.create('Ext.grid.Panel', {
        store: store,
        stateful: true,
        stateId: 'stateGrid',
        columns: [
            {
                text     : 'Company',
                flex     : 1,
                sortable : false,
                dataIndex: 'company'
            },
            {
                text     : 'Price',
                width    : 75,
                sortable : true,
                renderer : 'usMoney',
                dataIndex: 'price'
            },
            {
                text     : 'Change',
                width    : 75,
                sortable : true,
                renderer : change,
                dataIndex: 'change'
            },
            {
                text     : '% Change',
                width    : 75,
                sortable : true,
                renderer : pctChange,
                dataIndex: 'pctChange'
            },
            {
                text     : 'Last Updated',
                width    : 85,
                sortable : true,
                renderer : Ext.util.Format.dateRenderer('m/d/Y'),
                dataIndex: 'lastChange'
            }
        ],
        height: 350,
        width: 600,
        title: 'Array Grid with Print Option',
        renderTo: Ext.getBody(),
        tbar: [{
            text: 'Print',
            iconCls: 'icon-print',
            handler : function(){
            	Ext.ux.grid.Printer.printAutomatically = false;
            	Ext.ux.grid.Printer.print(grid);
            }
        }]
    });
});
</pre>
<p style="text-align: justify;">There are some options you can customize, such as the stylesheet path and the printAutomatically.</p>
<p style="text-align: justify;">And when we execute the code above, we will get a grid with a print button like the following:</p>
<p style="text-align: center;"><a href="http://loianegroner.com/wp-content/uploads/2011/09/extjs4-ux-gridprinter-loiane-01.png" target="_blank"><img class="aligncenter size-full wp-image-1202" title="extjs4-ux-gridprinter-loiane-01" src="http://loianegroner.com/wp-content/uploads/2011/09/extjs4-ux-gridprinter-loiane-01.png" alt="" width="529" height="416" /></a></p>
<p style="text-align: justify;">And when we click on the Print button, a new page will be opened with the following content:</p>
<p style="text-align: center;"><a href="http://loianegroner.com/wp-content/uploads/2011/09/extjs4-ux-gridprinter-loiane-02.png" target="_blank"><img class="aligncenter size-full wp-image-1203" title="extjs4-ux-gridprinter-loiane-02" src="http://loianegroner.com/wp-content/uploads/2011/09/extjs4-ux-gridprinter-loiane-02.png" alt="" width="529" height="416" /></a></p>
<h3 style="text-align: justify;">Demo</h3>
<p style="text-align: justify;">Demo: <a href="http://loianegroner.com/extjs/examples/extjs4-ux-gridprinter/" target="_blank">http://loianegroner.com/extjs/examples/extjs4-ux-gridprinter/</a></p>
<p style="text-align: justify;">Github repository: <a href="https://github.com/loiane/extjs4-ux-gridprinter" target="_blank">https://github.com/loiane/extjs4-ux-gridprinter</a></p>
<p style="text-align: justify;">The original plugin (ExtJS 3.x) &#8211; by Ed Spencer:  <a href="http://edspencer.net/2009/07/printing-grids-with-ext-js.html">http://edspencer.net/2009/07/printing-grids-with-ext-js.html</a></p>
<p style="text-align: justify;">Happy Coding! <img src='http://loianegroner.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<div class="shr-publisher-1199"></div><!-- Start Shareaholic LikeButtonSetBottom Automatic --><!-- End Shareaholic LikeButtonSetBottom Automatic --><img src="http://loianegroner.com/?ak_action=api_record_view&id=1199&type=feed" alt="" /><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/LoianeGroner?a=yYyymJz3buE:oMTPYSysHqg:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/LoianeGroner?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/LoianeGroner?a=yYyymJz3buE:oMTPYSysHqg:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/LoianeGroner?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/LoianeGroner?a=yYyymJz3buE:oMTPYSysHqg:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/LoianeGroner?i=yYyymJz3buE:oMTPYSysHqg:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/LoianeGroner?a=yYyymJz3buE:oMTPYSysHqg:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/LoianeGroner?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/LoianeGroner?a=yYyymJz3buE:oMTPYSysHqg:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/LoianeGroner?i=yYyymJz3buE:oMTPYSysHqg:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/LoianeGroner?a=yYyymJz3buE:oMTPYSysHqg:I9og5sOYxJI"><img src="http://feeds.feedburner.com/~ff/LoianeGroner?d=I9og5sOYxJI" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/LoianeGroner/~4/yYyymJz3buE" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://loianegroner.com/2011/09/extjs-4-grid-printer-plugin/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		<feedburner:origLink>http://loianegroner.com/2011/09/extjs-4-grid-printer-plugin/</feedburner:origLink></item>
		<item>
		<title>Ext Designer User’s Guide for ExtJS 3 and ExtJS 4</title>
		<link>http://feedproxy.google.com/~r/LoianeGroner/~3/0zZJnZLmRi0/</link>
		<comments>http://loianegroner.com/2011/08/ext-designer-user%e2%80%99s-guide-for-extjs-3-and-extjs-4/#comments</comments>
		<pubDate>Thu, 18 Aug 2011 11:50:55 +0000</pubDate>
		<dc:creator>Loiane</dc:creator>
				<category><![CDATA[Ext JS 4]]></category>
		<category><![CDATA[ExtJS]]></category>
		<category><![CDATA[Ext Designer]]></category>
		<category><![CDATA[ExtJS 3]]></category>
		<category><![CDATA[ExtJS 4]]></category>
		<category><![CDATA[Sencha]]></category>

		<guid isPermaLink="false">http://loianegroner.com/?p=1175</guid>
		<description><![CDATA[Sencha published on the Learning Center two User&#8217;s Guides about Ext Designer. The first one is about how to use Ext Designer with Ext JS 3: http://www.sencha.com/learn/ext-designer-for-ext-js-3-users-guide/ And the second one is about how to use Ext Designer with Ext JS 4: http://www.sencha.com/learn/ext-designer-for-ext-js-4-users-guide/ Both user&#8217;s guides are in PDF format and you can download them [...]]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop Automatic --><!-- End Shareaholic LikeButtonSetTop Automatic --><p style="text-align: justify;"><a href="http://www.sencha.com" target="_blank">Sencha </a>published on the <a href="http://www.sencha.com/learn" target="_blank">Learning Center</a> two User&#8217;s Guides about <a href="http://www.sencha.com/products/designer/" target="_blank">Ext Designer</a>.</p>
<p style="text-align: justify;"><img class="aligncenter size-full wp-image-1178" title="extdesigner" src="http://loianegroner.com/wp-content/uploads/2011/08/extdesigner.png" alt="" width="336" height="205" /></p>
<p style="text-align: justify;">The first one is about how to use Ext Designer with Ext JS 3:</p>
<p style="text-align: justify;"><a href="http://www.sencha.com/learn/ext-designer-for-ext-js-3-users-guide/" target="_blank">http://www.sencha.com/learn/ext-designer-for-ext-js-3-users-guide/</a></p>
<p style="text-align: justify;">And the second one is about how to use Ext Designer with Ext JS 4:</p>
<p style="text-align: justify;"><a href="http://www.sencha.com/learn/ext-designer-for-ext-js-4-users-guide/" target="_blank">http://www.sencha.com/learn/ext-designer-for-ext-js-4-users-guide/</a></p>
<p style="text-align: justify;">Both user&#8217;s guides are in PDF format and you can download them on the links above.</p>
<p style="text-align: justify;">Happy Coding!</p>
<p style="text-align: justify;">
<div class="shr-publisher-1175"></div><!-- Start Shareaholic LikeButtonSetBottom Automatic --><!-- End Shareaholic LikeButtonSetBottom Automatic --><img src="http://loianegroner.com/?ak_action=api_record_view&id=1175&type=feed" alt="" /><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/LoianeGroner?a=0zZJnZLmRi0:IpsLtxAQsFc:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/LoianeGroner?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/LoianeGroner?a=0zZJnZLmRi0:IpsLtxAQsFc:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/LoianeGroner?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/LoianeGroner?a=0zZJnZLmRi0:IpsLtxAQsFc:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/LoianeGroner?i=0zZJnZLmRi0:IpsLtxAQsFc:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/LoianeGroner?a=0zZJnZLmRi0:IpsLtxAQsFc:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/LoianeGroner?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/LoianeGroner?a=0zZJnZLmRi0:IpsLtxAQsFc:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/LoianeGroner?i=0zZJnZLmRi0:IpsLtxAQsFc:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/LoianeGroner?a=0zZJnZLmRi0:IpsLtxAQsFc:I9og5sOYxJI"><img src="http://feeds.feedburner.com/~ff/LoianeGroner?d=I9og5sOYxJI" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/LoianeGroner/~4/0zZJnZLmRi0" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://loianegroner.com/2011/08/ext-designer-user%e2%80%99s-guide-for-extjs-3-and-extjs-4/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://loianegroner.com/2011/08/ext-designer-user%e2%80%99s-guide-for-extjs-3-and-extjs-4/</feedburner:origLink></item>
		<item>
		<title>My Book: ExtJS 4 First Look</title>
		<link>http://feedproxy.google.com/~r/LoianeGroner/~3/oOyiFB_2BCE/</link>
		<comments>http://loianegroner.com/2011/08/my-book-extjs-4-first-look/#comments</comments>
		<pubDate>Tue, 16 Aug 2011 12:24:18 +0000</pubDate>
		<dc:creator>Loiane</dc:creator>
				<category><![CDATA[Book Review]]></category>
		<category><![CDATA[Ext JS 4]]></category>
		<category><![CDATA[ExtJS]]></category>
		<category><![CDATA[Ext JS 4 book]]></category>

		<guid isPermaLink="false">http://loianegroner.com/?p=1168</guid>
		<description><![CDATA[Hi folks, I&#8217;m very happy to announce that my book: ExtJS 4 First Look is released for pre order now. The book is going to be out in November/2011. Currently is in review phase and I think they are going to release the RAW as well. I&#8217;ve been working on this book since March, when [...]]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop Automatic --><!-- End Shareaholic LikeButtonSetTop Automatic --><p style="text-align: justify;">Hi folks,</p>
<p style="text-align: justify;">I&#8217;m very happy to announce that my book: ExtJS 4 First Look is released for pre order now.</p>
<p style="text-align: justify;">The book is going to be out in November/2011. Currently is in review phase and I think they are going to release the RAW as well.</p>
<p style="text-align: justify;"><a href="http://www.packtpub.com/ext-js-4-first-look/book" target="_blank"><img class="aligncenter size-full wp-image-1169" title="6662os_ExtJS4_book_loiane" src="http://loianegroner.com/wp-content/uploads/2011/08/6662os_ExtJS4_book_loiane.jpg" alt="" width="350" height="432" /></a></p>
<p style="text-align: justify;">I&#8217;ve been working on this book since March, when Sencha released the Ext 4 preview version. If you follow me on twitter or follow the updates on my blog, you know I am in love with Ext JS.</p>
<p style="text-align: justify;">This book has been a challenge for me, first because it is a book, it is huge deal; second because it is something new on the market (ExtJS has been on the market for a few years, but there is a lot of new cool features in Ext4), so I am studying a lot all these new features and third because I wrote the book in English, which is not my first language (I&#8217;m from Brazil, so my mother language is Portuguese-Brazil) . But so far did not get any complain from the editors about English errors (which is a big Yay for me!).</p>
<p style="text-align: justify;">In my family, I&#8217;m part of the first generation that could go to college, so writing and publising a book in a foreign language is a super ultra mega huge deal, and my parents are very very proud. So is my husband, who was/is really patient through out all this process.</p>
<p style="text-align: justify;">I also would like to thank everyone for the support and ideas for the book! Thank you very much! <img src='http://loianegroner.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p style="text-align: justify;">Well, about the book: this is a book for developers who already know some Ext JS. This book highlights the new features from Ext JS 4, there are some example comparing how something was done in Ext 3 and how you should do in Ext 4. So if you do not have any knowledge about Ext JS, this is not the book for you.</p>
<p style="text-align: justify;">The book is driven by examples. So to explain something, I present an example and a screenshot of the output of the code and then I explain what the code does. It is pretty much what I usually do here on my blog, but with more details.</p>
<p style="text-align: justify;">I put so much work and love in this book and I hope you enjoy it. I can&#8217;t wait November to have a print edition on my hands! <img src='http://loianegroner.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p style="text-align: justify;">Link for the book page: <a href="http://www.packtpub.com/ext-js-4-first-look/book">http://www.packtpub.com/ext-js-4-first-look/book</a></p>
<p style="text-align: justify;">The book is also available at Amazon:</p>
<p style="text-align: justify;"><iframe style="width: 120px; height: 240px;" src="http://rcm.amazon.com/e/cm?lt1=_blank&amp;bc1=FFFFFF&amp;IS1=1&amp;bg1=FFFFFF&amp;fc1=000000&amp;lc1=0000FF&amp;t=loiagron-20&amp;o=1&amp;p=8&amp;l=as1&amp;m=amazon&amp;f=ifr&amp;ref=qf_sp_asin_til&amp;asins=1849516669" frameborder="0" marginwidth="0" marginheight="0" scrolling="no" width="320" height="240"></iframe></p>
<p style="text-align: justify;">Happy Coding!</p>
<h3 style="text-align: justify;">Update &#8211; January 2012:</h3>
<p>For all people asking me when the book is going to be available: I got in touch with someone from Packt and they said to me they had an internal problema with the release of some books, including mine. Their answer is that the book is going to be published this month (January 2012 &#8211; I do not have the exact date). I apologize to everyone that already bought the book and did not get it yet.</p>
<p>But you have to understand that I am just the author of the book, I do not control the publishing process, these things are not up to me. I am also really hoping that this book is going to be published soon.</p>
<div class="shr-publisher-1168"></div><!-- Start Shareaholic LikeButtonSetBottom Automatic --><!-- End Shareaholic LikeButtonSetBottom Automatic --><img src="http://loianegroner.com/?ak_action=api_record_view&id=1168&type=feed" alt="" /><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/LoianeGroner?a=oOyiFB_2BCE:6d_5wzgGZmE:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/LoianeGroner?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/LoianeGroner?a=oOyiFB_2BCE:6d_5wzgGZmE:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/LoianeGroner?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/LoianeGroner?a=oOyiFB_2BCE:6d_5wzgGZmE:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/LoianeGroner?i=oOyiFB_2BCE:6d_5wzgGZmE:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/LoianeGroner?a=oOyiFB_2BCE:6d_5wzgGZmE:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/LoianeGroner?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/LoianeGroner?a=oOyiFB_2BCE:6d_5wzgGZmE:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/LoianeGroner?i=oOyiFB_2BCE:6d_5wzgGZmE:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/LoianeGroner?a=oOyiFB_2BCE:6d_5wzgGZmE:I9og5sOYxJI"><img src="http://feeds.feedburner.com/~ff/LoianeGroner?d=I9og5sOYxJI" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/LoianeGroner/~4/oOyiFB_2BCE" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://loianegroner.com/2011/08/my-book-extjs-4-first-look/feed/</wfw:commentRss>
		<slash:comments>55</slash:comments>
		<feedburner:origLink>http://loianegroner.com/2011/08/my-book-extjs-4-first-look/</feedburner:origLink></item>
		<item>
		<title>How to use ExtJS 4 + JQuery together</title>
		<link>http://feedproxy.google.com/~r/LoianeGroner/~3/B0_Uj7IUgdM/</link>
		<comments>http://loianegroner.com/2011/08/how-to-use-extjs-4-jquery-together/#comments</comments>
		<pubDate>Tue, 09 Aug 2011 09:00:30 +0000</pubDate>
		<dc:creator>Loiane</dc:creator>
				<category><![CDATA[Ext JS 4]]></category>
		<category><![CDATA[ExtJS]]></category>
		<category><![CDATA[ExtJS 4]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://loianegroner.com/?p=1142</guid>
		<description><![CDATA[This is an example of how to use Ext JS 4 and JQuery in an application together. To use Ext JS 4 with any JS frameowork is very simple: you need to import the js framework file (in this case JQuery ) and import Ext JS. ANd you are ready to develop with both frameworks! [...]]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop Automatic --><!-- End Shareaholic LikeButtonSetTop Automatic --><p>This is an example of how to use <a href="http://www.sencha.com/" target="_blank">Ext JS 4</a> and <a href="http://jquery.com/" target="_blank">JQuery </a>in an application together.</p>
<p>To use <a href="http://www.sencha.com/" target="_blank">Ext JS 4</a> with any JS frameowork is very simple: you need to import the js framework file (in this case <a href="http://jquery.com/" target="_blank">JQuery </a>) and import Ext JS. ANd you are ready to develop with both frameworks!</p>
<p>It is very basic and simple, but I get some emails asking about it once in a while, so I thought it would be nice to share, in case you did not use both in a project together before.</p>
<p>Following is how the sample project structure looks like:</p>
<p><a href="http://loianegroner.com/wp-content/uploads/2011/08/extjs4_jquery_loiane.png"><img class="aligncenter size-full wp-image-1146" title="extjs4_jquery_loiane" src="http://loianegroner.com/wp-content/uploads/2011/08/extjs4_jquery_loiane.png" alt="" width="170" height="154" /></a></p>
<p>And this is the HTML page:</p>
<pre class="brush: xml; collapse: false; first-line: 1; title: ; toolbar: true; wrap-lines: false; notranslate">
&lt;html&gt;
&lt;head&gt;
	&lt;title&gt;Ext JS 4 + JQuery&lt;/title&gt;

	&lt;link rel=&quot;stylesheet&quot; type=&quot;text/css&quot; href=&quot;ext4/resources/css/ext-all.css&quot; /&gt;

	&lt;script type=&quot;text/javascript&quot; src=&quot;jquery/jquery-1.6.2.min.js&quot;&gt;&lt;/script&gt;
    &lt;script type=&quot;text/javascript&quot; src=&quot;ext4/ext-all.js&quot;&gt;&lt;/script&gt;
&lt;/head&gt;
&lt;body&gt;
	&lt;script type=&quot;text/javascript&quot;&gt;
	Ext.onReady(function() {
		Ext.Msg.alert('Alert',$('#divId').text());

	});
	&lt;/script&gt;
	&lt;div id=&quot;divId&quot; style=&quot;padding:20px;&quot;&gt;Using Ext JS 4 + JQuery&lt;/div&gt;
&lt;/body&gt;
&lt;/html&gt;
</pre>
<p>And the output will be:</p>
<p><a href="http://loianegroner.com/wp-content/uploads/2011/08/extjs4_jquery_loiane_01.png"><img src="http://loianegroner.com/wp-content/uploads/2011/08/extjs4_jquery_loiane_01.png" alt="" title="extjs4_jquery_loiane_01" width="261" height="164" class="aligncenter size-full wp-image-1147" /></a></p>
<h3>Download the source code:</h3>
<p><strong>Github</strong>: <a href="https://github.com/loiane/extjs4-jquery" target="_blank">https://github.com/loiane/extjs4-jquery</a></p>
<p><strong>Google Code (zip file):</strong> <a href="https://code.google.com/p/extjs4-jquery/downloads/list" target="_blank">https://code.google.com/p/extjs4-jquery/downloads/list</a></p>
<p>Happy Coding! <img src='http://loianegroner.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<div class="shr-publisher-1142"></div><!-- Start Shareaholic LikeButtonSetBottom Automatic --><!-- End Shareaholic LikeButtonSetBottom Automatic --><img src="http://loianegroner.com/?ak_action=api_record_view&id=1142&type=feed" alt="" /><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/LoianeGroner?a=B0_Uj7IUgdM:MfQOfMXBfts:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/LoianeGroner?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/LoianeGroner?a=B0_Uj7IUgdM:MfQOfMXBfts:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/LoianeGroner?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/LoianeGroner?a=B0_Uj7IUgdM:MfQOfMXBfts:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/LoianeGroner?i=B0_Uj7IUgdM:MfQOfMXBfts:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/LoianeGroner?a=B0_Uj7IUgdM:MfQOfMXBfts:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/LoianeGroner?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/LoianeGroner?a=B0_Uj7IUgdM:MfQOfMXBfts:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/LoianeGroner?i=B0_Uj7IUgdM:MfQOfMXBfts:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/LoianeGroner?a=B0_Uj7IUgdM:MfQOfMXBfts:I9og5sOYxJI"><img src="http://feeds.feedburner.com/~ff/LoianeGroner?d=I9og5sOYxJI" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/LoianeGroner/~4/B0_Uj7IUgdM" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://loianegroner.com/2011/08/how-to-use-extjs-4-jquery-together/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		<feedburner:origLink>http://loianegroner.com/2011/08/how-to-use-extjs-4-jquery-together/</feedburner:origLink></item>
		<item>
		<title>Running a Web Application on Jetty Webserver from Eclipse IDE</title>
		<link>http://feedproxy.google.com/~r/LoianeGroner/~3/_XAhzjmIrLY/</link>
		<comments>http://loianegroner.com/2011/07/running-a-web-application-on-jetty-webserver-from-eclipse-ide/#comments</comments>
		<pubDate>Fri, 29 Jul 2011 09:00:21 +0000</pubDate>
		<dc:creator>Loiane</dc:creator>
				<category><![CDATA[Jetty]]></category>
		<category><![CDATA[Eclipse]]></category>

		<guid isPermaLink="false">http://loianegroner.com/?p=1124</guid>
		<description><![CDATA[This tutorial will walk you through how to run a web application on Jetty webserver directly from Eclipse. Requirements: Install Jetty webserver Install plugin Run-Jetty-Run on Eclipse As I mentioned on the tutorials listed above, I am trying to use Jetty instead of Tomcat. In this post, I will show how it is easy to [...]]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop Automatic --><!-- End Shareaholic LikeButtonSetTop Automatic --><p style="text-align: justify;">This tutorial will walk you through how to run a web application on <a href="http://jetty.codehaus.org/jetty/" target="_blank">Jetty webserver</a> directly from Eclipse.</p>
<p><img class="aligncenter size-full wp-image-1125" title="Jetty_logo_loiane" src="http://loianegroner.com/wp-content/uploads/2011/07/Jetty_logo_loiane.jpg" alt="" width="226" height="64" /></p>
<h3 style="text-align: justify;"><strong>Requi</strong><strong>rements</strong>:</h3>
<ol style="text-align: justify;">
<li><a title="Installing and Running Jetty" href="http://loianegroner.com/2011/07/installing-and-running-jetty/" target="_blank">Install Jetty webserver</a></li>
<li><a title="Jetty and Eclipse Integration" href="http://loianegroner.com/2011/07/jetty-and-eclipse-integration/" target="_blank">Install plugin Run-Jetty-Run on Eclipse</a></li>
</ol>
<p style="text-align: justify;">As I mentioned on the tutorials listed above, I am trying to use <a href="http://jetty.codehaus.org/jetty/" target="_blank">Jetty </a>instead of <a href="http://tomcat.apache.org/" target="_blank">Tomcat</a>. In this post, I will show how it is easy to deploy a web applicationon Jetty directly from Eclipse.</p>
<h3 style="text-align: justify;">Steps:</h3>
<p style="text-align: justify;">1 – Create a <em>Dynamic Web Project</em> (you can right click on the Project Explorer view or go to File -&gt; New…):</p>
<p style="text-align: justify;"><a href="http://loianegroner.com/wp-content/uploads/2011/07/Jetty_loiane_04.png"><img class="aligncenter size-full wp-image-1127" title="Jetty_loiane_04" src="http://loianegroner.com/wp-content/uploads/2011/07/Jetty_loiane_04.png" alt="" width="512" height="268" /></a></p>
<p style="text-align: justify;">2 – Give a name to the project and click on Next:</p>
<p style="text-align: center;"><a href="http://loianegroner.com/wp-content/uploads/2011/07/Jetty_loiane_05.png"><img class="aligncenter size-full wp-image-1128" title="Jetty_loiane_05" src="http://loianegroner.com/wp-content/uploads/2011/07/Jetty_loiane_05.png" alt="" width="542" height="618" /></a></p>
<p style="text-align: justify;">3 – Click on Next:</p>
<p style="text-align: center;"><a href="http://loianegroner.com/wp-content/uploads/2011/07/Jetty_loiane_06.png"><img class="aligncenter size-full wp-image-1129" title="Jetty_loiane_06" src="http://loianegroner.com/wp-content/uploads/2011/07/Jetty_loiane_06.png" alt="" width="533" height="378" /></a></p>
<p style="text-align: justify;">4 – Check the option Generate web.xml… and click on Finish:</p>
<p style="text-align: center;"><a href="http://loianegroner.com/wp-content/uploads/2011/07/Jetty_loiane_07.png" target="_blank"><img class="aligncenter size-full wp-image-1130" title="Jetty_loiane_07" src="http://loianegroner.com/wp-content/uploads/2011/07/Jetty_loiane_07.png" alt="" width="533" height="378" /></a></p>
<p style="text-align: justify;">5 – This is how the project will look like:</p>
<p style="text-align: justify;"><a href="http://loianegroner.com/wp-content/uploads/2011/07/Jetty_loiane_08.png"><img class="aligncenter size-full wp-image-1131" title="Jetty_loiane_08" src="http://loianegroner.com/wp-content/uploads/2011/07/Jetty_loiane_08.png" alt="" width="246" height="174" /></a></p>
<p style="text-align: justify;">6 – Select the project and click on Run Button -&gt; Run Configurations…</p>
<p style="text-align: justify;"><a href="http://loianegroner.com/wp-content/uploads/2011/07/Jetty_loiane_09.png"><img class="aligncenter size-full wp-image-1132" title="Jetty_loiane_09" src="http://loianegroner.com/wp-content/uploads/2011/07/Jetty_loiane_09.png" alt="" width="352" height="297" /></a></p>
<p style="text-align: justify;">7 – Double click on Jetty Webapp. It will create a jetty project configuration under the Jetty Webapp with the project name. Click on Run:</p>
<p style="text-align: center;"><a href="http://loianegroner.com/wp-content/uploads/2011/07/Jetty_loiane_10.png" target="_blank"><img class="aligncenter size-full wp-image-1133" title="Jetty_loiane_10" src="http://loianegroner.com/wp-content/uploads/2011/07/Jetty_loiane_10.png" alt="" width="524" height="412" /></a></p>
<p style="text-align: justify;">8 – Wait for the server to start:</p>
<p style="text-align: center;"><a href="http://loianegroner.com/wp-content/uploads/2011/07/Jetty_loiane_11.png" target="_blank"><img class="aligncenter size-full wp-image-1134" title="Jetty_loiane_11" src="http://loianegroner.com/wp-content/uploads/2011/07/Jetty_loiane_11.png" alt="" width="564" height="336" /></a></p>
<p style="text-align: justify;">9 – Test your application!</p>
<p style="text-align: center;"><a href="http://loianegroner.com/wp-content/uploads/2011/07/Jetty_loiane_12.png" target="_blank"><img class="aligncenter size-full wp-image-1135" title="Jetty_loiane_12" src="http://loianegroner.com/wp-content/uploads/2011/07/Jetty_loiane_12.png" alt="" width="583" height="228" /></a></p>
<p style="text-align: justify;">I also recorded a video with the steps above:</p>
<p style="text-align: center;"><iframe src="http://www.youtube.com/embed/rq93RXAfTW4" frameborder="0" width="480" height="390"></iframe></p>
<p style="text-align: justify;">See? It is very simple!</p>
<p style="text-align: justify;">The sample project source code is also available on my github: <a href="https://github.com/loiane/test-jetty">https://github.com/loiane/test-jetty</a></p>
<p style="text-align: justify;">Happy Coding! <img src='http://loianegroner.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<div class="shr-publisher-1124"></div><!-- Start Shareaholic LikeButtonSetBottom Automatic --><!-- End Shareaholic LikeButtonSetBottom Automatic --><img src="http://loianegroner.com/?ak_action=api_record_view&id=1124&type=feed" alt="" /><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/LoianeGroner?a=_XAhzjmIrLY:VbF0IYsRY5c:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/LoianeGroner?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/LoianeGroner?a=_XAhzjmIrLY:VbF0IYsRY5c:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/LoianeGroner?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/LoianeGroner?a=_XAhzjmIrLY:VbF0IYsRY5c:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/LoianeGroner?i=_XAhzjmIrLY:VbF0IYsRY5c:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/LoianeGroner?a=_XAhzjmIrLY:VbF0IYsRY5c:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/LoianeGroner?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/LoianeGroner?a=_XAhzjmIrLY:VbF0IYsRY5c:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/LoianeGroner?i=_XAhzjmIrLY:VbF0IYsRY5c:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/LoianeGroner?a=_XAhzjmIrLY:VbF0IYsRY5c:I9og5sOYxJI"><img src="http://feeds.feedburner.com/~ff/LoianeGroner?d=I9og5sOYxJI" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/LoianeGroner/~4/_XAhzjmIrLY" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://loianegroner.com/2011/07/running-a-web-application-on-jetty-webserver-from-eclipse-ide/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://loianegroner.com/2011/07/running-a-web-application-on-jetty-webserver-from-eclipse-ide/</feedburner:origLink></item>
		<item>
		<title>Jetty and Eclipse Integration</title>
		<link>http://feedproxy.google.com/~r/LoianeGroner/~3/GhrjcEeQ7cM/</link>
		<comments>http://loianegroner.com/2011/07/jetty-and-eclipse-integration/#comments</comments>
		<pubDate>Tue, 26 Jul 2011 12:32:44 +0000</pubDate>
		<dc:creator>Loiane</dc:creator>
				<category><![CDATA[Jetty]]></category>
		<category><![CDATA[Eclipse]]></category>

		<guid isPermaLink="false">http://loianegroner.com/?p=1102</guid>
		<description><![CDATA[This tutorial will walk you through out how to install Jetty on Eclipse, so you can run web applications on Jetty directly from Eclipse IDE. As I mentioned on a previous post (Installing and running Jetty), I am trying to use Jetty instead of Tomcat. What I like about Tomcat is that Eclipse has native [...]]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop Automatic --><!-- End Shareaholic LikeButtonSetTop Automatic --><p style="text-align: justify;">This tutorial will walk you through out how to install Jetty on Eclipse, so you can run web applications on Jetty directly from Eclipse IDE.</p>
<p style="text-align: justify;"><a href="http://loianegroner.com/wp-content/uploads/2011/07/jetty-logo-80x22.png"><img class="aligncenter size-full wp-image-1119" title="jetty-logo-80x22" src="http://loianegroner.com/wp-content/uploads/2011/07/jetty-logo-80x22.png" alt="" width="283" height="80" /></a></p>
<p style="text-align: justify;">As I mentioned on a previous post (<a title="Installing and Running Jetty" href="http://loianegroner.com/2011/07/installing-and-running-jetty/" target="_blank">Installing and running Jetty</a>), I am trying to use <a href="http://jetty.codehaus.org/jetty/" target="_blank">Jetty </a>instead of <a href="http://tomcat.apache.org/" target="_blank">Tomcat</a>. What I like about <a href="http://tomcat.apache.org/" target="_blank">Tomcat </a>is that Eclipse has native support to it. You can quickly go to the servers view and add a new Tomcat server instance in less than a minute. But Eclipse does not have native support to Jetty, and I did some research of how to do the same easy way with <a href="http://jetty.codehaus.org/jetty/" target="_blank">Jetty </a>as well.</p>
<p style="text-align: justify;">I found this plugin <a href="http://code.google.com/p/run-jetty-run/" target="_blank">Run-Jetty-Run</a> hosted on Google Code and it is very simple to use. So in this post I will show how to install it within Eclipse and in the next post I will show how it is easy to use.</p>
<p style="text-align: justify;">There are two ways of installing a plugin on Eclipse now: using Eclipse Marketplace or the old way which is Install new Software.</p>
<h1 style="text-align: justify;">Eclipse Marketplace</h1>
<p style="text-align: justify;">The link of Run-Jetty_run Plugin on Marketplace is: <a href="http://marketplace.eclipse.org/content/run-jetty-run" target="_blank">http://marketplace.eclipse.org/content/run-jetty-run</a></p>
<p style="text-align: justify;">1 &#8211; Open Eclipse, go to the Help -&gt; Eclipse Marketplace:</p>
<p style="text-align: justify;"><a href="http://loianegroner.com/wp-content/uploads/2011/07/Jetty_Eclipse_Loiane_01.png"><img class="aligncenter size-full wp-image-1103" title="Jetty_Eclipse_Loiane_01" src="http://loianegroner.com/wp-content/uploads/2011/07/Jetty_Eclipse_Loiane_01.png" alt="" width="378" height="329" /></a></p>
<p style="text-align: justify;">2 &#8211; Search for run-jetty-run and click on install:</p>
<p style="text-align: justify;"><a href="http://loianegroner.com/wp-content/uploads/2011/07/Jetty_Eclipse_Loiane_02.png"><img class="aligncenter size-full wp-image-1104" title="Jetty_Eclipse_Loiane_02" src="http://loianegroner.com/wp-content/uploads/2011/07/Jetty_Eclipse_Loiane_02.png" alt="" width="545" height="487" /></a></p>
<p style="text-align: justify;">3 &#8211; Confirm the installation of the plugin:</p>
<p style="text-align: justify;"><a href="http://loianegroner.com/wp-content/uploads/2011/07/Jetty_Eclipse_Loiane_03.png"><img class="aligncenter size-full wp-image-1105" title="Jetty_Eclipse_Loiane_03" src="http://loianegroner.com/wp-content/uploads/2011/07/Jetty_Eclipse_Loiane_03.png" alt="" width="543" height="329" /></a></p>
<p style="text-align: justify;">4 &#8211; Review and accept the licence and click on Finish:</p>
<p style="text-align: justify;"><a href="http://loianegroner.com/wp-content/uploads/2011/07/Jetty_Eclipse_Loiane_04.png"><img class="aligncenter size-full wp-image-1106" title="Jetty_Eclipse_Loiane_04" src="http://loianegroner.com/wp-content/uploads/2011/07/Jetty_Eclipse_Loiane_04.png" alt="" width="541" height="417" /></a></p>
<p style="text-align: justify;">5 &#8211; Wait while the plugin is being installed and then restart Eclipse.</p>
<h1 style="text-align: justify;">Old way - Install new Software</h1>
<p style="text-align: justify;">1 &#8211; Open Eclipse, go to the Help -&gt; Install new Software:</p>
<p style="text-align: justify;"><a href="http://loianegroner.com/wp-content/uploads/2011/07/Jetty_Eclipse_Loiane_05.png"><img class="aligncenter size-full wp-image-1107" title="Jetty_Eclipse_Loiane_05" src="http://loianegroner.com/wp-content/uploads/2011/07/Jetty_Eclipse_Loiane_05.png" alt="" width="423" height="320" /></a></p>
<p style="text-align: justify;">2 &#8211; Click on Add, then fill the form with Name:Jetty (or whatever you like) and Location: <a href="http://run-jetty-run.googlecode.com/svn/trunk/updatesite" target="_blank">http://run-jetty-run.googlecode.com/svn/trunk/updatesite </a></p>
<p style="text-align: justify;"><a href="http://loianegroner.com/wp-content/uploads/2011/07/Jetty_Eclipse_Loiane_06.png"><img class="aligncenter size-full wp-image-1108" title="Jetty_Eclipse_Loiane_06" src="http://loianegroner.com/wp-content/uploads/2011/07/Jetty_Eclipse_Loiane_06.png" alt="" width="565" height="604" /></a></p>
<p style="text-align: justify;">3 &#8211; Select the plugin and click on Next:</p>
<p style="text-align: justify;"><a href="http://loianegroner.com/wp-content/uploads/2011/07/Jetty_Eclipse_Loiane_08.png"><img class="aligncenter size-full wp-image-1109" title="Jetty_Eclipse_Loiane_08" src="http://loianegroner.com/wp-content/uploads/2011/07/Jetty_Eclipse_Loiane_08.png" alt="" width="565" height="601" /></a></p>
<p style="text-align: justify;">4 &#8211; Confirm the installation of the plugin:</p>
<p style="text-align: center;"><a href="http://loianegroner.com/wp-content/uploads/2011/07/Jetty_Eclipse_Loiane_09.png" target="_blank"><img class="aligncenter size-full wp-image-1110" title="Jetty_Eclipse_Loiane_09" src="http://loianegroner.com/wp-content/uploads/2011/07/Jetty_Eclipse_Loiane_09.png" alt="" width="557" height="282" /></a></p>
<p style="text-align: justify;">5 &#8211; Review and accept the licence and click on Finish:</p>
<p style="text-align: justify;"><a href="http://loianegroner.com/wp-content/uploads/2011/07/Jetty_Eclipse_Loiane_10.png"><img class="aligncenter size-full wp-image-1111" title="Jetty_Eclipse_Loiane_10" src="http://loianegroner.com/wp-content/uploads/2011/07/Jetty_Eclipse_Loiane_10.png" alt="" width="462" height="408" /></a></p>
<p style="text-align: justify;">6 &#8211; Wait while the plugin is being installed and then restart Eclipse.</p>
<p style="text-align: justify;">On next post, we will see how to use it.</p>
<p style="text-align: justify;">Happy Coding! <img src='http://loianegroner.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<div class="shr-publisher-1102"></div><!-- Start Shareaholic LikeButtonSetBottom Automatic --><!-- End Shareaholic LikeButtonSetBottom Automatic --><img src="http://loianegroner.com/?ak_action=api_record_view&id=1102&type=feed" alt="" /><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/LoianeGroner?a=GhrjcEeQ7cM:ePlGOlJPVyg:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/LoianeGroner?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/LoianeGroner?a=GhrjcEeQ7cM:ePlGOlJPVyg:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/LoianeGroner?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/LoianeGroner?a=GhrjcEeQ7cM:ePlGOlJPVyg:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/LoianeGroner?i=GhrjcEeQ7cM:ePlGOlJPVyg:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/LoianeGroner?a=GhrjcEeQ7cM:ePlGOlJPVyg:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/LoianeGroner?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/LoianeGroner?a=GhrjcEeQ7cM:ePlGOlJPVyg:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/LoianeGroner?i=GhrjcEeQ7cM:ePlGOlJPVyg:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/LoianeGroner?a=GhrjcEeQ7cM:ePlGOlJPVyg:I9og5sOYxJI"><img src="http://feeds.feedburner.com/~ff/LoianeGroner?d=I9og5sOYxJI" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/LoianeGroner/~4/GhrjcEeQ7cM" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://loianegroner.com/2011/07/jetty-and-eclipse-integration/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		<feedburner:origLink>http://loianegroner.com/2011/07/jetty-and-eclipse-integration/</feedburner:origLink></item>
		<item>
		<title>ExtJS 4 File Upload + Spring MVC 3 Example</title>
		<link>http://feedproxy.google.com/~r/LoianeGroner/~3/udhIBn2V-h4/</link>
		<comments>http://loianegroner.com/2011/07/extjs-4-file-upload-spring-mvc-3-example/#comments</comments>
		<pubDate>Mon, 18 Jul 2011 09:00:32 +0000</pubDate>
		<dc:creator>Loiane</dc:creator>
				<category><![CDATA[Ext JS 4]]></category>
		<category><![CDATA[Spring]]></category>
		<category><![CDATA[Spring MVC 3]]></category>

		<guid isPermaLink="false">http://loianegroner.com/?p=1093</guid>
		<description><![CDATA[This tutorial will walk you through out how to use the Ext JS 4 File Upload Field in the front end and Spring MVC 3 in the back end. This tutorial is also an update for the tutorial Ajax File Upload with ExtJS and Spring Framework, implemented with Ext JS 3 and Spring MVC 2.5. Ext [...]]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop Automatic --><!-- End Shareaholic LikeButtonSetTop Automatic --><p style="text-align: justify;">This tutorial will walk you through out how to use the Ext JS 4 File Upload Field in the front end and Spring MVC 3 in the back end.</p>
<p style="text-align: justify;">This tutorial is also an update for the tutorial <a title="Ajax File Upload with ExtJS and Spring Framework" href="http://loianegroner.com/2010/03/ajax-file-upload-with-extjs-and-spring-framework/">Ajax File Upload with ExtJS and Spring Framework</a>, implemented with Ext JS 3 and Spring MVC 2.5.</p>
<p style="text-align: justify;"><a href="http://loianegroner.com/wp-content/uploads/2011/07/extjs4-file-upload-spring_loiane.png"><img class="aligncenter size-full wp-image-1098" title="extjs4-file-upload-spring_loiane" src="http://loianegroner.com/wp-content/uploads/2011/07/extjs4-file-upload-spring_loiane.png" alt="" width="414" height="124" /></a></p>
<h1 style="text-align: justify;">Ext JS File Upload Form</h1>
<p style="text-align: justify;">First, we will need the Ext JS 4 File upload form. This one is the same as showed in <a href="http://dev.sencha.com/deploy/ext-4.0.2a/docs/#/api/Ext.form.field.File" target="_blank">Ext JS 4 docs</a>.</p>
<pre class="brush: jscript; collapse: false; first-line: 1; title: ; toolbar: true; wrap-lines: false; notranslate">
Ext.onReady(function(){

    Ext.create('Ext.form.Panel', {
        title: 'File Uploader',
        width: 400,
        bodyPadding: 10,
        frame: true,
        renderTo: 'fi-form',
        items: [{
            xtype: 'filefield',
            name: 'file',
            fieldLabel: 'File',
            labelWidth: 50,
            msgTarget: 'side',
            allowBlank: false,
            anchor: '100%',
            buttonText: 'Select a File...'
        }],

        buttons: [{
            text: 'Upload',
            handler: function() {
                var form = this.up('form').getForm();
                if(form.isValid()){
                    form.submit({
                        url: 'upload.action',
                        waitMsg: 'Uploading your file...',
                        success: function(fp, o) {
                            Ext.Msg.alert('Success', 'Your file has been uploaded.');
                        }
                    });
                }
            }
        }]
    });
});
</pre>
<h1 style="text-align: justify;">HTML Page</h1>
<p style="text-align: justify;">Then in the HTML page, we will have a div where we are going to render the Ext JS form. This page also contains the required javascript imports:</p>
<pre class="brush: xml; collapse: false; first-line: 1; title: ; toolbar: true; wrap-lines: false; notranslate">
&lt;html&gt;
&lt;head&gt;
&lt;title&gt;Spring FileUpload Example with ExtJS 4 Form&lt;/title&gt;

	&lt;!-- Ext JS Files --&gt;
	&lt;link rel=&quot;stylesheet&quot; type=&quot;text/css&quot; href=&quot;/extjs4-file-upload-spring/extjs/resources/css/ext-all.css&quot; /&gt;
    &lt;script type=&quot;text/javascript&quot; src=&quot;/extjs4-file-upload-spring/extjs/bootstrap.js&quot;&gt;&lt;/script&gt;

	&lt;!-- file upload form --&gt;
	&lt;script src=&quot;/extjs4-file-upload-spring/js/file-upload.js&quot;&gt;&lt;/script&gt;

&lt;/head&gt;
&lt;body&gt;

	&lt;p&gt;Click on &quot;Browse&quot; button (image) to select a file and click on Upload button&lt;/p&gt;

	&lt;div id=&quot;fi-form&quot; style=&quot;padding:25px;&quot;&gt;&lt;/div&gt;
&lt;/body&gt;
&lt;/html&gt;
</pre>
<h1 style="text-align: justify;">FileUpload Bean</h1>
<p style="text-align: justify;">We will also need a FileUpload Bean to represent the file as a multipart file:</p>
<pre class="brush: java; collapse: false; first-line: 1; title: ; toolbar: true; wrap-lines: false; notranslate">
package com.loiane.model;

import org.springframework.web.multipart.commons.CommonsMultipartFile;

/**
 * Represents file uploaded from extjs form
 *
 * @author Loiane Groner
 * http://loiane.com
 * http://loianegroner.com
 */
public class FileUploadBean {

	private CommonsMultipartFile file;

	public CommonsMultipartFile getFile() {
		return file;
	}

	public void setFile(CommonsMultipartFile file) {
		this.file = file;
	}
}
</pre>
<h1 style="text-align: justify;">File Upload Controller</h1>
<p style="text-align: justify;">Then we will need a controller. This one is implemented with Spring MVC 3.</p>
<pre class="brush: java; collapse: false; first-line: 1; title: ; toolbar: true; wrap-lines: false; notranslate">
package com.loiane.controller;

import org.springframework.stereotype.Controller;
import org.springframework.validation.BindingResult;
import org.springframework.validation.ObjectError;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.loiane.model.ExtJSFormResult;
import com.loiane.model.FileUploadBean;

/**
 * Controller - Spring
 *
 * @author Loiane Groner
 * http://loiane.com
 * http://loianegroner.com
 */
@Controller
@RequestMapping(value = &quot;/upload.action&quot;)
public class FileUploadController {

	@RequestMapping(method = RequestMethod.POST)
	public @ResponseBody String create(FileUploadBean uploadItem, BindingResult result){

		ExtJSFormResult extjsFormResult = new ExtJSFormResult();

		if (result.hasErrors()){
			for(ObjectError error : result.getAllErrors()){
				System.err.println(&quot;Error: &quot; + error.getCode() +  &quot; - &quot; + error.getDefaultMessage());
			}

			//set extjs return - error
			extjsFormResult.setSuccess(false);

			return extjsFormResult.toString();
		}

		// Some type of file processing...
		System.err.println(&quot;-------------------------------------------&quot;);
		System.err.println(&quot;Test upload: &quot; + uploadItem.getFile().getOriginalFilename());
		System.err.println(&quot;-------------------------------------------&quot;);

		//set extjs return - sucsess
		extjsFormResult.setSuccess(true);

		return extjsFormResult.toString();

}
</pre>
<h1 style="text-align: justify;">Ext JS Form Return</h1>
<p style="text-align: justify;">Some people asked me how to return something to the form to display a message to the user. We can implement a POJO with a success property. The success property is the only thing Ext JS needs as a return:</p>
<pre class="brush: java; collapse: false; first-line: 1; title: ; toolbar: true; wrap-lines: false; notranslate">
package com.loiane.model;

/**
 * A simple return message for Ext JS
 *
 * @author Loiane Groner
 * http://loiane.com
 * http://loianegroner.com
 */
public class ExtJSFormResult {

	private boolean success;

	public boolean isSuccess() {
		return success;
	}
	public void setSuccess(boolean success) {
		this.success = success;
	}

	public String toString(){
		return &quot;{success:&quot;+this.success+&quot;}&quot;;
	}
}
</pre>
<h1 style="text-align: justify;">Spring Config</h1>
<p style="text-align: justify;">Don&#8217;t forget to add the multipart file config in the Spring config file:</p>
<pre class="brush: xml; collapse: false; first-line: 1; title: ; toolbar: true; wrap-lines: false; notranslate">
    &lt;!-- Configure the multipart resolver --&gt;
    &lt;bean id=&quot;multipartResolver&quot; class=&quot;org.springframework.web.multipart.commons.CommonsMultipartResolver&quot;&gt;
        &lt;!-- one of the properties available; the maximum file size in bytes --&gt;
        &lt;property name=&quot;maxUploadSize&quot; value=&quot;100000&quot;/&gt;
    &lt;/bean&gt;
</pre>
<h1 style="text-align: justify;">NullPointerException</h1>
<p style="text-align: justify;">I also got some questions about NullPointerException. Make sure the fileupload field name has the same name as the CommonsMultipartFile property in the FileUploadBean class:</p>
<p style="text-align: justify;">ExtJS:</p>
<pre class="brush: jscript; collapse: false; first-line: 1; highlight: [3]; title: ; toolbar: true; wrap-lines: false; notranslate">
{
	xtype: 'filefield',
	name: 'file',
	fieldLabel: 'File',
	labelWidth: 50,
	msgTarget: 'side',
	allowBlank: false,
	anchor: '100%',
	buttonText: 'Select a File...'
}
</pre>
<p style="text-align: justify;">Java:</p>
<pre class="brush: java; collapse: false; first-line: 1; highlight: [3]; title: ; toolbar: true; wrap-lines: false; notranslate">
public class FileUploadBean {

	private CommonsMultipartFile file;
}
</pre>
<p style="text-align: justify;">These properties <strong>ALWAYS</strong> have to match!</p>
<p style="text-align: justify;">You can still use the Spring MVC 2.5 code with the Ext JS 4 code presented in this tutorial.</p>
<h3 style="text-align: justify;">Download</h3>
<p style="text-align: justify;">You can download the source code from my Github repository (you can clone the project or you can click on the download button on the upper right corner of the project page): <a href="https://github.com/loiane/extjs4-file-upload-spring" target="_blank">https://github.com/loiane/extjs4-file-upload-spring</a></p>
<p style="text-align: justify;">You can also download the source code form the Google Code repository: <a href="http://code.google.com/p/extjs4-file-upload-spring/" target="_blank">http://code.google.com/p/extjs4-file-upload-spring/</a></p>
<p style="text-align: justify;">Both repositories have the same source. Google Code is just an alternative.</p>
<p style="text-align: justify;">Happy Coding! <img src='http://loianegroner.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<div class="shr-publisher-1093"></div><!-- Start Shareaholic LikeButtonSetBottom Automatic --><!-- End Shareaholic LikeButtonSetBottom Automatic --><img src="http://loianegroner.com/?ak_action=api_record_view&id=1093&type=feed" alt="" /><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/LoianeGroner?a=udhIBn2V-h4:4fKY7QcO438:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/LoianeGroner?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/LoianeGroner?a=udhIBn2V-h4:4fKY7QcO438:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/LoianeGroner?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/LoianeGroner?a=udhIBn2V-h4:4fKY7QcO438:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/LoianeGroner?i=udhIBn2V-h4:4fKY7QcO438:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/LoianeGroner?a=udhIBn2V-h4:4fKY7QcO438:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/LoianeGroner?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/LoianeGroner?a=udhIBn2V-h4:4fKY7QcO438:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/LoianeGroner?i=udhIBn2V-h4:4fKY7QcO438:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/LoianeGroner?a=udhIBn2V-h4:4fKY7QcO438:I9og5sOYxJI"><img src="http://feeds.feedburner.com/~ff/LoianeGroner?d=I9og5sOYxJI" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/LoianeGroner/~4/udhIBn2V-h4" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://loianegroner.com/2011/07/extjs-4-file-upload-spring-mvc-3-example/feed/</wfw:commentRss>
		<slash:comments>27</slash:comments>
		<feedburner:origLink>http://loianegroner.com/2011/07/extjs-4-file-upload-spring-mvc-3-example/</feedburner:origLink></item>
		<item>
		<title>New Java 7 Language Features</title>
		<link>http://feedproxy.google.com/~r/LoianeGroner/~3/M-32h5KU92k/</link>
		<comments>http://loianegroner.com/2011/07/new-java-7-language-features/#comments</comments>
		<pubDate>Mon, 11 Jul 2011 09:00:53 +0000</pubDate>
		<dc:creator>Loiane</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Java 7]]></category>
		<category><![CDATA[NetBeans 7]]></category>
		<category><![CDATA[Project Coin]]></category>

		<guid isPermaLink="false">http://loianegroner.com/?p=1071</guid>
		<description><![CDATA[Last week I was at the Java 7 launch party in Sao Paulo, Brazil and it was really cool. There were a lot of developers on the party to celebrate Java 7 (afterall, we have been waiting for it for 5 years!). I took some pictures at the event: http://www.flickr.com/photos/loiane/sets/72157627015952961/ Video of the event: http://blogs.oracle.com/java/entry/java_7_celebration_begins Slides: http://blogs.oracle.com/darcy/resource/ProjectCoin/CoinLaunch.pdf Anyways, [...]]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop Automatic --><!-- End Shareaholic LikeButtonSetTop Automatic --><p style="text-align: justify;">Last week I was at the Java 7 launch party in Sao Paulo, Brazil and it was really cool. There were a lot of developers on the party to celebrate Java 7 (afterall, we have been waiting for it for 5 years!).</p>
<p style="text-align: justify;">I took some pictures at the event: <a href="http://www.flickr.com/photos/loiane/sets/72157627015952961/" target="_blank">http://www.flickr.com/photos/loiane/sets/72157627015952961/</a></p>
<p style="text-align: justify;">Video of the event: <a href="http://blogs.oracle.com/java/entry/java_7_celebration_begins" target="_blank">http://blogs.oracle.com/java/entry/java_7_celebration_begins</a></p>
<p style="text-align: justify;">Slides:<a href="http://blogs.oracle.com/darcy/resource/ProjectCoin/CoinLaunch.pdf" target="_blank"> http://blogs.oracle.com/darcy/resource/ProjectCoin/CoinLaunch.pdf</a></p>
<p style="text-align: justify;"><a href="http://loianegroner.com/wp-content/uploads/2011/07/duke_java7.jpg"><img class="alignleft size-full wp-image-1074" title="Print" src="http://loianegroner.com/wp-content/uploads/2011/07/duke_java7.jpg" alt="" width="135" height="228" /></a>Anyways, I was really excited with the event and I went home and started to play with Java 7 language features.</p>
<p style="text-align: justify;">As I will have to wait for Open JDK for Mac to be released, I had to play with it on Windows. You can <a href="http://jdk7.java.net/" target="_blank">download Java 7 here</a>.</p>
<p style="text-align: justify;">Another issue I found is Eclipse does not have native support for <a href="http://jdk7.java.net/" target="_blank">Java 7</a>. They released a plugin, but it still beta. So I decided to play with <a href="http://netbeans.org/" target="_blank">NetBeans</a>.</p>
<p style="text-align: justify;">The current version of <a href="http://netbeans.org/" target="_blank">NetBeans </a>is 7, and it already comes with native support to Java 7. If you install Java 7 and then install <a href="http://netbeans.org/" target="_blank">NetBeans</a>, it will set Java 7 as the default JDK for development.</p>
<p style="text-align: justify;">Then I created a Java Project on NetBeans but the source code was still compiling in Java 6. You have to <a href="http://netbeans.org/kb/docs/java/javase-jdk7.html#project" target="_blank">make a small change to make it compile with Java 7</a>.</p>
<p style="text-align: justify;">All set and I started to play with some languages new features, aka Project Coin.</p>
<h1 style="text-align: justify;">Strings in Switch:</h1>
<p style="text-align: justify;">In all examples, I tried first to write code as we usually do, and then convert the code to a Java 7 feature. The cool thing about <a href="http://netbeans.org/" target="_blank">NetBeans</a> is it already have tips to convert the code.</p>
<p style="text-align: justify;">First, will compare some Strings using if-else. NetBeans will popup a warning like this:</p>
<p style="text-align: justify;"><a href="http://loianegroner.com/wp-content/uploads/2011/07/java7_loiane_01.jpg"><img class="aligncenter size-full wp-image-1075" title="java7_loiane_01" src="http://loianegroner.com/wp-content/uploads/2011/07/java7_loiane_01.jpg" alt="" width="443" height="289" /></a></p>
<p style="text-align: justify;">And if we accept the change, it will convert the code into this:</p>
<p style="text-align: justify;"><a href="http://loianegroner.com/wp-content/uploads/2011/07/java7_loiane_02.jpg"><img class="aligncenter size-full wp-image-1076" title="java7_loiane_02" src="http://loianegroner.com/wp-content/uploads/2011/07/java7_loiane_02.jpg" alt="" width="451" height="338" /></a></p>
<p style="text-align: justify;">Following is the code:</p>
<p>Before:</p>
<pre class="brush: java; collapse: false; first-line: 1; title: ; toolbar: true; wrap-lines: false; notranslate">
 public void testStringInSwitch(String param){

        final String JAVA5 = &quot;Java 5&quot;;
        final String JAVA6 = &quot;Java 6&quot;;
        final String JAVA7 = &quot;Java 7&quot;;

        if (param.equals(JAVA5)){
            System.out.println(JAVA5);
        } else if (param.equals(JAVA6)){
            System.out.println(JAVA6);
        } else if (param.equals(JAVA7)){
            System.out.println(JAVA7);
        }
    }
</pre>
<p>Java7:</p>
<pre class="brush: java; collapse: false; first-line: 1; title: ; toolbar: true; wrap-lines: false; notranslate">
 public void testStringInSwitch(String param){

        final String JAVA5 = &quot;Java 5&quot;;
        final String JAVA6 = &quot;Java 6&quot;;
        final String JAVA7 = &quot;Java 7&quot;;

        switch (param) {
            case JAVA5:
                System.out.println(JAVA5);
                break;
            case JAVA6:
                System.out.println(JAVA6);
                break;
            case JAVA7:
                System.out.println(JAVA7);
                break;
        }
    }
</pre>
<h1 style="text-align: justify;">Binary Literals:</h1>
<p>Before:</p>
<pre class="brush: java; collapse: false; first-line: 1; title: ; toolbar: true; wrap-lines: false; notranslate">
public void testBinaryIntegralLiterals(){

        int binary = 8;

        if (binary == 8){
            System.out.println(true);
        } else{
            System.out.println(false);
        }
}
</pre>
<p>Java7:</p>
<pre class="brush: java; collapse: false; first-line: 1; title: ; toolbar: true; wrap-lines: false; notranslate">
 public void testBinaryIntegralLiterals(){

        int binary = 0b1000; //2^3 = 8

        if (binary == 8){
            System.out.println(true);
        } else{
            System.out.println(false);
        }
}
</pre>
<p style="text-align: justify;">And if you try to declare a constant number in the code, NetBeans will warn you to convert it into a Binary Literal:</p>
<p style="text-align: justify;"><a href="http://loianegroner.com/wp-content/uploads/2011/07/java7_loiane_09.jpg"><img class="aligncenter size-full wp-image-1083" title="java7_loiane_09" src="http://loianegroner.com/wp-content/uploads/2011/07/java7_loiane_09.jpg" alt="" width="432" height="172" /></a></p>
<p style="text-align: justify;">to</p>
<p style="text-align: justify;"><a href="http://loianegroner.com/wp-content/uploads/2011/07/java7_loiane_10.jpg"><img class="aligncenter size-full wp-image-1084" title="java7_loiane_10" src="http://loianegroner.com/wp-content/uploads/2011/07/java7_loiane_10.jpg" alt="" width="417" height="174" /></a></p>
<pre class="brush: java; collapse: false; first-line: 1; title: ; toolbar: true; wrap-lines: false; notranslate">
public void testUnderscoresNumericLiterals() {

        int oneMillion_ = 1_000_000;
        int oneMillion = 1000000;

        if (oneMillion_ == oneMillion){
            System.out.println(true);
        } else{
            System.out.println(false);
        }
    }
</pre>
<h1 style="text-align: justify;">Underscore Between Literals:</h1>
<pre class="brush: java; collapse: false; first-line: 1; title: ; toolbar: true; wrap-lines: false; notranslate">
public void testUnderscoresNumericLiterals() {

	int oneMillion_ = 1_000_000; //new
    int oneMillion = 1000000;

    if (oneMillion_ == oneMillion){
		System.out.println(true);
    } else{
        System.out.println(false);
    }
}
</pre>
<h1 style="text-align: justify;">Diamond Syntax:</h1>
<p>Before:</p>
<pre class="brush: java; collapse: false; first-line: 1; title: ; toolbar: true; wrap-lines: false; notranslate">
public void testDinamond(){

    List&lt;String&gt; list = new ArrayList&lt;String&gt;();
    Map&lt;String, List&lt;String&gt;&gt; map = new HashMap&lt;String, List&lt;String&gt;&gt;();
}
</pre>
<p>Java7:</p>
<pre class="brush: java; collapse: false; first-line: 1; title: ; toolbar: true; wrap-lines: false; notranslate">
public void testDinamond(){
    List&lt;String&gt; list = new ArrayList&lt;&gt;();
    Map&lt;String, List&lt;String&gt;&gt; map = new HashMap&lt;&gt;();
}
</pre>
<p style="text-align: justify;">When we write code in Java 6 syntax, NetBeans will warn us to convert it into Java 7 Diamond Syntax:</p>
<p style="text-align: center;"><a href="http://loianegroner.com/wp-content/uploads/2011/07/java7_loiane_05.jpg"><img class="aligncenter size-full wp-image-1079" title="java7_loiane_05" src="http://loianegroner.com/wp-content/uploads/2011/07/java7_loiane_05.jpg" alt="" width="598" height="98" /></a></p>
<p style="text-align: justify;">To</p>
<p style="text-align: justify;"><a href="http://loianegroner.com/wp-content/uploads/2011/07/java7_loiane_06.jpg"><img class="aligncenter size-full wp-image-1080" title="java7_loiane_06" src="http://loianegroner.com/wp-content/uploads/2011/07/java7_loiane_06.jpg" alt="" width="501" height="105" /></a></p>
<h1 style="text-align: justify;">Multi-Catch Similar Exceptions:</h1>
<p>Before:</p>
<pre class="brush: java; collapse: false; first-line: 1; title: ; toolbar: true; wrap-lines: false; notranslate">
    public void testMultiCatch(){

        try {
            throw new FileNotFoundException(&quot;FileNotFoundException&quot;);
        } catch (FileNotFoundException fnfo) {
            fnfo.printStackTrace();
        } catch (IOException ioe) {
            ioe.printStackTrace();
   }
</pre>
<p>Java 7:</p>
<pre class="brush: java; collapse: false; first-line: 1; title: ; toolbar: true; wrap-lines: false; notranslate">
    public void testMultiCatch(){

        try {
            throw new FileNotFoundException(&quot;FileNotFoundException&quot;);
        } catch (FileNotFoundException | IOException fnfo) {
            fnfo.printStackTrace();
        }
    }
</pre>
<p style="text-align: justify;">Same thing here. NetBeans will ask to convert the code into Java 7:</p>
<p style="text-align: center;"><a href="http://loianegroner.com/wp-content/uploads/2011/07/java7_loiane_03.jpg"><img class="aligncenter size-full wp-image-1077" title="java7_loiane_03" src="http://loianegroner.com/wp-content/uploads/2011/07/java7_loiane_03.jpg" alt="" width="554" height="171" /></a></p>
<p style="text-align: justify;">To</p>
<p style="text-align: center;"><a href="http://loianegroner.com/wp-content/uploads/2011/07/java7_loiane_04.jpg"><img class="aligncenter size-full wp-image-1078" title="java7_loiane_04" src="http://loianegroner.com/wp-content/uploads/2011/07/java7_loiane_04.jpg" alt="" width="549" height="138" /></a></p>
<h1 style="text-align: justify;">Try with Resources:</h1>
<p>Before:</p>
<pre class="brush: java; collapse: false; first-line: 1; title: ; toolbar: true; wrap-lines: false; notranslate">
    public void testTryWithResourcesStatement() throws FileNotFoundException, IOException{

         FileInputStream in = null;
        try {
            in = new FileInputStream(&quot;java7.txt&quot;);

            System.out.println(in.read());

        } finally {
            if (in != null) {
                in.close();
            }
        }

    }
</pre>
<p>Java 7:</p>
<pre class="brush: java; collapse: false; first-line: 1; title: ; toolbar: true; wrap-lines: false; notranslate">
    public void testTryWithResourcesStatement() throws FileNotFoundException, IOException{

        try (FileInputStream in = new FileInputStream(&quot;java7.txt&quot;)) {

            System.out.println(in.read());

        }
    }
</pre>
<p style="text-align: justify;">Same thing here:</p>
<p style="text-align: center;"><a href="http://loianegroner.com/wp-content/uploads/2011/07/java7_loiane_07.jpg"><img class="aligncenter size-full wp-image-1081" title="java7_loiane_07" src="http://loianegroner.com/wp-content/uploads/2011/07/java7_loiane_07.jpg" alt="" width="543" height="169" /></a></p>
<p style="text-align: justify;">To:</p>
<p style="text-align: center;"><a href="http://loianegroner.com/wp-content/uploads/2011/07/java7_loiane_08.jpg"><img class="aligncenter size-full wp-image-1082" title="java7_loiane_08" src="http://loianegroner.com/wp-content/uploads/2011/07/java7_loiane_08.jpg" alt="" width="549" height="98" /></a></p>
<p style="text-align: justify;">There is also varargs simplification, but I did not understand this one very well to code an example.</p>
<p style="text-align: justify;">There are another features that were submited, but did not make it into this release:</p>
<ul>
<li><a href="http://mail.openjdk.java.net/pipermail/coin-dev/2009-March/000047.html" target="_blank">Elvis Operator</a></li>
<li><a href="http://mail.openjdk.java.net/pipermail/coin-dev/2009-March/001193.html" target="_blank">List and Maps Index</a></li>
<li><a href="http://mail.openjdk.java.net/pipermail/coin-dev/2009-March/001193.html" target="_blank">Collection Literals</a></li>
<li><a href="http://mail.openjdk.java.net/pipermail/coin-dev/2009-March/000047.html" target="_blank">Null-Safe navigation</a></li>
</ul>
<p style="text-align: justify;">The code presented on this post is not only theory, I really ran it in my machine. You can get/download the NetBeans project from my github: <a href="https://github.com/loiane/Java7HelloWorld" target="_blank">https://github.com/loiane/Java7HelloWorld</a></p>
<p style="text-align: justify;">A quick update: A DZone released today a RefCardz about NetBeans and Java 7 &#8211; it is a pdf and the download is free: <a href="http://refcardz.dzone.com/refcardz/netbeans-ide-7-programming" target="_blank">http://refcardz.dzone.com/refcardz/netbeans-ide-7-programming</a></p>
<div class="shr-publisher-1071"></div><!-- Start Shareaholic LikeButtonSetBottom Automatic --><!-- End Shareaholic LikeButtonSetBottom Automatic --><img src="http://loianegroner.com/?ak_action=api_record_view&id=1071&type=feed" alt="" /><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/LoianeGroner?a=M-32h5KU92k:SZfPfcn_tlk:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/LoianeGroner?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/LoianeGroner?a=M-32h5KU92k:SZfPfcn_tlk:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/LoianeGroner?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/LoianeGroner?a=M-32h5KU92k:SZfPfcn_tlk:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/LoianeGroner?i=M-32h5KU92k:SZfPfcn_tlk:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/LoianeGroner?a=M-32h5KU92k:SZfPfcn_tlk:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/LoianeGroner?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/LoianeGroner?a=M-32h5KU92k:SZfPfcn_tlk:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/LoianeGroner?i=M-32h5KU92k:SZfPfcn_tlk:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/LoianeGroner?a=M-32h5KU92k:SZfPfcn_tlk:I9og5sOYxJI"><img src="http://feeds.feedburner.com/~ff/LoianeGroner?d=I9og5sOYxJI" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/LoianeGroner/~4/M-32h5KU92k" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://loianegroner.com/2011/07/new-java-7-language-features/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		<feedburner:origLink>http://loianegroner.com/2011/07/new-java-7-language-features/</feedburner:origLink></item>
		<item>
		<title>Installing and Running Jetty</title>
		<link>http://feedproxy.google.com/~r/LoianeGroner/~3/g44UhoieevA/</link>
		<comments>http://loianegroner.com/2011/07/installing-and-running-jetty/#comments</comments>
		<pubDate>Wed, 06 Jul 2011 09:00:20 +0000</pubDate>
		<dc:creator>Loiane</dc:creator>
				<category><![CDATA[Jetty]]></category>

		<guid isPermaLink="false">http://loianegroner.com/?p=1010</guid>
		<description><![CDATA[This tutorial will walk you through how to download, install and run Jetty &#8211; 100 % Java HTTP and Servlet Container. If you do not know Jetty, Following is what Wikipedia says about it: Jetty is a pure Java-based HTTP server and servlet container (Application server) developed as a free and open source project as part of the Eclipse Foundation. It [...]]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop Automatic --><!-- End Shareaholic LikeButtonSetTop Automatic --><p>This tutorial will walk you through how to download, install and run Jetty &#8211; 100 % Java HTTP and Servlet Container.</p>
<p>If you do not know Jetty, Following is what <a href="http://en.wikipedia.org/wiki/Jetty_(Web_server)" target="_blank">Wikipedia</a> says about it:</p>
<p><strong>Jetty</strong> is a pure <a title="Java (programming language)" href="http://en.wikipedia.org/wiki/Java_(programming_language)">Java</a>-based <a title="HTTP server" href="http://en.wikipedia.org/wiki/HTTP_server">HTTP server</a> and <a title="Servlet" href="http://en.wikipedia.org/wiki/Servlet">servlet</a> container (<a title="Application server" href="http://en.wikipedia.org/wiki/Application_server">Application server</a>) developed as a <a title="Free software" href="http://en.wikipedia.org/wiki/Free_software">free</a> and <a title="Open source" href="http://en.wikipedia.org/wiki/Open_source">open source</a> project as part of the <a title="Eclipse Foundation" href="http://en.wikipedia.org/wiki/Eclipse_Foundation">Eclipse Foundation</a>. It is currently used in products such as <a title="ActiveMQ" href="http://en.wikipedia.org/wiki/ActiveMQ">ActiveMQ</a>,<sup id="cite_ref-0"><a href="http://en.wikipedia.org/wiki/Jetty_(Web_server)#cite_note-0">[1]</a></sup> <a title="Alfresco (software)" href="http://en.wikipedia.org/wiki/Alfresco_(software)">Alfresco</a>, <sup id="cite_ref-1"><a href="http://en.wikipedia.org/wiki/Jetty_(Web_server)#cite_note-1">[2]</a></sup> <a title="Apache Geronimo" href="http://en.wikipedia.org/wiki/Apache_Geronimo">Apache Geronimo</a>,<sup id="cite_ref-2"><a href="http://en.wikipedia.org/wiki/Jetty_(Web_server)#cite_note-2">[3]</a></sup> <a title="Apache Maven" href="http://en.wikipedia.org/wiki/Apache_Maven">Apache Maven</a>, <a title="Google App Engine" href="http://en.wikipedia.org/wiki/Google_App_Engine">Google App Engine</a>,<sup id="cite_ref-support_3-0"><a href="http://en.wikipedia.org/wiki/Jetty_(Web_server)#cite_note-support-3">[4]</a></sup> <a title="Eclipse" href="http://en.wikipedia.org/wiki/Eclipse">Eclipse</a>,<sup id="cite_ref-4"><a href="http://en.wikipedia.org/wiki/Jetty_(Web_server)#cite_note-4">[5]</a></sup> <a title="Fuse Services Framework" href="http://en.wikipedia.org/wiki/Fuse_Services_Framework">FUSE</a>,<sup id="cite_ref-5"><a href="http://en.wikipedia.org/wiki/Jetty_(Web_server)#cite_note-5">[6]</a></sup> <a title="HP OpenView" href="http://en.wikipedia.org/wiki/HP_OpenView">HP OpenView</a>, <a title="JBoss" href="http://en.wikipedia.org/wiki/JBoss">JBoss</a>,<sup id="cite_ref-6"><a href="http://en.wikipedia.org/wiki/Jetty_(Web_server)#cite_note-6">[7]</a></sup> <a title="Liferay" href="http://en.wikipedia.org/wiki/Liferay">Liferay</a>,<sup id="cite_ref-7"><a href="http://en.wikipedia.org/wiki/Jetty_(Web_server)#cite_note-7">[8]</a></sup> <a title="Ubuntu (operating system)" href="http://en.wikipedia.org/wiki/Ubuntu_(operating_system)">Ubuntu</a>, <a title="HOSEbird" href="http://en.wikipedia.org/wiki/HOSEbird">Twitter&#8217;s Streaming API</a><sup id="cite_ref-8"><a href="http://en.wikipedia.org/wiki/Jetty_(Web_server)#cite_note-8">[9]</a></sup> and <a title="Zimbra" href="http://en.wikipedia.org/wiki/Zimbra">Zimbra</a>.<sup id="cite_ref-9"><a href="http://en.wikipedia.org/wiki/Jetty_(Web_server)#cite_note-9">[10]</a></sup> Jetty is also used as a standard Java application server by many open source projects such as <a title="Eucalyptus (computing)" href="http://en.wikipedia.org/wiki/Eucalyptus_(computing)">Eucalyptus</a> and <a title="Hadoop" href="http://en.wikipedia.org/wiki/Hadoop">Hadoop</a>.</p>
<p>I am doing some experiments, and I decided to use <a href="http://jetty.codehaus.org/jetty/" target="_blank">Jetty</a> instead of <a href="http://tomcat.apache.org/" target="_blank">TomCat</a>.</p>
<p>So let&#8217;s get this server up and running!</p>
<h2>1 &#8211; Downloading</h2>
<p>You can download Jetty from two sources: Eclipse or Codehaus.</p>
<ol>
<li><a href="http://jetty.codehaus.org/jetty/" target="_blank">http://jetty.codehaus.org/jetty/</a></li>
<li><a href="http://www.eclipse.org/jetty/downloads.php" target="_blank">http://www.eclipse.org/jetty/downloads.php</a></li>
</ol>
<p>The current stable version is 7, so I downloaded this one from <a href="http://download.eclipse.org/jetty/" target="_blank">Eclipse</a> page.</p>
<p>The compressed file is platform independent. So if you use Mac, Linux or Windows, that is ok, it will run on any OS.</p>
<h2>2 &#8211; Installing</h2>
<p>Simply uncompress the file to a directory. You should have something like this:</p>
<p style="text-align: left;"><a href="http://loianegroner.com/wp-content/uploads/2011/06/Jetty_loiane_01.png" target="_blank"><img class="aligncenter size-full wp-image-1011" title="Jetty_loiane_01" src="http://loianegroner.com/wp-content/uploads/2011/06/Jetty_loiane_01.png" alt="" width="589" height="308" /></a></p>
<p style="text-align: left;">Installation is complete! Let&#8217;s get it running.</p>
<h2 style="text-align: left;">3 &#8211; Running Jetty</h2>
<ol>
<li>Open a terminal.</li>
<li>Go to the Jetty installation directory.</li>
<li>Enter the following command:</li>
</ol>
<pre class="brush: bash; collapse: false; first-line: 1; title: ; toolbar: true; wrap-lines: false; notranslate">
java -jar start.jar
</pre>
<p style="text-align: center;"><a href="http://loianegroner.com/wp-content/uploads/2011/06/Jetty_loiane_13.png" target="_blank"><img class="aligncenter size-full wp-image-1013" title="Jetty_loiane_13" src="http://loianegroner.com/wp-content/uploads/2011/06/Jetty_loiane_13.png" alt="" width="549" height="346" /></a></p>
<p style="text-align: left;">Now open a browser and go to <em>localhost</em> to check if Jetty was installed sucessfully:</p>
<pre class="brush: bash; collapse: false; first-line: 1; title: ; toolbar: true; wrap-lines: false; notranslate">

http://localhost:8080/
</pre>
<p>You should get a page like this:</p>
<p style="text-align: center;"><a href="http://loianegroner.com/wp-content/uploads/2011/06/Jetty_loiane_02.png" target="_blank"><img class="aligncenter size-full wp-image-1014" title="Jetty_loiane_02" src="http://loianegroner.com/wp-content/uploads/2011/06/Jetty_loiane_02.png" alt="" width="589" height="616" /></a></p>
<p>And it is done!</p>
<p>Happy coding!</p>
<div class="shr-publisher-1010"></div><!-- Start Shareaholic LikeButtonSetBottom Automatic --><!-- End Shareaholic LikeButtonSetBottom Automatic --><img src="http://loianegroner.com/?ak_action=api_record_view&id=1010&type=feed" alt="" /><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/LoianeGroner?a=g44UhoieevA:qE5QDvnTLYE:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/LoianeGroner?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/LoianeGroner?a=g44UhoieevA:qE5QDvnTLYE:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/LoianeGroner?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/LoianeGroner?a=g44UhoieevA:qE5QDvnTLYE:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/LoianeGroner?i=g44UhoieevA:qE5QDvnTLYE:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/LoianeGroner?a=g44UhoieevA:qE5QDvnTLYE:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/LoianeGroner?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/LoianeGroner?a=g44UhoieevA:qE5QDvnTLYE:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/LoianeGroner?i=g44UhoieevA:qE5QDvnTLYE:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/LoianeGroner?a=g44UhoieevA:qE5QDvnTLYE:I9og5sOYxJI"><img src="http://feeds.feedburner.com/~ff/LoianeGroner?d=I9og5sOYxJI" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/LoianeGroner/~4/g44UhoieevA" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://loianegroner.com/2011/07/installing-and-running-jetty/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		<feedburner:origLink>http://loianegroner.com/2011/07/installing-and-running-jetty/</feedburner:origLink></item>
		<item>
		<title>Setting Up SSL on Tomcat in 5 minutes (https://localhost:8443)</title>
		<link>http://feedproxy.google.com/~r/LoianeGroner/~3/5yEJ7D0j7B8/</link>
		<comments>http://loianegroner.com/2011/06/setting-up-ssl-on-tomcat-in-5-minutes-httpslocalhost8443/#comments</comments>
		<pubDate>Thu, 30 Jun 2011 09:00:37 +0000</pubDate>
		<dc:creator>Loiane</dc:creator>
				<category><![CDATA[Tomcat]]></category>
		<category><![CDATA[https://localhost:8443]]></category>
		<category><![CDATA[SSL]]></category>

		<guid isPermaLink="false">http://loianegroner.com/?p=993</guid>
		<description><![CDATA[This tutorial will walk you through how to configure SSL (https://localhost:8443 access) on Tomcat in 5 minutes. For this tutorial you will need: Java SDK (used version 6 for this tutorial) Tomcat (used version 7 for this tutorial) The set up consists in 3 basic steps: Create a keystore file using Java Configure Tomcat to [...]]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop Automatic --><!-- End Shareaholic LikeButtonSetTop Automatic --><p>This tutorial will walk you through how to configure <strong>SSL </strong>(<strong>https://localhost:8443</strong> access) on <strong>Tomcat </strong>in 5 minutes.</p>
<p><a href="http://loianegroner.com/wp-content/uploads/2011/06/apache-tomcat.png"><img class="aligncenter size-full wp-image-1001" title="apache-tomcat" src="http://loianegroner.com/wp-content/uploads/2011/06/apache-tomcat.png" alt="" width="208" height="207" /></a></p>
<p>For this tutorial you will need:</p>
<ul>
<li><a href="http://www.oracle.com/technetwork/java/javase/downloads/index.html" target="_blank">Java SDK</a> (used version 6 for this tutorial)</li>
<li><a href="http://tomcat.apache.org/" target="_blank">Tomcat </a>(used version 7 for this tutorial)</li>
</ul>
<p>The set up consists in 3 basic steps:</p>
<ol>
<li>Create a <strong>keystore </strong>file using Java</li>
<li>Configure Tomcat to use the keystore</li>
<li>Test it</li>
<li>(Bonus ) Configure your app to work with SSL (access through https://localhost:8443/yourApp)</li>
</ol>
<h2>1 &#8211; Creating a Keystore file using Java</h2>
<p>Fisrt, open the terminal on your computer and type:</p>
<p><strong>Windows</strong>:</p>
<pre class="brush: bash; collapse: false; first-line: 1; title: ; toolbar: true; wrap-lines: false; notranslate">
cd %JAVA_HOME%/bin
</pre>
<p><strong>Linux or Mac OS</strong>:</p>
<pre class="brush: bash; collapse: false; first-line: 1; title: ; toolbar: true; wrap-lines: false; notranslate">
cd $JAVA_HOME/bin
</pre>
<p>The $JAVA_HOME on Mac is located on &#8220;<strong>/System/Library/Frameworks/JavaVM.framework/Versions/{your java version}/Home/</strong>&#8221;</p>
<p>You will change the current directory to the directory Java is installed on your computer. Inside the Java Home directory, cd to the bin folder. Inside the bin folder there is a file named keytool. This guy is responsible for generating the keystore file for us.</p>
<p>Next, type on the terminal:</p>
<pre class="brush: bash; collapse: false; first-line: 1; title: ; toolbar: true; wrap-lines: false; notranslate">
keytool -genkey -alias tomcat -keyalg RSA
</pre>
<p>When you type the command above, it will ask you some questions. First, it will ask you to create a password (My password is &#8220;<em>password</em>&#8220;):</p>
<pre class="brush: bash; collapse: false; first-line: 1; title: ; toolbar: true; wrap-lines: false; notranslate">
loiane:bin loiane$ keytool -genkey -alias tomcat -keyalg RSA
Enter keystore password:  password
Re-enter new password: password
What is your first and last name?
  [Unknown]:  Loiane Groner
What is the name of your organizational unit?
  [Unknown]:  home
What is the name of your organization?
  [Unknown]:  home
What is the name of your City or Locality?
  [Unknown]:  Sao Paulo
What is the name of your State or Province?
  [Unknown]:  SP
What is the two-letter country code for this unit?
  [Unknown]:  BR
Is CN=Loiane Groner, OU=home, O=home, L=Sao Paulo, ST=SP, C=BR correct?
  [no]:  yes

Enter key password for
	(RETURN if same as keystore password):  password
Re-enter new password: password
</pre>
<p>It will create a .keystore file on your user home directory. On Windows, it will be on: C:\Documents and Settings\[username]; on Mac it will be on /Users/[username] and on Linux will be on /home/[username].</p>
<h2>2 &#8211; Configuring Tomcat for using the keystore file &#8211; SSL config</h2>
<p>Open your Tomcat installation directory and open the <strong><em>conf </em></strong>folder. Inside this folder, you will find the <em><strong>server.xml</strong></em> file. Open it.</p>
<p>Find the following declaration:</p>
<pre class="brush: xml; collapse: false; first-line: 1; title: ; toolbar: true; wrap-lines: false; notranslate">
&lt;!--
&lt;Connector port=&quot;8443&quot; protocol=&quot;HTTP/1.1&quot; SSLEnabled=&quot;true&quot;
    maxThreads=&quot;150&quot; scheme=&quot;https&quot; secure=&quot;true&quot;
    clientAuth=&quot;false&quot; sslProtocol=&quot;TLS&quot; /&gt;
--&gt;
</pre>
<p>Uncomment it and modify it to look like the following:</p>
<pre class="brush: xml; collapse: false; first-line: 1; highlight: [3,4,5]; title: ; toolbar: true; wrap-lines: false; notranslate">
Connector SSLEnabled=&quot;true&quot; acceptCount=&quot;100&quot; clientAuth=&quot;false&quot;
    disableUploadTimeout=&quot;true&quot; enableLookups=&quot;false&quot; maxThreads=&quot;25&quot;
    port=&quot;8443&quot; keystoreFile=&quot;/Users/loiane/.keystore&quot; keystorePass=&quot;password&quot;
    protocol=&quot;org.apache.coyote.http11.Http11NioProtocol&quot; scheme=&quot;https&quot;
    secure=&quot;true&quot; sslProtocol=&quot;TLS&quot; /&gt;
</pre>
<p>Note we add the <em><strong>keystoreFile</strong></em>, <em><strong>keystorePass </strong></em>and changed the <em><strong>protocol </strong></em>declarations.</p>
<h2>3 &#8211; Let&#8217;s test it!</h2>
<p>Start tomcat service and try to access <span style="text-decoration: underline;"><strong>https://localhost:8443</strong></span>. You will see Tomcat&#8217;s local home page.</p>
<p>Note if you try to access the default 8080 port it will be working too: <span style="text-decoration: underline;"><strong>http://localhost:8080</strong></span></p>
<h2>4 &#8211; BONUS - Configuring your app to work with SSL (access through https://localhost:8443/yourApp)</h2>
<p>To force your web application to work with SSL, you simply need to add the following code to your <strong>web.xml</strong> file (before <em>web-app</em> tag ends):</p>
<pre class="brush: xml; collapse: false; first-line: 1; title: ; toolbar: true; wrap-lines: false; notranslate">
&lt;security-constraint&gt;
	&lt;web-resource-collection&gt;
		&lt;web-resource-name&gt;securedapp&lt;/web-resource-name&gt;
		&lt;url-pattern&gt;/*&lt;/url-pattern&gt;
	&lt;/web-resource-collection&gt;
	&lt;user-data-constraint&gt;
		&lt;transport-guarantee&gt;CONFIDENTIAL&lt;/transport-guarantee&gt;
	&lt;/user-data-constraint&gt;
&lt;/security-constraint&gt;
</pre>
<p>The <em><strong>url pattern</strong></em> is set to <strong>/*</strong> so any page/resource from your application is secure (it can be only accessed with <strong>https</strong>). The <em><strong>transport-guarantee</strong></em> tag is set to <strong>CONFIDENTIAL </strong>to make sure your app will work on <strong>SSL</strong>.</p>
<p>If you want to turn off the SSL, you don&#8217;t need to delete the code above from web.xml, simply change <strong>CONFIDENTIAL</strong> to <strong>NONE</strong>.</p>
<p><em><strong>Reference</strong></em>: <a href="http://tomcat.apache.org/tomcat-7.0-doc/ssl-howto.html">http://tomcat.apache.org/tomcat-7.0-doc/ssl-howto.html</a> (this tutorial is a little confusing, that is why I decided to write another one my own).</p>
<p>Happy Coding!</p>
<div class="shr-publisher-993"></div><!-- Start Shareaholic LikeButtonSetBottom Automatic --><!-- End Shareaholic LikeButtonSetBottom Automatic --><img src="http://loianegroner.com/?ak_action=api_record_view&id=993&type=feed" alt="" /><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/LoianeGroner?a=5yEJ7D0j7B8:Z52FQSPfPrc:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/LoianeGroner?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/LoianeGroner?a=5yEJ7D0j7B8:Z52FQSPfPrc:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/LoianeGroner?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/LoianeGroner?a=5yEJ7D0j7B8:Z52FQSPfPrc:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/LoianeGroner?i=5yEJ7D0j7B8:Z52FQSPfPrc:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/LoianeGroner?a=5yEJ7D0j7B8:Z52FQSPfPrc:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/LoianeGroner?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/LoianeGroner?a=5yEJ7D0j7B8:Z52FQSPfPrc:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/LoianeGroner?i=5yEJ7D0j7B8:Z52FQSPfPrc:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/LoianeGroner?a=5yEJ7D0j7B8:Z52FQSPfPrc:I9og5sOYxJI"><img src="http://feeds.feedburner.com/~ff/LoianeGroner?d=I9og5sOYxJI" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/LoianeGroner/~4/5yEJ7D0j7B8" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://loianegroner.com/2011/06/setting-up-ssl-on-tomcat-in-5-minutes-httpslocalhost8443/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://loianegroner.com/2011/06/setting-up-ssl-on-tomcat-in-5-minutes-httpslocalhost8443/</feedburner:origLink></item>
		<item>
		<title>JAXB Custom Binding – Java.util.Date / Spring 3 Serialization</title>
		<link>http://feedproxy.google.com/~r/LoianeGroner/~3/W3ApGZSHOzo/</link>
		<comments>http://loianegroner.com/2011/06/jaxb-custom-binding-java-util-date-spring-3-serialization/#comments</comments>
		<pubDate>Tue, 07 Jun 2011 09:00:45 +0000</pubDate>
		<dc:creator>Loiane</dc:creator>
				<category><![CDATA[Spring]]></category>
		<category><![CDATA[@XmlJavaTypeAdapter]]></category>
		<category><![CDATA[java.util.Date]]></category>
		<category><![CDATA[JAXB]]></category>
		<category><![CDATA[JAXB Custom Binding]]></category>
		<category><![CDATA[Spring 3]]></category>
		<category><![CDATA[XmlAdapter]]></category>

		<guid isPermaLink="false">http://loianegroner.com/?p=976</guid>
		<description><![CDATA[JaxB can handle Java.util.Date serialization, but it expects the following format: &#8220;yyyy-MM-ddTHH:mm:ss&#8220;. What if you need to format the date object in another format? I had the same issue when I was working with Spring MVc 3 and Jackson JSON Processor, and recently, I faced the same issue working with Spring MVC 3 and JAXB [...]]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop Automatic --><!-- End Shareaholic LikeButtonSetTop Automatic --><p style="text-align: justify;"><a href="http://jaxb.java.net/" target="_blank"></a><a href="http://loianegroner.com/wp-content/uploads/2011/05/111-jaxb.gif"><img class="alignleft size-full wp-image-983" title="111-jaxb" src="http://loianegroner.com/wp-content/uploads/2011/05/111-jaxb.gif" alt="" width="111" height="91" /></a><a href="http://jaxb.java.net/" target="_blank">JaxB </a>can handle <strong><em>Java.util.Date</em></strong> serialization, but it expects the following format: <em><strong>&#8220;yyyy-MM-ddTHH:mm:ss</strong></em>&#8220;. What if you need to format the date object in another format?</p>
<p style="text-align: justify;">I <a href="http://loianegroner.com/2010/09/how-to-serialize-java-util-date-with-jackson-json-processor-spring-3-0/" target="_blank">had the same issue</a> when I was working with <a href="http://loianegroner.com/2010/09/how-to-serialize-java-util-date-with-jackson-json-processor-spring-3-0/" target="_blank">Spring MVc 3 and Jackson JSON Processor</a>, and recently, I faced the same issue working with Spring MVC 3 and <a href="http://jaxb.java.net/" target="_blank">JAXB for XML serialization</a>.</p>
<p style="text-align: justify;">Let&#8217;s digg into the issue:</p>
<h2 style="text-align: justify;">Problem:</h2>
<p style="text-align: justify;">I have the following Java Beans which I want to serialize in XML using Spring MVC 3:</p>
<pre class="brush: java; collapse: false; first-line: 1; title: ; toolbar: true; wrap-lines: false; notranslate">
package com.loiane.model;

import java.util.Date;

public class Company {

	private int id;

	private String company;

	private double price;

	private double change;

	private double pctChange;

	private Date lastChange;

	//getters and setters
</pre>
<p style="text-align: justify;">And I have another object which is going to wrap the POJO above:</p>
<pre class="brush: java; collapse: false; first-line: 1; title: ; toolbar: true; wrap-lines: false; notranslate">
package com.loiane.model;

import java.util.List;

import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;

@XmlRootElement(name=&quot;companies&quot;)
public class Companies {

	@XmlElement(required = true)
	private List&lt;Company&gt; list;

	public void setList(List&lt;Company&gt; list) {
		this.list = list;
	}
}
</pre>
<p style="text-align: justify;">In my Spring controller, I&#8217;m going to return a List of Company through the the <em><strong>@ResponseBody</strong></em> annotation &#8211; which is going to serialize the object automatically with JaxB:</p>
<pre class="brush: java; collapse: false; first-line: 1; title: ; toolbar: true; wrap-lines: false; notranslate">
@RequestMapping(value=&quot;/company/view.action&quot;)
public @ResponseBody Companies view() throws Exception {}
</pre>
<p style="text-align: justify;">When I call the controller method, this is what it returns to the view:</p>
<pre class="brush: xml; collapse: false; first-line: 1; highlight: [6,14]; title: ; toolbar: true; wrap-lines: false; notranslate">
&lt;companies&gt;
	&lt;list&gt;
		&lt;change&gt;0.02&lt;/change&gt;
		&lt;company&gt;3m Co&lt;/company&gt;
		&lt;id&gt;1&lt;/id&gt;
		&lt;lastChange&gt;2011-09-01T00:00:00-03:00&lt;/lastChange&gt;
		&lt;pctChange&gt;0.03&lt;/pctChange&gt;
		&lt;price&gt;71.72&lt;/price&gt;
	&lt;/list&gt;
	&lt;list&gt;
		&lt;change&gt;0.42&lt;/change&gt;
		&lt;company&gt;Alcoa Inc&lt;/company&gt;
		&lt;id&gt;2&lt;/id&gt;
		&lt;lastChange&gt;2011-09-01T00:00:00-03:00&lt;/lastChange&gt;
		&lt;pctChange&gt;1.47&lt;/pctChange&gt;
		&lt;price&gt;29.01&lt;/price&gt;
	&lt;/list&gt;
&lt;/companies&gt;
</pre>
<p style="text-align: justify;">Note the date format. It is not the format I expect it to return. I need to serialize the date in the following format: &#8220;<em><strong>MM-dd-yyyy</strong></em>&#8220;</p>
<h2 style="text-align: justify;">Solution:</h2>
<p style="text-align: justify;">I need to create a class extending the <em><strong>XmlAdapter </strong></em>and override the <em><strong>marshal </strong></em>and <em><strong>unmarshal </strong></em>methods and in these methods I am going to format the date as I need to:</p>
<pre class="brush: java; collapse: false; first-line: 1; title: ; toolbar: true; wrap-lines: false; notranslate">
package com.loiane.util;

import java.text.SimpleDateFormat;
import java.util.Date;

import javax.xml.bind.annotation.adapters.XmlAdapter;

public class JaxbDateSerializer extends XmlAdapter&lt;String, Date&gt;{

	private SimpleDateFormat dateFormat = new SimpleDateFormat(&quot;MM-dd-yyyy&quot;);

    @Override
    public String marshal(Date date) throws Exception {
        return dateFormat.format(date);
    }

    @Override
    public Date unmarshal(String date) throws Exception {
        return dateFormat.parse(date);
    }
}
</pre>
<p style="text-align: justify;">And in my Java Bean class, I simply need to add the <em><strong>@XmlJavaTypeAdapter</strong></em> annotation in the get method of the date property.</p>
<pre class="brush: java; collapse: false; first-line: 1; highlight: [23]; title: ; toolbar: true; wrap-lines: false; notranslate">
package com.loiane.model;

import java.util.Date;

import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;

import com.loiane.util.JaxbDateSerializer;

public class Company {

	private int id;

	private String company;

	private double price;

	private double change;

	private double pctChange;

	private Date lastChange;

	@XmlJavaTypeAdapter(JaxbDateSerializer.class)
	public Date getLastChange() {
		return lastChange;
	}
	//getters and setters
}
</pre>
<p style="text-align: justify;">If we try to call the controller method again, it is going to return the following XML:</p>
<pre class="brush: xml; collapse: false; first-line: 1; highlight: [6,14]; title: ; toolbar: true; wrap-lines: false; notranslate">
&lt;companies&gt;
	&lt;list&gt;
		&lt;change&gt;0.02&lt;/change&gt;
		&lt;company&gt;3m Co&lt;/company&gt;
		&lt;id&gt;1&lt;/id&gt;
		&lt;lastChange&gt;09-01-2011&lt;/lastChange&gt;
		&lt;pctChange&gt;0.03&lt;/pctChange&gt;
		&lt;price&gt;71.72&lt;/price&gt;
	&lt;/list&gt;
	&lt;list&gt;
		&lt;change&gt;0.42&lt;/change&gt;
		&lt;company&gt;Alcoa Inc&lt;/company&gt;
		&lt;id&gt;2&lt;/id&gt;
		&lt;lastChange&gt;09-01-2011&lt;/lastChange&gt;
		&lt;pctChange&gt;1.47&lt;/pctChange&gt;
		&lt;price&gt;29.01&lt;/price&gt;
	&lt;/list&gt;
&lt;/companies&gt;
</pre>
<p style="text-align: justify;">Problem solved!</p>
<p style="text-align: justify;">Happy Coding! <img src='http://loianegroner.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<div class="shr-publisher-976"></div><!-- Start Shareaholic LikeButtonSetBottom Automatic --><!-- End Shareaholic LikeButtonSetBottom Automatic --><img src="http://loianegroner.com/?ak_action=api_record_view&id=976&type=feed" alt="" /><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/LoianeGroner?a=W3ApGZSHOzo:QThLUysAk_g:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/LoianeGroner?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/LoianeGroner?a=W3ApGZSHOzo:QThLUysAk_g:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/LoianeGroner?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/LoianeGroner?a=W3ApGZSHOzo:QThLUysAk_g:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/LoianeGroner?i=W3ApGZSHOzo:QThLUysAk_g:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/LoianeGroner?a=W3ApGZSHOzo:QThLUysAk_g:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/LoianeGroner?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/LoianeGroner?a=W3ApGZSHOzo:QThLUysAk_g:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/LoianeGroner?i=W3ApGZSHOzo:QThLUysAk_g:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/LoianeGroner?a=W3ApGZSHOzo:QThLUysAk_g:I9og5sOYxJI"><img src="http://feeds.feedburner.com/~ff/LoianeGroner?d=I9og5sOYxJI" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/LoianeGroner/~4/W3ApGZSHOzo" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://loianegroner.com/2011/06/jaxb-custom-binding-java-util-date-spring-3-serialization/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		<feedburner:origLink>http://loianegroner.com/2011/06/jaxb-custom-binding-java-util-date-spring-3-serialization/</feedburner:origLink></item>
		<item>
		<title>IBatis (MyBatis): Working with Stored Procedures</title>
		<link>http://feedproxy.google.com/~r/LoianeGroner/~3/I2bmSbGxsvQ/</link>
		<comments>http://loianegroner.com/2011/03/ibatis-mybatis-working-with-stored-procedures/#comments</comments>
		<pubDate>Tue, 29 Mar 2011 10:00:39 +0000</pubDate>
		<dc:creator>Loiane</dc:creator>
				<category><![CDATA[iBatis (MyBatis)]]></category>
		<category><![CDATA[iBatis]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[MyBatis]]></category>
		<category><![CDATA[mySQL]]></category>
		<category><![CDATA[stored procedure]]></category>

		<guid isPermaLink="false">http://loianegroner.com/?p=807</guid>
		<description><![CDATA[This tutorial will walk you through how to setup iBatis (MyBatis) in a simple Java project and will present how to work with stored procedures using MySQL. The goal os this tutorial is to demonstrate how to execute/call stored procedures using iBatis/MyBatis. Pre-Requisites For this tutorial I am using: IDE: Eclipse (you can use your favorite one) [...]]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop Automatic --><!-- End Shareaholic LikeButtonSetTop Automatic --><div>
<p style="text-align: justify;">This tutorial will walk you through how to setup <a href="http://www.mybatis.org/" target="_blank">iBatis</a> (<a href="http://www.mybatis.org/" target="_blank">MyBatis</a>) in a simple Java project and will present how to work with stored procedures using MySQL.</p>
<p style="text-align: justify;">The goal os this tutorial is to demonstrate how to execute/call stored procedures using iBatis/MyBatis.</p>
<p style="text-align: justify;"><a href="http://loianegroner.com/wp-content/uploads/2011/01/ibatis_mybatis_loiane.png"><img class="aligncenter" title="ibatis_mybatis_loiane" src="http://loianegroner.com/wp-content/uploads/2011/01/ibatis_mybatis_loiane.png" alt="" width="274" height="149" /></a></p>
<p style="text-align: justify;"><a href="http://loianegroner.com/wp-content/uploads/2011/01/ibatis_mybatis_loiane.png"></a></p>
<h2 style="text-align: justify;">Pre-Requisites</h2>
<p style="text-align: justify;">For this tutorial I am using:</p>
<p style="text-align: justify;">IDE: <a href="http://eclipse.org/" target="_blank">Eclipse</a> (you can use your favorite one)<br />
DataBase: <a href="http://dev.mysql.com/downloads/" target="_blank">MySQL</a><br />
Libs/jars: <a href="http://www.mybatis.org/" target="_blank">Mybatis</a>, <a href="http://dev.mysql.com/downloads/" target="_blank">MySQL</a> conector and <a href="http://www.junit.org/" target="_blank">JUnit</a> (for testing)</p>
<p style="text-align: justify;">This is how your project should look like:</p>
<p style="text-align: justify;"><a href="http://loianegroner.com/wp-content/uploads/2011/03/ibatis_mybatis_loiane_stored_procedures_project.png"><img class="aligncenter size-full wp-image-959" title="ibatis_mybatis_loiane_stored_procedures_project" src="http://loianegroner.com/wp-content/uploads/2011/03/ibatis_mybatis_loiane_stored_procedures_project.png" alt="" width="318" height="443" /></a></p>
<p style="text-align: justify;"><a href="http://loianegroner.com/wp-content/uploads/2011/02/ibatis_mybatis_loiane_handling_joins.png"></a></p>
<h2 style="text-align: justify;">Sample Database</h2>
<p style="text-align: justify;">Please run the script into your database before getting started with the project implementation. You will find the script (with dummy data) inside the sql folder.</p>
<p style="text-align: justify;"><a href="http://loianegroner.com/wp-content/uploads/2011/03/ibatis_mybatis_loiane_stored_procedures.png"><img class="aligncenter size-full wp-image-960" title="ibatis_mybatis_loiane_stored_procedures" src="http://loianegroner.com/wp-content/uploads/2011/03/ibatis_mybatis_loiane_stored_procedures.png" alt="" width="559" height="148" /></a></p>
<p style="text-align: justify;">As we are going to work with stored procedures, you will also have to execute a script with procedures. Here are the procedures:</p>
<pre class="brush: sql; collapse: false; first-line: 1; title: ; toolbar: true; wrap-lines: false; notranslate">
USE `blog_ibatis`;
DROP procedure IF EXISTS `getTotalCity`;
DELIMITER $$
USE `blog_ibatis`$$
CREATE PROCEDURE `blog_ibatis`.`getTotalCity` (OUT total INTEGER)
BEGIN
    SELECT count(*) into total
    FROM city;
END
$$
DELIMITER ;

-- --------------------------------------------------------------------------------

USE `blog_ibatis`;
DROP procedure IF EXISTS `getTotalCityStateId`;
DELIMITER $$
USE `blog_ibatis`$$
CREATE PROCEDURE `blog_ibatis`.`getTotalCityStateId` (IN stateId SMALLINT, OUT total INTEGER)
BEGIN
    SELECT count(*) into total
    FROM city
    WHERE state_id = stateId;
END
$$
DELIMITER ;

-- --------------------------------------------------------------------------------

USE `blog_ibatis`;
DROP procedure IF EXISTS `getStates`;
DELIMITER $$
USE `blog_ibatis`$$
CREATE PROCEDURE `blog_ibatis`.`getStates` ()
BEGIN
    SELECT state_id, state_code, state_name
    FROM state;
END
$$
DELIMITER ;
</pre>
<h2 style="text-align: justify;">1 &#8211; SPMapper &#8211; XML</h2>
<p style="text-align: justify;">I did not find anything on the user manual about how to call stored procedures, so I decided to search on the mailing list. And I found some tips of how to call stores procedures.</p>
<p style="text-align: justify;">On the previous version, iBatis has a special XML tag for stored procedures. But there is no XML tag for it on current MyBatis version (version 3).</p>
<p style="text-align: justify;">To call a stored procedure usgin MyBatis/iBatis 3 you will have to follow some tips:</p>
<ol style="text-align: justify;">
<li style="text-align: justify;">Must set the statement type to <strong>CALLABLE </strong></li>
<li style="text-align: justify;">Must use the JDBC standard escape sequence for stored procedures: 		{<strong>call xxx (parm1, parm2)</strong>}</li>
<li style="text-align: justify;">Must set the <strong>MODE </strong>of all parameters (<strong>IN, OUT, INOUT</strong>)</li>
<li style="text-align: justify;">All IN, OUT, and INOUT parameters must be a part of the <strong>parameterType </strong>or parameterMap (discouraged). 		The only exception is if you are using a Map 		as a parameter object. In that case you <strong>do not need to add OUT parameters 		to the map before calling</strong>, MyBatis will add them for you automatically.</li>
<li style="text-align: justify;">resultType or resultMap (more typically) is only used if the procedure returns 		a result set.</li>
<li style="text-align: justify;"><em><strong>IMPORTANT</strong></em>: Oracle ref cursors are usually returned as parameters, 		NOT directly from the stored proc. So with ref cursors, resultMap and/or 		resultType is usually not used.</li>
</ol>
<h3 style="text-align: justify;">First Example:</h3>
<p style="text-align: justify;">We want to call the procedure <em>getTotalCity </em>and this procedure only have one OUT parameter, and no IN/INOUT parameter. How to do it?</p>
<p style="text-align: justify;">We are going to ser inline parameters in this first example. To use inline parameters, create a POJO class to represent your parameters, set the parameterType to the class you created and you are going to use this notation to represent each parameter:</p>
<p style="text-align: justify;"><em><strong>#{parameterName, mode=OUT, jdbcType=INTEGER}</strong></em></p>
<ul style="text-align: justify;">
<li>mode can be IN, OUT, INOUT</li>
<li>and specify the jdbcType of your parameter</li>
</ul>
<p style="text-align: justify;">To create the Mybatis XML configuration, you can use the <strong>select </strong>ou <strong>update </strong>tag. Do not forget to set the statementType to <span style="text-decoration: underline;"><em><strong>CALLABLE</strong></em></span>.</p>
<p style="text-align: justify;">Here is how our MyBatis statement is going to look like:</p>
<pre class="brush: xml; collapse: false; first-line: 1; title: ; toolbar: true; wrap-lines: false; notranslate">
&lt;select id=&quot;callGetTotalCity&quot; parameterType=&quot;Param&quot; statementType=&quot;CALLABLE&quot;&gt;
	{ CALL getTotalCity(#{total, mode=OUT, jdbcType=INTEGER})}
&lt;/select&gt;
</pre>
<p style="text-align: justify;">And this is the POJO class which represents the parameter for <em>getTotalCity </em>procedure:</p>
<pre class="brush: java; collapse: false; first-line: 1; title: ; toolbar: true; wrap-lines: false; notranslate">
package com.loiane.model;

public class Param {

	private int total;

	public int getTotal() {
		return total;
	}

	public void setTotal(int total) {
		this.total = total;
	}
}
</pre>
<h3 style="text-align: justify;">Second Example:</h3>
<p style="text-align: justify;">Now we are going to try to call the same stored procedure we demonstrated on the first example, but we are going to use a parameterMap, like you used to do in version 2.x.</p>
<p style="text-align: justify;">A very important note: this is discouraged, please use inline parameters.</p>
<p style="text-align: justify;">Let&#8217;s declare the Param POJO class as a parameterMap:</p>
<pre class="brush: xml; collapse: false; first-line: 1; title: ; toolbar: true; wrap-lines: false; notranslate">
&lt;parameterMap type=&quot;Param&quot; id=&quot;testParameterMap&quot;&gt;
	&lt;parameter property=&quot;total&quot; jdbcType=&quot;INTEGER&quot; mode=&quot;OUT&quot; /&gt;
&lt;/parameterMap&gt;
</pre>
<p style="text-align: justify;">And the stored procedure statment:</p>
<pre class="brush: xml; collapse: false; first-line: 1; title: ; toolbar: true; wrap-lines: false; notranslate">
&lt;update id=&quot;callGetTotalCity2&quot; parameterMap=&quot;testParameterMap&quot; statementType=&quot;CALLABLE&quot;&gt;
    { CALL getTotalCity(?) }
&lt;/update&gt;
</pre>
<p style="text-align: justify;">Note that now we use &#8220;<strong><em>?</em></strong>&#8221; (question mark) to represent each parameter.</p>
<h3 style="text-align: justify;">Third Example:</h3>
<p style="text-align: justify;">Now we are going to call a stored procedure with IN and OUT parameters. Let&#8217;s follow the same rules as the fisrt example.</p>
<p style="text-align: justify;">We are going to use inline parameters and we are going to create a POJO class to represent our parameter.</p>
<p style="text-align: justify;">MyBatis code:</p>
<pre class="brush: xml; collapse: false; first-line: 1; title: ; toolbar: true; wrap-lines: false; notranslate">
&lt;select id=&quot;callGetTotalCityStateId&quot; parameterType=&quot;Param2&quot; statementType=&quot;CALLABLE&quot;&gt;
   	{ CALL getTotalCityStateId(
    	#{stateId, mode=IN, jdbcType=INTEGER},
    	#{total, mode=OUT, jdbcType=INTEGER})}
&lt;/select&gt;
</pre>
<p style="text-align: justify;">Param2 POJO:</p>
<pre class="brush: java; collapse: false; first-line: 1; title: ; toolbar: true; wrap-lines: false; notranslate">
package com.loiane.model;

public class Param2 {

	private int total;
	private int stateId;

	public int getTotal() {
		return total;
	}
	public void setTotal(int total) {
		this.total = total;
	}
	public int getStateId() {
		return stateId;
	}
	public void setStateId(int stateId) {
		this.stateId = stateId;
	}
}
</pre>
<h3 style="text-align: justify;">Fourth Example:</h3>
<p style="text-align: justify;">Now let&#8217;s try to retrieve a resultSet from the stored procedure. For this we are going to use a resultMap.</p>
<pre class="brush: xml; collapse: false; first-line: 1; title: ; toolbar: true; wrap-lines: false; notranslate">
&lt;resultMap type=&quot;State&quot; id=&quot;resultState&quot;&gt;
	&lt;result property=&quot;id&quot; column=&quot;state_id&quot;/&gt;
    &lt;result property=&quot;name&quot; column=&quot;state_name&quot;/&gt;
    &lt;result property=&quot;code&quot; column=&quot;state_code&quot;/&gt;
&lt;/resultMap&gt;

&lt;select id=&quot;callGetStates&quot; resultMap=&quot;resultState&quot; statementType=&quot;CALLABLE&quot;&gt;
   	{ CALL getStates()}
&lt;/select&gt;
</pre>
<p style="text-align: justify;">State POJO class:</p>
<pre class="brush: java; collapse: false; first-line: 1; title: ; toolbar: true; wrap-lines: false; notranslate">
package com.loiane.model;

public class State {

	private int id;
	private String code;
	private String name;

	public int getId() {
		return id;
	}
	public void setId(int id) {
		this.id = id;
	}
	public String getCode() {
		return code;
	}
	public void setCode(String code) {
		this.code = code;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
}
</pre>
<h2 style="text-align: justify;">2- SPMapper &#8211; Annotations</h2>
<p style="text-align: justify;">Now let&#8217;s try to do the same thing we did using XML config.</p>
<h3 style="text-align: justify;">Annotation for First Example (XML):</h3>
<pre class="brush: java; collapse: false; first-line: 1; title: ; toolbar: true; wrap-lines: false; notranslate">
@Select(value= &quot;{ CALL getTotalCity( #{total, mode=OUT, jdbcType=INTEGER} )}&quot;)
@Options(statementType = StatementType.CALLABLE)
Object callGetTotalCityAnnotations(Param param);
</pre>
<p style="text-align: justify;">It is very similiar to a simple select statement, but we have to set the statement type to CALLABLE. To do it, we can use the annotation <em><strong>@Options</strong></em>.</p>
<p style="text-align: justify;">With annotations, we can only use inline parameters, so we will not be able to represent the second exemple using annotations.</p>
<h3 style="text-align: justify;">Annotation for Third Example (XML):</h3>
<p style="text-align: justify;">The explanation is the same as first example, I am just going to list the code:</p>
<pre class="brush: java; collapse: false; first-line: 1; title: ; toolbar: true; wrap-lines: false; notranslate">
@Select(value= &quot;{ CALL getTotalCityStateId( #{stateId, mode=IN, jdbcType=INTEGER}, #{total, mode=OUT, jdbcType=INTEGER})}&quot;)
@Options(statementType = StatementType.CALLABLE)
Object callGetTotalCityStateIdAnnotations(Param2 param2);
</pre>
<h3 style="text-align: justify;">Annotation for Fourth Example (XML):</h3>
<p style="text-align: justify;">I tried to set the fourth example with annotation, but the only thing I&#8217;ve got is this:</p>
<pre class="brush: java; collapse: false; first-line: 1; title: ; toolbar: true; wrap-lines: false; notranslate">
//TODO: set resultMap with annotations
/*@Select(value= &quot;{ CALL getTotalCityStateId()}&quot;)
@Options(statementType = StatementType.CALLABLE)
/*@Results(value = {
	@Result(property=&quot;id&quot;, column=&quot;state_id&quot;),
	@Result(property=&quot;name&quot;, column=&quot;state_name&quot;),
	@Result(property=&quot;code&quot;, column=&quot;state_code&quot;),
})*/
List&lt;State&gt; callGetStatesAnnotations();
</pre>
<p style="text-align: justify;">And it does not work. I tried to search on the mailing list, no luck. I could not find a way to represent a resultMap with annotation and stored procedures. I don&#8217;t know if it is a limitation. If you have any clue how to do it, please leave a comment, I will appreciate it! <img src='http://loianegroner.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<h2 style="text-align: justify;">Download</h2>
</div>
<div>
<p style="text-align: justify;">If you want to download the complete sample project, you can get it from my GitHub account: <a href="https://github.com/loiane/ibatis-dynamic-sql" target="_blank"></a><a href="https://github.com/loiane/ibatis-stored-procedures" target="_blank">https://github.com/loiane/ibatis-stored-procedures</a></p>
<p style="text-align: justify;">If you want to download the zip file of the project, just click on download:</p>
<p style="text-align: justify;"><a href="http://loianegroner.com/wp-content/uploads/2011/01/donwload-github-example-loiane.png" target="_blank"><img class="aligncenter" title="donwload-github-example-loiane" src="http://loianegroner.com/wp-content/uploads/2011/01/donwload-github-example-loiane.png" alt="" width="572" height="219" /></a></p>
<p style="text-align: justify;"><a href="http://loianegroner.com/wp-content/uploads/2011/01/donwload-github-example-loiane.png" target="_blank"></a></p>
<p style="text-align: justify;">There are more articles about iBatis to come. Stay tooned!</p>
<p style="text-align: justify;">Happy Coding! <img src='http://loianegroner.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
</div>
<div class="shr-publisher-807"></div><!-- Start Shareaholic LikeButtonSetBottom Automatic --><!-- End Shareaholic LikeButtonSetBottom Automatic --><img src="http://loianegroner.com/?ak_action=api_record_view&id=807&type=feed" alt="" /><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/LoianeGroner?a=I2bmSbGxsvQ:-BptHDcFrpY:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/LoianeGroner?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/LoianeGroner?a=I2bmSbGxsvQ:-BptHDcFrpY:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/LoianeGroner?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/LoianeGroner?a=I2bmSbGxsvQ:-BptHDcFrpY:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/LoianeGroner?i=I2bmSbGxsvQ:-BptHDcFrpY:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/LoianeGroner?a=I2bmSbGxsvQ:-BptHDcFrpY:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/LoianeGroner?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/LoianeGroner?a=I2bmSbGxsvQ:-BptHDcFrpY:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/LoianeGroner?i=I2bmSbGxsvQ:-BptHDcFrpY:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/LoianeGroner?a=I2bmSbGxsvQ:-BptHDcFrpY:I9og5sOYxJI"><img src="http://feeds.feedburner.com/~ff/LoianeGroner?d=I9og5sOYxJI" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/LoianeGroner/~4/I2bmSbGxsvQ" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://loianegroner.com/2011/03/ibatis-mybatis-working-with-stored-procedures/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		<feedburner:origLink>http://loianegroner.com/2011/03/ibatis-mybatis-working-with-stored-procedures/</feedburner:origLink></item>
		<item>
		<title>IBatis (MyBatis): Working with Dynamic Queries (SQL)</title>
		<link>http://feedproxy.google.com/~r/LoianeGroner/~3/cIjwdGGhK-A/</link>
		<comments>http://loianegroner.com/2011/03/ibatis-mybatis-working-with-dynamic-queries-sql/#comments</comments>
		<pubDate>Tue, 22 Mar 2011 10:00:33 +0000</pubDate>
		<dc:creator>Loiane</dc:creator>
				<category><![CDATA[iBatis (MyBatis)]]></category>
		<category><![CDATA[choose]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[dynamic sql]]></category>
		<category><![CDATA[forEach]]></category>
		<category><![CDATA[iBatis]]></category>
		<category><![CDATA[if]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[MyBatis]]></category>
		<category><![CDATA[mySQL]]></category>
		<category><![CDATA[trim]]></category>
		<category><![CDATA[where]]></category>

		<guid isPermaLink="false">http://loianegroner.com/?p=781</guid>
		<description><![CDATA[This tutorial will walk you through how to setup iBatis (MyBatis) in a simple Java project and will present how to work with dynamic queries (SQL). Pre-Requisites For this tutorial I am using: IDE: Eclipse (you can use your favorite one) DataBase: MySQL Libs/jars: Mybatis, MySQL conector and JUnit (for testing) This is how your project should look like: Sample Database [...]]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop Automatic --><!-- End Shareaholic LikeButtonSetTop Automatic --><div>
<p>This tutorial will walk you through how to setup <a href="http://www.mybatis.org/" target="_blank">iBatis</a> (<a href="http://www.mybatis.org/" target="_blank">MyBatis</a>) in a simple Java project and will present how to work with dynamic queries (SQL).</p>
<p style="text-align: center;"><a href="http://loianegroner.com/wp-content/uploads/2011/01/ibatis_mybatis_loiane.png"><img class="size-full wp-image-685 aligncenter" title="ibatis_mybatis_loiane" src="http://loianegroner.com/wp-content/uploads/2011/01/ibatis_mybatis_loiane.png" alt="" width="274" height="149" /></a></p>
<p><a href="http://loianegroner.com/wp-content/uploads/2011/01/ibatis_mybatis_loiane.png"></a></p>
<h2>Pre-Requisites</h2>
<p>For this tutorial I am using:</p>
<p>IDE: <a href="http://eclipse.org/" target="_blank">Eclipse</a> (you can use your favorite one)<br />
DataBase: <a href="http://dev.mysql.com/downloads/" target="_blank">MySQL</a><br />
Libs/jars: <a href="http://www.mybatis.org/" target="_blank">Mybatis</a>, <a href="http://dev.mysql.com/downloads/" target="_blank">MySQL</a> conector and <a href="http://www.junit.org/" target="_blank">JUnit</a> (for testing)</p>
<p>This is how your project should look like:</p>
<p><a href="http://loianegroner.com/wp-content/uploads/2011/02/ibatis_mybatis_loiane_dynamicsql.png"><img class="aligncenter size-full wp-image-893" title="ibatis_mybatis_loiane_dynamicsql" src="http://loianegroner.com/wp-content/uploads/2011/02/ibatis_mybatis_loiane_dynamicsql.png" alt="" width="255" height="372" /></a></p>
<p><a href="http://loianegroner.com/wp-content/uploads/2011/02/ibatis_mybatis_loiane_handling_joins.png"></a></p>
<h2>Sample Database</h2>
<p>Please run the script into your database before getting started with the project implementation. You will find the script (with dummy data) inside the sql folder.</p>
<p style="text-align: center;"><a href="http://loianegroner.com/wp-content/uploads/2011/02/dynamic_sql_ibatis_loiane.png" target="_blank"><img class="aligncenter size-full wp-image-894" title="dynamic_sql_ibatis_loiane" src="http://loianegroner.com/wp-content/uploads/2011/02/dynamic_sql_ibatis_loiane.png" alt="" width="503" height="286" /></a></p>
<h2>1 &#8211; Article POJO</h2>
<p style="text-align: justify;">I represented the pojo we are going to use in this tutorial with a UML diagram, but you can download the complete source code in the end of this article.</p>
<p style="text-align: center;"><img class="size-full wp-image-895 aligncenter" title="ibatis_mybatis_loiane_dyanmicsql_uml" src="http://loianegroner.com/wp-content/uploads/2011/02/ibatis_mybatis_loiane_dyanmicsql_uml.png" alt="" width="130" height="107" /></p>
<p><a href="http://loianegroner.com/wp-content/uploads/2011/02/ibatis_mybatis_loiane_uml_handlingjoins.png"></a></p>
<p>The goal of this tutorial is to demonstrate how to retrieve the article information from database using dynamic sql to filter the data.</p>
<h2>2 &#8211; Article Mapper &#8211; XML</h2>
<blockquote>
<p style="text-align: justify;">One of the most powerful features of MyBatis has always been its Dynamic SQL capabilities. If you have any experience with JDBC or any similar framework, you understand how painful it is to conditionally concatenate strings of SQL together, making sure not to forget spaces or to omit a comma at the end of a list of columns. Dynamic SQL can be downright painful to deal with.</p>
<p style="text-align: justify;">While working with Dynamic SQL will never be a party, MyBatis certainly improves the situation with a powerful Dynamic SQL language that can be used within any mapped SQL statement.</p>
<p style="text-align: justify;">The Dynamic SQL elements should be familiar to anyone who has used JSTL or any similar XML based text processors. In previous versions of MyBatis, there were a lot of elements to know and understand. MyBatis 3 greatly improves upon this, and now there are less than half of those elements to work with. MyBatis employs powerful OGNL based expressions to eliminate most of the other elements.</p>
<ul>
<li style="text-align: justify;">if</li>
<li>choose (when, otherwise)</li>
<li>trim (where, set)</li>
<li>foreach</li>
</ul>
</blockquote>
</div>
<p>Let&#8217;s explain each one with examples.</p>
<p><strong>1 &#8211; First scenario</strong>: we want to retrieve all the articles from database with an optional filter: title. In other words, if user specify an article title, we are going to retrieve the articles that match with the title, otherwise we are going to retrieve all the articles from database. So we are going to implement a <strong>condition (if)</strong>:</p>
<pre class="brush: xml; collapse: false; first-line: 1; title: ; toolbar: true; wrap-lines: false; notranslate">
&lt;select id=&quot;selectArticleByTitle&quot; parameterType=&quot;com.loiane.model.Article&quot;
	resultType=&quot;Article&quot;&gt;
	SELECT id, title, author
	FROM article
	WHERE id_status = 1
	&lt;if test=&quot;title != null&quot;&gt;
		AND title LIKE #{title}
	&lt;/if&gt;
&lt;/select&gt;
</pre>
<p><strong>2 &#8211; Second scenario</strong>: Now we have two optional filters: article title and author. The user can specify both, none or only one filter. So we are going to implement two conditions:</p>
<pre class="brush: xml; collapse: false; first-line: 1; title: ; toolbar: true; wrap-lines: false; notranslate">
&lt;select id=&quot;selectArticleByTitleAndAuthor&quot; parameterType=&quot;com.loiane.model.Article&quot;
	resultType=&quot;Article&quot;&gt;
	SELECT id, title, author
	FROM article
	WHERE id_status = 1
	&lt;if test=&quot;title != null&quot;&gt;
		AND title LIKE #{title}
	&lt;/if&gt;
	&lt;if test=&quot;author != null&quot;&gt;
		AND author LIKE #{author}
	&lt;/if&gt;
&lt;/select&gt;
</pre>
<p><strong>3 &#8211; Third scenario</strong>: Now we want to give the user only one option: the user will have to specify only one of the following filters: title, author or retrieve all the articles from iBatis category. So we are going to use a <strong>Choose</strong> element:</p>
<pre class="brush: xml; collapse: false; first-line: 1; title: ; toolbar: true; wrap-lines: false; notranslate">
&lt;select id=&quot;selectArticleByTitleOrAuthorOrCategory&quot;
	parameterType=&quot;com.loiane.model.Article&quot; resultType=&quot;Article&quot;&gt;
	SELECT id, title, author
	FROM article
	WHERE id_status = 1
	&lt;choose&gt;
		&lt;when test=&quot;title != null&quot;&gt;
			AND title LIKE #{title}
		&lt;/when&gt;
		&lt;when test=&quot;author != null&quot;&gt;
			AND author LIKE #{author}
		&lt;/when&gt;
		&lt;otherwise&gt;
			AND id_category = 3
		&lt;/otherwise&gt;
	&lt;/choose&gt;
&lt;/select&gt;
</pre>
<p><strong>4 &#8211; Fourth scenario</strong>: take a look at all three statements above. They all have a condition in common: WHERE id_status = 1. It means we are already filtering the active articles Let&#8217;s remove this condition to make it more interesting.</p>
<pre class="brush: xml; collapse: false; first-line: 1; title: ; toolbar: true; wrap-lines: false; notranslate">
&lt;select id=&quot;selectArticleByTitleAndAuthor&quot; parameterType=&quot;com.loiane.model.Article&quot;
	resultType=&quot;Article&quot;&gt;
	SELECT id, title, author
	FROM article
	WHERE
	&lt;if test=&quot;title != null&quot;&gt;
		title LIKE #{title}
	&lt;/if&gt;
	&lt;if test=&quot;author != null&quot;&gt;
		AND author LIKE #{author}
	&lt;/if&gt;
&lt;/select&gt;
</pre>
<p>What if both title and author are null? We are going to have the following statement:</p>
<pre class="brush: sql; collapse: false; first-line: 1; title: ; toolbar: true; wrap-lines: false; notranslate">
SELECT id, title, author
FROM article
WHERE
</pre>
<p>And what if only the author is not null? We are going to have the fololwing statement:</p>
<pre class="brush: sql; collapse: false; first-line: 1; title: ; toolbar: true; wrap-lines: false; notranslate">
SELECT id, title, author
FROM article
WHERE
AND author LIKE #{author}
</pre>
<p>And both FAILS!</p>
<p>How to fix it?</p>
<p><strong>5 &#8211; Fifth scenario</strong>: we want to retrieve all the articles with two optional filters: title and author. To avoid the 4th scenatio, we are going to use a Where element:</p>
<pre class="brush: xml; collapse: false; first-line: 1; title: ; toolbar: true; wrap-lines: false; notranslate">
&lt;select id=&quot;selectArticleByTitleAndAuthorDynamic&quot; parameterType=&quot;com.loiane.model.Article&quot;
	resultType=&quot;Article&quot;&gt;
	SELECT id, title, author
	FROM article
	&lt;where&gt;
		&lt;if test=&quot;title != null&quot;&gt;
			title LIKE #{title}
		&lt;/if&gt;
		&lt;if test=&quot;author != null&quot;&gt;
			AND author LIKE #{author}
		&lt;/if&gt;
	&lt;/where&gt;
&lt;/select&gt;
</pre>
<p><!-- p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Helvetica} --></p>
<blockquote>
<p style="text-align: justify;">MyBatis has a simple answer that will likely work in 90% of the cases. And in cases where it doesn’t, you can customize it so that it does.</p>
<p style="text-align: justify;">The where element knows to only insert “WHERE” if there is any content returned by the containing tags. Furthermore, if that content begins with “AND” or “OR”, it knows to strip it off.</p>
<p style="text-align: justify;">If the where element does not behave exactly as you like, you can customize it by defining your own trim element. For example,the trim equivalent to the where element is:</p>
</blockquote>
<pre class="brush: xml; collapse: false; first-line: 1; title: ; toolbar: true; wrap-lines: false; notranslate">
&lt;select id=&quot;selectArticleByTitleAndAuthorDynamic2&quot; parameterType=&quot;com.loiane.model.Article&quot;
	resultType=&quot;Article&quot;&gt;
	SELECT id, title, author
	FROM article
	&lt;trim prefix=&quot;WHERE&quot; prefixOverrides=&quot;AND |OR &quot;&gt;
		&lt;if test=&quot;title != null&quot;&gt;
			title LIKE #{title}
		&lt;/if&gt;
		&lt;if test=&quot;author != null&quot;&gt;
			AND author LIKE #{author}
		&lt;/if&gt;
	&lt;/trim&gt;
&lt;/select&gt;
</pre>
<p><!-- p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Helvetica} --></p>
<blockquote>
<p style="text-align: justify;">The overrides attribute takes a pipe delimited list of text to override, where whitespace is relevant. The result is the removal of anything specified in the overrides attribute, and the insertion of anything in the with attribute.</p>
</blockquote>
<p style="text-align: justify;">You can also use the <strong>Trim</strong> element with SET.</p>
<p style="text-align: justify;"><strong>6 &#8211; Sixth scenario</strong>: the user will choose all the categories an article can belong to. So in this case, we have a list (a collection), and we have to interate this collection and we are going to use a <strong>foreach</strong> element:</p>
<pre class="brush: xml; collapse: false; first-line: 1; title: ; toolbar: true; wrap-lines: false; notranslate">
&lt;select id=&quot;selectArticleByListCategories&quot; resultType=&quot;Article&quot;&gt;
	SELECT id, title, author
	FROM article
	WHERE id_category IN
	&lt;foreach item=&quot;category&quot; index=&quot;index&quot; collection=&quot;list&quot; open=&quot;(&quot;
		separator=&quot;,&quot; close=&quot;)&quot;&gt;
		#{category}
	&lt;/foreach&gt;
&lt;/select&gt;
</pre>
<blockquote>
<p style="text-align: justify;">The foreach element is very powerful, and allows you to specify a collection, declare item and index variables that can be used inside the body of the element. It also allows you to specify opening and closing strings, and add a separator to place in between iterations. The element is smart in that it won’t accidentally append extra separators.</p>
<p style="text-align: justify;"><strong><span style="text-decoration: underline;">Note</span></strong>: You can pass a List instance or an Array to MyBatis as a parameter object. When you do, MyBatis will automatically wrap it in a Map, and key it by name. List instances will be keyed to the name “list” and array instances will be keyed to the name “array”.</p>
</blockquote>
<p style="text-align: justify;">The complete <em><strong>Article.xml</strong></em> file looks like this:</p>
<pre class="brush: xml; collapse: false; first-line: 1; title: ; toolbar: true; wrap-lines: false; notranslate">
&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
&lt;!DOCTYPE mapper
  PUBLIC &quot;-//mybatis.org//DTD Mapper 3.0//EN&quot;
	&quot;http://mybatis.org/dtd/mybatis-3-mapper.dtd&quot;&gt;

&lt;mapper namespace=&quot;Article&quot;&gt;

    &lt;select id=&quot;selectArticleByTitle&quot; parameterType=&quot;com.loiane.model.Article&quot;
     resultType=&quot;Article&quot;&gt;
    	SELECT id, title, author
		FROM article
		WHERE id_status = 1
		&lt;if test=&quot;title != null&quot;&gt;
			AND title LIKE #{title}
		&lt;/if&gt;
    &lt;/select&gt;

    &lt;select id=&quot;selectArticleByTitleAndAuthor&quot; parameterType=&quot;com.loiane.model.Article&quot;
     resultType=&quot;Article&quot;&gt;
    	SELECT id, title, author
		FROM article
		WHERE id_status = 1
		&lt;if test=&quot;title != null&quot;&gt;
			AND title LIKE #{title}
		&lt;/if&gt;
		&lt;if test=&quot;author != null&quot;&gt;
			AND author LIKE #{author}
		&lt;/if&gt;
    &lt;/select&gt;

    &lt;select id=&quot;selectArticleByTitleOrAuthorOrCategory&quot; parameterType=&quot;com.loiane.model.Article&quot;
     resultType=&quot;Article&quot;&gt;
    	SELECT id, title, author
		FROM article
		WHERE id_status = 1
		&lt;choose&gt;
			&lt;when test=&quot;title != null&quot;&gt;
				AND title LIKE #{title}
			&lt;/when&gt;
			&lt;when test=&quot;author != null&quot;&gt;
				AND author LIKE #{author}
			&lt;/when&gt;
			&lt;otherwise&gt;
				AND id_category = 3
			&lt;/otherwise&gt;
		&lt;/choose&gt;
    &lt;/select&gt;

	 &lt;select id=&quot;selectArticleByTitleAndAuthorDynamic&quot; parameterType=&quot;com.loiane.model.Article&quot;
     resultType=&quot;Article&quot;&gt;
    	SELECT id, title, author
		FROM article
		&lt;where&gt;
			&lt;if test=&quot;title != null&quot;&gt;
				title LIKE #{title}
			&lt;/if&gt;
			&lt;if test=&quot;author != null&quot;&gt;
				AND author LIKE #{author}
			&lt;/if&gt;
		&lt;/where&gt;
    &lt;/select&gt;

    &lt;select id=&quot;selectArticleByTitleAndAuthorDynamic2&quot; parameterType=&quot;com.loiane.model.Article&quot;
     resultType=&quot;Article&quot;&gt;
    	SELECT id, title, author
		FROM article
		&lt;trim prefix=&quot;WHERE&quot; prefixOverrides=&quot;AND |OR &quot;&gt;
			&lt;if test=&quot;title != null&quot;&gt;
				title LIKE #{title}
			&lt;/if&gt;
			&lt;if test=&quot;author != null&quot;&gt;
				AND author LIKE #{author}
			&lt;/if&gt;
		&lt;/trim&gt;
    &lt;/select&gt;

    &lt;select id=&quot;selectArticleByListCategories&quot; resultType=&quot;Article&quot;&gt;
    	SELECT id, title, author
		FROM article
		WHERE id_category IN
		&lt;foreach item=&quot;category&quot; index=&quot;index&quot; collection=&quot;list&quot;
			open=&quot;(&quot; separator=&quot;,&quot; close=&quot;)&quot;&gt;
			#{category}
		&lt;/foreach&gt;
    &lt;/select&gt;
&lt;/mapper&gt;
</pre>
<div>
<h2 style="text-align: justify;">Download</h2>
<p style="text-align: justify;">If you want to download the complete sample project, you can get it from my GitHub account: <a href="https://github.com/loiane/ibatis-dynamic-sql" target="_blank">https://github.com/loiane/ibatis-dynamic-sql</a></p>
<p style="text-align: justify;">If you want to download the zip file of the project, just click on download:</p>
<p style="text-align: justify;"><a href="http://loianegroner.com/wp-content/uploads/2011/01/donwload-github-example-loiane.png" target="_blank"><img title="donwload-github-example-loiane" src="http://loianegroner.com/wp-content/uploads/2011/01/donwload-github-example-loiane.png" alt="" width="572" height="219" /></a></p>
<p style="text-align: justify;"><a href="http://loianegroner.com/wp-content/uploads/2011/01/donwload-github-example-loiane.png" target="_blank"></a></p>
<p style="text-align: justify;">There are more articles about iBatis to come. Stay tooned!</p>
<p style="text-align: justify;">Happy Coding! <img src='http://loianegroner.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
</div>
<div class="shr-publisher-781"></div><!-- Start Shareaholic LikeButtonSetBottom Automatic --><!-- End Shareaholic LikeButtonSetBottom Automatic --><img src="http://loianegroner.com/?ak_action=api_record_view&id=781&type=feed" alt="" /><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/LoianeGroner?a=cIjwdGGhK-A:gV1CgOV3AaA:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/LoianeGroner?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/LoianeGroner?a=cIjwdGGhK-A:gV1CgOV3AaA:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/LoianeGroner?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/LoianeGroner?a=cIjwdGGhK-A:gV1CgOV3AaA:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/LoianeGroner?i=cIjwdGGhK-A:gV1CgOV3AaA:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/LoianeGroner?a=cIjwdGGhK-A:gV1CgOV3AaA:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/LoianeGroner?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/LoianeGroner?a=cIjwdGGhK-A:gV1CgOV3AaA:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/LoianeGroner?i=cIjwdGGhK-A:gV1CgOV3AaA:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/LoianeGroner?a=cIjwdGGhK-A:gV1CgOV3AaA:I9og5sOYxJI"><img src="http://feeds.feedburner.com/~ff/LoianeGroner?d=I9og5sOYxJI" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/LoianeGroner/~4/cIjwdGGhK-A" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://loianegroner.com/2011/03/ibatis-mybatis-working-with-dynamic-queries-sql/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://loianegroner.com/2011/03/ibatis-mybatis-working-with-dynamic-queries-sql/</feedburner:origLink></item>
		<item>
		<title>IBatis (MyBatis): Discriminator Column Example – Inheritance Mapping Tutorial</title>
		<link>http://feedproxy.google.com/~r/LoianeGroner/~3/kkgrVlIq4HI/</link>
		<comments>http://loianegroner.com/2011/03/ibatis-mybatis-discriminator-column-example-inheritance-mapping-tutorial/#comments</comments>
		<pubDate>Tue, 15 Mar 2011 10:00:55 +0000</pubDate>
		<dc:creator>Loiane</dc:creator>
				<category><![CDATA[iBatis (MyBatis)]]></category>
		<category><![CDATA[annotations]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[discriminator column]]></category>
		<category><![CDATA[iBatis]]></category>
		<category><![CDATA[ibatis annotation]]></category>
		<category><![CDATA[Inheritance Mapping]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[MyBatis]]></category>
		<category><![CDATA[MyBatis annotation]]></category>
		<category><![CDATA[mySQL]]></category>

		<guid isPermaLink="false">http://loianegroner.com/?p=771</guid>
		<description />
			<content:encoded><![CDATA[<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/LoianeGroner?a=kkgrVlIq4HI:lEeSQt2c2BA:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/LoianeGroner?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/LoianeGroner?a=kkgrVlIq4HI:lEeSQt2c2BA:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/LoianeGroner?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/LoianeGroner?a=kkgrVlIq4HI:lEeSQt2c2BA:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/LoianeGroner?i=kkgrVlIq4HI:lEeSQt2c2BA:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/LoianeGroner?a=kkgrVlIq4HI:lEeSQt2c2BA:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/LoianeGroner?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/LoianeGroner?a=kkgrVlIq4HI:lEeSQt2c2BA:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/LoianeGroner?i=kkgrVlIq4HI:lEeSQt2c2BA:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/LoianeGroner?a=kkgrVlIq4HI:lEeSQt2c2BA:I9og5sOYxJI"><img src="http://feeds.feedburner.com/~ff/LoianeGroner?d=I9og5sOYxJI" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/LoianeGroner/~4/kkgrVlIq4HI" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://loianegroner.com/2011/03/ibatis-mybatis-discriminator-column-example-inheritance-mapping-tutorial/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://loianegroner.com/2011/03/ibatis-mybatis-discriminator-column-example-inheritance-mapping-tutorial/</feedburner:origLink></item>
		<item>
		<title>IBatis (MyBatis): Handling Constructors</title>
		<link>http://feedproxy.google.com/~r/LoianeGroner/~3/KkMUltkr3Us/</link>
		<comments>http://loianegroner.com/2011/03/ibatis-mybatis-handling-constructors/#comments</comments>
		<pubDate>Thu, 10 Mar 2011 10:00:59 +0000</pubDate>
		<dc:creator>Loiane</dc:creator>
				<category><![CDATA[iBatis (MyBatis)]]></category>
		<category><![CDATA[annotations]]></category>
		<category><![CDATA[constructor]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[iBatis]]></category>
		<category><![CDATA[ibatis annotation]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[MyBatis]]></category>
		<category><![CDATA[MyBatis annotation]]></category>
		<category><![CDATA[mySQL]]></category>

		<guid isPermaLink="false">http://loianegroner.com/?p=915</guid>
		<description><![CDATA[This tutorial will walk you through how to setup iBatis (MyBatis) in a simple Java project and will present an example using a class constructor with arguments. Pre-Requisites For this tutorial I am using: IDE: Eclipse (you can use your favorite one) DataBase: MySQL Libs/jars: Mybatis, MySQL conector and JUnit (for testing) This is how your project should look like: Sample [...]]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop Automatic --><!-- End Shareaholic LikeButtonSetTop Automatic --><p style="text-align: justify;">This tutorial will walk you through how to setup <a href="http://www.mybatis.org/" target="_blank">iBatis</a> (<a href="http://www.mybatis.org/" target="_blank">MyBatis</a>) in a simple Java project and will present an example using a class constructor with arguments.</p>
<p style="text-align: justify;"><a href="http://loianegroner.com/wp-content/uploads/2011/01/ibatis_mybatis_loiane.png"><img class="aligncenter size-full wp-image-685" title="ibatis_mybatis_loiane" src="http://loianegroner.com/wp-content/uploads/2011/01/ibatis_mybatis_loiane.png" alt="" width="274" height="149" /></a></p>
<p style="text-align: justify;"><a href="http://loianegroner.com/wp-content/uploads/2011/01/ibatis_mybatis_loiane.png"></a></p>
<h2 style="text-align: justify;">Pre-Requisites</h2>
<p style="text-align: justify;">For this tutorial I am using:</p>
<p style="text-align: justify;">IDE: <a href="http://eclipse.org/" target="_blank">Eclipse</a> (you can use your favorite one)<br />
DataBase: <a href="http://dev.mysql.com/downloads/" target="_blank">MySQL</a><br />
Libs/jars: <a href="http://www.mybatis.org/" target="_blank">Mybatis</a>, <a href="http://dev.mysql.com/downloads/" target="_blank">MySQL</a> conector and <a href="http://www.junit.org/" target="_blank">JUnit</a> (for testing)</p>
<p style="text-align: justify;">This is how your project should look like:</p>
<p style="text-align: justify;"><a href="http://loianegroner.com/wp-content/uploads/2011/02/ibatis_mybatis_loiane_constructor_project.png"><img class="aligncenter size-full wp-image-922" title="ibatis_mybatis_loiane_constructor_project" src="http://loianegroner.com/wp-content/uploads/2011/02/ibatis_mybatis_loiane_constructor_project.png" alt="" width="255" height="373" /></a></p>
<p style="text-align: justify;"><a href="http://loianegroner.com/wp-content/uploads/2011/02/ibatis_mybatis_loiane_handling_joins.png"></a></p>
<h2 style="text-align: justify;">Sample Database</h2>
<p style="text-align: justify;">Please run the script into your database before getting started with the project implementation. You will find the script (with dummy data) inside the sql folder.</p>
<p style="text-align: justify;"><a href="http://loianegroner.com/wp-content/uploads/2011/02/ibatis_mybatis_loiane_constructor.PNG.png"><img class="aligncenter size-full wp-image-927" title="ibatis_mybatis_loiane_constructor.PNG" src="http://loianegroner.com/wp-content/uploads/2011/02/ibatis_mybatis_loiane_constructor.PNG.png" alt="" width="140" height="129" /></a></p>
<h2 style="text-align: justify;">1 &#8211; POJO</h2>
<p style="text-align: justify;">I represented the beans here with a UML model, but you can download the complete source code in the end of this article.</p>
<p style="text-align: justify;"><a href="http://loianegroner.com/wp-content/uploads/2011/02/ibatis_mybatis_loiane_constructor_uml.png"><img class="aligncenter size-full wp-image-925" title="ibatis_mybatis_loiane_constructor_uml" src="http://loianegroner.com/wp-content/uploads/2011/02/ibatis_mybatis_loiane_constructor_uml.png" alt="" width="511" height="224" /></a></p>
<p style="text-align: justify;"><a href="http://loianegroner.com/wp-content/uploads/2011/02/ibatis_mybatis_loiane_uml_handlingjoins.png"></a></p>
<p style="text-align: justify;">As you can see, we do not have a default construtor in this class, only a constructor with some arguments. Some persistence frameworks requires a default constructor, but you have to be careful with your business logic.</p>
<p style="text-align: justify;">Let&#8217;s say there are a couple of mandatory atributes in your class. Nothing is going to stop you if you do not set these atributes and try to insert, update on the database. And you problably will get an exception for that.</p>
<p style="text-align: justify;">To prevent this kind of situation, you can create a constructor with the mandatory arguments. And ibatis/mybatis can handle this situation for you, because you do not need to create a default constructor.</p>
<h2 style="text-align: justify;">2 &#8211; Blog Mapper &#8211; XML</h2>
<blockquote style="text-align: justify;">
<div id="_mcePaste" style="text-align: justify;">While properties will work for most Data Transfer Object (DTO) type classes, and likely most of yourdomain model, there may be some cases where you want to use immutable classes. Often tables thatcontain reference or lookup data that rarely or never changes is suited to immutable classes.Constructor injection allows you to set values on a class upon instantiation, without exposing publicmethods. MyBatis also supports private properties and private JavaBeans properties to achieve this, butsome people prefer Constructor injection. The constructor element enables this.</div>
<div style="text-align: justify;">
<div style="text-align: justify;">In order to inject the results into the constructor, MyBatis needs to identify the constructor by the type of its parameters. Java has no way to introspect (or reflect) on parameter names. So when creating a constructor element, ensure that the arguments are in order, and that the data types are specified.</div>
</div>
</blockquote>
<p style="text-align: justify;">If you need, you can still map another attributes, such as association, collection in your resultMap.</p>
<p style="text-align: justify;">Following is the Blog.xml file:</p>
<pre class="brush: xml; collapse: false; first-line: 1; title: ; toolbar: true; wrap-lines: false; notranslate">
&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
&lt;!DOCTYPE mapper
  PUBLIC &quot;-//mybatis.org//DTD Mapper 3.0//EN&quot;
	&quot;http://mybatis.org/dtd/mybatis-3-mapper.dtd&quot;&gt;

&lt;mapper namespace=&quot;Blog&quot;&gt;

	&lt;resultMap id=&quot;resultBlog&quot; type=&quot;Blog&quot;&gt;
		&lt;constructor&gt;
			&lt;idArg column=&quot;id&quot; javaType=&quot;int&quot;/&gt;
			&lt;arg column=&quot;url&quot; javaType=&quot;String&quot;/&gt;
		&lt;/constructor&gt;
	    &lt;result property=&quot;name&quot;/&gt;
    &lt;/resultMap&gt;

    &lt;select id=&quot;selectBlog&quot; resultMap=&quot;resultBlog&quot;&gt;
    	SELECT idBlog as id, name, url FROM BLOG
    &lt;/select&gt;

&lt;/mapper&gt;
</pre>
<h2 style="text-align: justify;">3 - Blog Mapper &#8211; Annotations</h2>
<p style="text-align: justify;">We did the configuration in XML, now let&#8217;s try to use annotations to do the same thing we did using XML.</p>
<p style="text-align: justify;">This is the code for BlogMapper.java:</p>
<pre class="brush: java; collapse: false; first-line: 1; title: ; toolbar: true; wrap-lines: false; notranslate">
package com.loiane.data;

import java.util.List;

import org.apache.ibatis.annotations.Arg;
import org.apache.ibatis.annotations.ConstructorArgs;
import org.apache.ibatis.annotations.Select;

import com.loiane.model.Blog;

public interface BlogMapper {

	/**
	 * Returns the list of all Blog instances from the database.
	 * @return the list of all Blog instances from the database.
	 */
	@Select(&quot;SELECT idBlog as id, name, url FROM BLOG &quot;)
	@ConstructorArgs(value = {
        @Arg(column=&quot;id&quot;,javaType=Integer.class),
        @Arg(column=&quot;url&quot;,javaType=String.class)
    })
	List&lt;Blog&gt; selectAllBlogs();
}
</pre>
<p style="text-align: justify;">Let&#8217;s take a look at the @ConstructorArgs and @Arg annotations:</p>
<h3 style="text-align: justify;">@ConstructorArgs</h3>
<p style="text-align: justify;">Collects a group of results to be passed to a result object constructor.</p>
<p style="text-align: justify;">Attributes: value, which is an array of Args.</p>
<p style="text-align: justify;">Xml equivalent: constructor</p>
<h3 style="text-align: justify;">@Arg</h3>
<p style="text-align: justify;">A single constructor argument that is part of a ConstructorArgs collection.</p>
<p style="text-align: justify;">Attributes: id, column, javaType, jdbcType, typeHandler.</p>
<p style="text-align: justify;">The id attribute is a boolean value that identifies the property to be used for comparisons, similar to the &lt;idArg&gt; XML element.</p>
<p style="text-align: justify;">Xml equivalent: idArg, arg</p>
<p style="text-align: justify;">We do not need to use the @Results annotation because the other attributes has the same name, so Mybatis knows how to map them.</p>
<h2 style="text-align: justify;">Download</h2>
<p style="text-align: justify;">If you want to download the complete sample project, you can get it from my GitHub account: <a href="https://github.com/loiane/ibatis-constructor" target="_blank">https://github.com/loiane/ibatis-constructor</a></p>
<p style="text-align: justify;">If you want to download the zip file of the project, just click on download:</p>
<p style="text-align: justify;"><a href="http://loianegroner.com/wp-content/uploads/2011/01/donwload-github-example-loiane.png" target="_blank"><img class="aligncenter" title="donwload-github-example-loiane" src="http://loianegroner.com/wp-content/uploads/2011/01/donwload-github-example-loiane.png" alt="" width="572" height="219" /></a></p>
<p style="text-align: justify;"><a href="http://loianegroner.com/wp-content/uploads/2011/01/donwload-github-example-loiane.png" target="_blank"></a></p>
<p style="text-align: justify;">There are more articles about iBatis to come. Stay tooned!</p>
<p style="text-align: justify;">Happy Coding! <img src='http://loianegroner.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p style="text-align: justify;">Once again though, some may find this external definition of maps somewhat tedious. Thereforethere’s an alternative syntax for those that prefer a more concise mapping style. For example:</p>
<div class="shr-publisher-915"></div><!-- Start Shareaholic LikeButtonSetBottom Automatic --><!-- End Shareaholic LikeButtonSetBottom Automatic --><img src="http://loianegroner.com/?ak_action=api_record_view&id=915&type=feed" alt="" /><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/LoianeGroner?a=KkMUltkr3Us:11h6CZkrlmw:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/LoianeGroner?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/LoianeGroner?a=KkMUltkr3Us:11h6CZkrlmw:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/LoianeGroner?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/LoianeGroner?a=KkMUltkr3Us:11h6CZkrlmw:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/LoianeGroner?i=KkMUltkr3Us:11h6CZkrlmw:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/LoianeGroner?a=KkMUltkr3Us:11h6CZkrlmw:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/LoianeGroner?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/LoianeGroner?a=KkMUltkr3Us:11h6CZkrlmw:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/LoianeGroner?i=KkMUltkr3Us:11h6CZkrlmw:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/LoianeGroner?a=KkMUltkr3Us:11h6CZkrlmw:I9og5sOYxJI"><img src="http://feeds.feedburner.com/~ff/LoianeGroner?d=I9og5sOYxJI" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/LoianeGroner/~4/KkMUltkr3Us" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://loianegroner.com/2011/03/ibatis-mybatis-handling-constructors/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://loianegroner.com/2011/03/ibatis-mybatis-handling-constructors/</feedburner:origLink></item>
		<item>
		<title>IBatis (MyBatis): Handling Joins: Advanced Result Mapping, Association, Collections, N+1 Select Problem</title>
		<link>http://feedproxy.google.com/~r/LoianeGroner/~3/LvQSvQUZjVI/</link>
		<comments>http://loianegroner.com/2011/03/ibatis-mybatis-handling-joins-advanced-result-mapping-association-collections-n1-select-problem/#comments</comments>
		<pubDate>Tue, 01 Mar 2011 10:00:22 +0000</pubDate>
		<dc:creator>Loiane</dc:creator>
				<category><![CDATA[iBatis (MyBatis)]]></category>
		<category><![CDATA[annotations]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[delete]]></category>
		<category><![CDATA[iBatis]]></category>
		<category><![CDATA[ibatis annotation]]></category>
		<category><![CDATA[insert]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[many-to-many]]></category>
		<category><![CDATA[MyBatis]]></category>
		<category><![CDATA[MyBatis annotation]]></category>
		<category><![CDATA[mySQL]]></category>
		<category><![CDATA[one-to-many]]></category>
		<category><![CDATA[One-to-one]]></category>
		<category><![CDATA[select]]></category>
		<category><![CDATA[update]]></category>

		<guid isPermaLink="false">http://loianegroner.com/?p=767</guid>
		<description><![CDATA[This tutorial will walk you through how to setup iBatis (MyBatis) in a simple Java project and will present examples using advanced result mapings, how to hadle mappings with association, collections, n+1 problem and will show how to configure these relationships using XML configuration and annotations. Pre-Requisites For this tutorial I am using: IDE: Eclipse (you can [...]]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop Automatic --><!-- End Shareaholic LikeButtonSetTop Automatic --><p style="text-align: justify;">This tutorial will walk you through how to setup <a href="http://www.mybatis.org/" target="_blank">iBatis</a> (<a href="http://www.mybatis.org/" target="_blank">MyBatis</a>) in a simple Java project and will present examples using advanced result mapings, how to hadle mappings with association, collections, n+1 problem and will show how to configure these relationships using XML configuration and annotations.</p>
<p style="text-align: justify;"><a href="http://loianegroner.com/wp-content/uploads/2011/01/ibatis_mybatis_loiane.png"><img class="aligncenter size-full wp-image-685" title="ibatis_mybatis_loiane" src="http://loianegroner.com/wp-content/uploads/2011/01/ibatis_mybatis_loiane.png" alt="" width="274" height="149" /></a></p>
<h2 style="text-align: justify;">Pre-Requisites</h2>
<p style="text-align: justify;">For this tutorial I am using:</p>
<p style="text-align: justify;">IDE: <a href="http://eclipse.org/" target="_blank">Eclipse</a> (you can use your favorite one)<br />
DataBase: <a href="http://dev.mysql.com/downloads/" target="_blank">MySQL</a><br />
Libs/jars: <a href="http://www.mybatis.org/" target="_blank">Mybatis</a>, <a href="http://dev.mysql.com/downloads/" target="_blank">MySQL</a> conector and <a href="http://www.junit.org/" target="_blank">JUnit</a> (for testing)</p>
<p style="text-align: justify;">This is how your project should look like:</p>
<p style="text-align: justify;"><a href="http://loianegroner.com/wp-content/uploads/2011/02/ibatis_mybatis_loiane_handling_joins.png"><img class="aligncenter size-full wp-image-825" title="ibatis_mybatis_loiane_handling_joins" src="http://loianegroner.com/wp-content/uploads/2011/02/ibatis_mybatis_loiane_handling_joins.png" alt="" width="260" height="493" /></a></p>
<h2 style="text-align: justify;">Sample Database</h2>
<p style="text-align: justify;">Please run the script into your database before getting started with the project implementation. You will find the script (with dummy data) inside the sql folder.</p>
<p style="text-align: justify;"><a href="http://loianegroner.com/wp-content/uploads/2011/02/ibatis_loiane_advancedresultmapping.png"><img class="aligncenter size-full wp-image-776" title="ibatis_loiane_advancedresultmapping" src="http://loianegroner.com/wp-content/uploads/2011/02/ibatis_loiane_advancedresultmapping.png" alt="" width="474" height="314" /></a></p>
<h2>1 &#8211; POJOs &#8211; Beans</h2>
<p style="text-align: justify;">I represented the beans here with a UML model, but you can download the complete source code in the end of this article.</p>
<p style="text-align: justify;"><a href="http://loianegroner.com/wp-content/uploads/2011/02/ibatis_mybatis_loiane_uml_handlingjoins.png"><img class="aligncenter size-full wp-image-826" title="ibatis_mybatis_loiane_uml_handlingjoins" src="http://loianegroner.com/wp-content/uploads/2011/02/ibatis_mybatis_loiane_uml_handlingjoins.png" alt="" width="386" height="414" /></a></p>
<p style="text-align: justify;">The goal of this post is to demonstrate how to retrieve all the blog information from the database, but as you can see, the class Blog contains an association (Author) and a collection of Posts (and it contains a collection of Tags). And we are going to try to retrieve all this information at once.</p>
<p style="text-align: justify;">So we are going to demonstrate One-to-one, one-to-many and many-to-many relationships using iBatis/Mybatis.</p>
<h2>2 &#8211; Advanced Result Mapping</h2>
<p style="text-align: justify;">The result map on the code above is an advanced result mapping. As I already mentioned on previous posts, the resultMap element is the most important and powerful element in MyBatis.</p>
<p><!-- p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Helvetica} span.s1 {font: 7.0px Helvetica} --></p>
<blockquote>
<p style="text-align: justify;">MyBatis was created with one idea in mind: Databases aren’t always what you want or need them to be. While we’d love every database to be perfect 3rd normal form or BCNF, they aren’t. And it would be great if it was possible to have a single database map perfectly to all of the applications that use it, it’s not. Result Maps are the answer that MyBatis provides to this problem.</p>
<p style="text-align: justify;">The resultMap element has a number of sub-elements and a structure worthy of some discussion. The following is a conceptual view of the resultMap element.</p>
<ul>
<li><span style="font-family: TT15Et00; mso-bidi-font-family: TT15Et00; mso-ansi-language: EN-US;" lang="EN-US">constructor </span><span style="font-family: TT15Ct00; mso-bidi-font-family: TT15Ct00; mso-ansi-language: EN-US;" lang="EN-US">– used for injecting results into the constructor of a class upon instantiation</span></li>
<li><span style="line-height: normal;"><span style="font-family: Symbol; mso-fareast-font-family: Symbol; mso-bidi-font-family: Symbol; mso-ansi-language: EN-US;" lang="EN-US"><span style="mso-list: Ignore;"><span style="font: 7.0pt &amp;amp;amp;"> </span></span></span><span style="font-family: TT15Et00; mso-bidi-font-family: TT15Et00; mso-ansi-language: EN-US;" lang="EN-US">id </span><span style="font-family: TT15Ct00; mso-bidi-font-family: TT15Ct00; mso-ansi-language: EN-US;" lang="EN-US">– an ID result; flagging results as ID will help improve overall performance</span></span></li>
<li><span style="line-height: normal;"><span style="font-family: TT15Et00; mso-bidi-font-family: TT15Et00; mso-ansi-language: EN-US;" lang="EN-US">result </span><span style="font-family: TT15Ct00; mso-bidi-font-family: TT15Ct00; mso-ansi-language: EN-US;" lang="EN-US">– a normal result injected into a field or JavaBean property</span></span></li>
<li><span style="line-height: normal;"><span style="font-family: TT15Et00; mso-bidi-font-family: TT15Et00; mso-ansi-language: EN-US;" lang="EN-US">association </span><span style="font-family: TT15Ct00; mso-bidi-font-family: TT15Ct00; mso-ansi-language: EN-US;" lang="EN-US">– a complex type association; many results will roll up into this type</span></span></li>
<li><span style="line-height: normal;"><span style="font-family: TT15Et00; mso-bidi-font-family: TT15Et00; mso-ansi-language: EN-US;" lang="EN-US">collection </span><span style="font-family: TT15Ct00; mso-bidi-font-family: TT15Ct00; mso-ansi-language: EN-US;" lang="EN-US">– a collection of complex types</span></span></li>
<li><span style="line-height: normal;"><span style="font-family: TT15Et00; mso-bidi-font-family: TT15Et00; mso-ansi-language: EN-US;" lang="EN-US">discriminator </span><span style="font-family: TT15Ct00; mso-bidi-font-family: TT15Ct00; mso-ansi-language: EN-US;" lang="EN-US">– uses a result value to determine which resultMap to use.</span></span></li>
</ul>
<p style="text-align: justify;"><span style="text-decoration: underline;">Best Practice:</span> Always build ResultMaps incrementally. Unit tests really help out here. If you try to build a gigantic resultMap like the one above all at once, it’s likely you’ll get it wrong and it will be hard to work with. Start simple, and evolve it a step at a time. And unit test! The downside to using frameworks is that they are sometimes a bit of a black box (open source or not). Your best bet to ensure that you’re achieving the behaviour that you intend, is to write unit tests. It also helps to have them when submitting bugs.</p>
</blockquote>
<p><!-- p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Helvetica} span.s1 {font: 11.0px Symbol} span.s2 {font: 11.0px Courier} span.Apple-tab-span {white-space:pre} --> <!-- p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Helvetica} --></p>
<p style="text-align: justify;">Our goal is to write the following result map:</p>
<pre class="brush: xml; collapse: false; first-line: 1; title: ; toolbar: true; wrap-lines: false; notranslate">
&lt;resultMap id=&quot;resultBlog&quot; type=&quot;Blog&quot;&gt;
	&lt;id property=&quot;id&quot; column=&quot;idBlog&quot; /&gt;
	&lt;result property=&quot;name&quot; column=&quot;blogname&quot; /&gt;
	&lt;result property=&quot;url&quot; column=&quot;blogurl&quot; /&gt;
	&lt;association property=&quot;author&quot; column=&quot;idBlog&quot; javaType=&quot;Author&quot;
		select=&quot;selectAuthor&quot; /&gt;
	&lt;collection property=&quot;posts&quot; column=&quot;idBlog&quot; javaType=&quot;ArrayList&quot;
		ofType=&quot;Post&quot; select=&quot;selectPosts&quot; resultMap=&quot;resultTag&quot; /&gt;
&lt;/resultMap&gt;
</pre>
<p style="text-align: justify;">But let&#8217;s take a step at the time. We are going to start retrieving only the Blog data, so our initial result map and query is going to look like this:</p>
<pre class="brush: xml; collapse: false; first-line: 1; title: ; toolbar: true; wrap-lines: false; notranslate">
&lt;resultMap id=&quot;resultBlog&quot; type=&quot;Blog&quot;&gt;
	&lt;id property=&quot;id&quot; column=&quot;idBlog&quot; /&gt;
	&lt;result property=&quot;name&quot; column=&quot;blogname&quot; /&gt;
	&lt;result property=&quot;url&quot; column=&quot;blogurl&quot; /&gt;
&lt;/resultMap&gt;

&lt;select id=&quot;selectBlog&quot; resultMap=&quot;resultBlog&quot;&gt;
	SELECT idBlog, name as blogname, url as blogurl FROM BLOG
&lt;/select&gt;
</pre>
<p style="text-align: justify;">So far, so good. Let&#8217;s take another step.</p>
<h3>Association</h3>
<p style="text-align: justify;">Now let&#8217;s also try to retrieve the Author data.</p>
<blockquote>
<p style="text-align: justify;">The association element deals with a “<strong>has-one</strong>” type relationship. For example, in our example, a Blog has one Author. An association mapping works mostly like any other result. You specify the target property, the column to retrieve the value from, the javaType of the property (which MyBatis can figure out most of the time), the jdbcType if necessary and a typeHandler if you want to override the retrieval of the result values.</p>
<p style="text-align: justify;">Where the association differs is that you need to tell MyBatis how to load the association. MyBatis can do so in two different ways:</p>
<ul>
<li>Nested Select: By executing another mapped SQL statement that returns the complex type desired.</li>
<li>Nested Results: By using nested result mappings to deal with repeating subsets of joined results.</li>
</ul>
</blockquote>
<p>We are going to take a look at the Nested Select first.</p>
<p>Here is our resultMap with Author association.</p>
<pre class="brush: xml; collapse: false; first-line: 1; title: ; toolbar: true; wrap-lines: false; notranslate">
&lt;resultMap id=&quot;resultBlog&quot; type=&quot;Blog&quot;&gt;
	&lt;id property=&quot;id&quot; column=&quot;idBlog&quot; /&gt;
	&lt;result property=&quot;name&quot; column=&quot;blogname&quot; /&gt;
	&lt;result property=&quot;url&quot; column=&quot;blogurl&quot; /&gt;
	&lt;association property=&quot;author&quot; column=&quot;idBlog&quot; javaType=&quot;Author&quot;
		select=&quot;selectAuthor&quot; /&gt;
&lt;/resultMap&gt;

&lt;select id=&quot;selectBlog&quot; resultMap=&quot;resultBlog&quot;&gt;
	SELECT idBlog, name as blogname, url as blogurl FROM BLOG
&lt;/select&gt;

&lt;select id=&quot;selectAuthor&quot; parameterType=&quot;int&quot; resultType=&quot;Author&quot;&gt;
	SELECT idAuthor as id, name, email FROM AUTHOR WHERE idBlog = #{idBlog}
&lt;/select&gt;
</pre>
<p>Take a look at the <em>select=&#8221;selectAuthor&#8221;</em> atribute. This means MyBatis is going to execute the author select statment to retrieve all the authors that belong to the blog. To make the relationship between blog and author we specify the <em>column=&#8221;idBlog&#8221;</em>, so we can filter the authors list.</p>
<p>Note that we set the javaType=&#8221;Author&#8221;. We are using an Alias (remember?). This is because the columns we are retrieving from database match with Author atributes, so we do not need to specify a resultMap for author.</p>
<blockquote><p>That’s it. We have two select statements: one to load the Blog, the other to load the Author, and the Blog’s resultMap describes that the “selectAuthor” statement should be used to load its author property.</p>
<p>All other properties will be loaded automatically assuming their column and property names match.</p></blockquote>
<blockquote><p>While this approach is simple, it will not perform well for large data sets or lists. This problem is knownas the “<strong><span style="text-decoration: underline;">N+1 Selects Problem</span></strong>”. In a nutshell, the N+1 selects problem is caused like this:</p>
<ul>
<li>You execute a single SQL statement to retrieve a list of records (the “+1”).</li>
<li>For each record returned, you execute a select statement to load details for each (the “N”).</li>
</ul>
<p>This problem could result in hundreds or thousands of SQL statements to be executed. This is notalways desirable.The upside is that MyBatis can lazy load such queries, thus you might be spared the cost of thesestatements all at once. However, if you load such a list and then immediately iterate through it toaccess the nested data, you will invoke all of the lazy loads, and thus performance could be very bad.</p></blockquote>
<p>We are going to show how to avoid the N+1 Select Problem later.</p>
<h3>Collection</h3>
<p>We are retrieving Blog and Author information from database. So we have to retrieve the Post information now. And a Blog contains a list of Posts, and a Post contains a list of Tags. We are dealing with two relationships here: first one is a <strong>one-to-many</strong> (Blog-Post) and the second one is a <strong>many-to-many</strong> (Post-Tag). We are going to show you how to do it.</p>
<p>We are also going to use a Nested Select to retrieve Posts.</p>
<p>Let&#8217;s take a look at the resultMap with Post collection:</p>
<pre class="brush: xml; collapse: false; first-line: 1; title: ; toolbar: true; wrap-lines: false; notranslate">
&lt;resultMap id=&quot;resultBlog&quot; type=&quot;Blog&quot;&gt;
	&lt;id property=&quot;id&quot; column=&quot;idBlog&quot; /&gt;
	&lt;result property=&quot;name&quot; column=&quot;blogname&quot; /&gt;
	&lt;result property=&quot;url&quot; column=&quot;blogurl&quot; /&gt;
	&lt;association property=&quot;author&quot; column=&quot;idBlog&quot; javaType=&quot;Author&quot;
		select=&quot;selectAuthor&quot; /&gt;
	&lt;collection property=&quot;posts&quot; column=&quot;idBlog&quot; javaType=&quot;ArrayList&quot;
		ofType=&quot;Post&quot; select=&quot;selectPosts&quot; resultMap=&quot;resultTag&quot; /&gt;
&lt;/resultMap&gt;
</pre>
<blockquote><p>The collection element works almost identically to the association. In fact, it’s so similar, to document the similarities would be redundant. So let’s focus on the differences.To continue with our example above, a Blog only had one Author. But a Blog has many Posts.</p>
<p>To map a set of nested results to a List like this, we use the collection element. Just like the association element, we can use a nested select, or nested results from a join.</p>
<p>There are a number things you’ll notice immediately, but for the most part it looks very similar to the association element we learned about above. First, you’ll notice that we’re using the collection element. Then you’ll notice that there’s a new “ofType” attribute. This attribute is necessary to distinguish between the JavaBean (or field) property type and the type that the collection contains.</p></blockquote>
<p>To handle the Many-to-Many relationship between Post and Tag, we are also going to use a collection element, but we don&#8217;t need to use nested results for it:</p>
<pre class="brush: xml; collapse: false; first-line: 1; title: ; toolbar: true; wrap-lines: false; notranslate">
&lt;resultMap id=&quot;resultPosts&quot; type=&quot;Post&quot;&gt;
	&lt;id property=&quot;id&quot; column=&quot;idPost&quot; /&gt;
	&lt;result property=&quot;title&quot; column=&quot;title&quot; /&gt;
	&lt;collection property=&quot;tags&quot; column=&quot;idPost&quot; javaType=&quot;ArrayList&quot;
		ofType=&quot;Tag&quot; resultMap=&quot;resultTag&quot; /&gt;
&lt;/resultMap&gt;

&lt;resultMap id=&quot;resultTag&quot; type=&quot;Tag&quot;&gt;
	&lt;id property=&quot;id&quot; column=&quot;idTag&quot; /&gt;
	&lt;result property=&quot;value&quot; column=&quot;value&quot; /&gt;
&lt;/resultMap&gt;

&lt;select id=&quot;selectPosts&quot; parameterType=&quot;int&quot; resultType=&quot;Post&quot;
	resultMap=&quot;resultPosts&quot;&gt;
	SELECT
	P.idPost as idPost, P.title as title,
	T.idTag as idTag, T.value as value
	FROM Post P
	left outer join Post_Tag PT on P.idPost = PT.idPost
	left outer join Tag T on PT.idTag = T.idTag
	WHERE P.idBlog = #{idBlog}
&lt;/select&gt;
</pre>
<p>And we are done! Let&#8217;s see how the <em><strong>Blog.xml</strong></em> file looks like:</p>
<pre class="brush: xml; collapse: false; first-line: 1; title: ; toolbar: true; wrap-lines: false; notranslate">
&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
&lt;!DOCTYPE mapper
  PUBLIC &quot;-//mybatis.org//DTD Mapper 3.0//EN&quot;
	&quot;http://mybatis.org/dtd/mybatis-3-mapper.dtd&quot;&gt;

&lt;mapper namespace=&quot;Blog&quot;&gt;

	&lt;resultMap id=&quot;resultBlog&quot; type=&quot;Blog&quot;&gt;
	    &lt;id property=&quot;id&quot; column=&quot;idBlog&quot;/&gt;
	    &lt;result property=&quot;name&quot; column=&quot;blogname&quot;/&gt;
	    &lt;result property=&quot;url&quot; column=&quot;blogurl&quot;/&gt;
	    &lt;association property=&quot;author&quot; column=&quot;idBlog&quot; javaType=&quot;Author&quot; select=&quot;selectAuthor&quot;/&gt;
	    &lt;collection property=&quot;posts&quot; column=&quot;idBlog&quot; javaType=&quot;ArrayList&quot; ofType=&quot;Post&quot;
	    	select=&quot;selectPosts&quot; resultMap=&quot;resultTag&quot;/&gt;
    &lt;/resultMap&gt;

    &lt;resultMap id=&quot;resultPosts&quot; type=&quot;Post&quot;&gt;
	    &lt;id property=&quot;id&quot; column=&quot;idPost&quot;/&gt;
	    &lt;result property=&quot;title&quot; column=&quot;title&quot;/&gt;
	    &lt;collection property=&quot;tags&quot; column=&quot;idPost&quot; javaType=&quot;ArrayList&quot; ofType=&quot;Tag&quot;
	    	resultMap=&quot;resultTag&quot;/&gt;
    &lt;/resultMap&gt;

	&lt;resultMap id=&quot;resultTag&quot; type=&quot;Tag&quot;&gt;
    	&lt;id property=&quot;id&quot; column=&quot;idTag&quot;/&gt;
    	&lt;result property=&quot;value&quot; column=&quot;value&quot;/&gt;
    &lt;/resultMap&gt;

    &lt;select id=&quot;selectBlog&quot; resultMap=&quot;resultBlog&quot;&gt;
    	SELECT idBlog, name as blogname, url as blogurl FROM BLOG
    &lt;/select&gt;

   &lt;select id=&quot;selectAuthor&quot; parameterType=&quot;int&quot; resultType=&quot;Author&quot;&gt;
   		SELECT idAuthor as id, name, email FROM AUTHOR WHERE idBlog = #{idBlog}
   &lt;/select&gt;

   &lt;select id=&quot;selectPosts&quot; parameterType=&quot;int&quot; resultType=&quot;Post&quot; resultMap=&quot;resultPosts&quot;&gt;
   		SELECT
			P.idPost as idPost, P.title as title,
		    T.idTag as idTag, T.value as value
		FROM Post P
      		left outer join Post_Tag PT on P.idPost = PT.idPost
		  	left outer join Tag T on PT.idTag = T.idTag
		WHERE P.idBlog = #{idBlog}
   &lt;/select&gt;

&lt;/mapper&gt;
</pre>
<h3>Solution to N+1 Selects Problem</h3>
<p>As you could read above, the <strong>N+1 Selects Problem</strong> can happen while you are retrieving data.</p>
<p>How to solve it?</p>
<p>Using <strong>Nested Results</strong>: By using nested result mappings to deal with repeating subsets of joined results.</p>
<p>What we have to do is to write a single query to retrieve all the data (Blog + Author + Posts + Tags), and hadle the mapping in a single ResultMapping.</p>
<blockquote>
<div id="_mcePaste"><strong><em>Very Important</em></strong>: id elements play a very important role in Nested Result mapping. You should alwaysspecify one or more properties that can be used to uniquely identify the results. The truth is that MyBatis will still work if you leave it out, but at a severe performance cost. Choose as few properties as possible that can uniquely identify the result. The primary key is an obvious choice (even if composite).</div>
</blockquote>
<div>This is how the Blog.xml will look like is we use NestedResults:</div>
<pre class="brush: xml; collapse: false; first-line: 1; title: ; toolbar: true; wrap-lines: false; notranslate">
&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
&lt;!DOCTYPE mapper
  PUBLIC &quot;-//mybatis.org//DTD Mapper 3.0//EN&quot;
	&quot;http://mybatis.org/dtd/mybatis-3-mapper.dtd&quot;&gt;

&lt;mapper namespace=&quot;BlogBestPractice&quot;&gt;

   &lt;resultMap id=&quot;resultBlog&quot; type=&quot;Blog&quot;&gt;
	    &lt;id property=&quot;id&quot; column=&quot;idBlog&quot;/&gt;
	    &lt;result property=&quot;name&quot; column=&quot;blogName&quot;/&gt;
	    &lt;result property=&quot;url&quot; column=&quot;url&quot;/&gt;
	    &lt;association property=&quot;author&quot; column=&quot;idBlog&quot; javaType=&quot;Author&quot;&gt;
	    	&lt;id property=&quot;id&quot; column=&quot;idAuthor&quot;/&gt;
			&lt;result property=&quot;name&quot; column=&quot;authorName&quot;/&gt;
			&lt;result property=&quot;email&quot; column=&quot;email&quot;/&gt;
	    &lt;/association&gt;
	    &lt;collection property=&quot;posts&quot; column=&quot;idBlog&quot; javaType=&quot;ArrayList&quot; ofType=&quot;Post&quot;&gt;
	    	&lt;id property=&quot;id&quot; column=&quot;idPost&quot;/&gt;
	    	&lt;result property=&quot;title&quot; column=&quot;title&quot;/&gt;
	    	&lt;collection property=&quot;tags&quot; column=&quot;idBlog&quot; javaType=&quot;ArrayList&quot; ofType=&quot;Tag&quot;&gt;
	    		&lt;id property=&quot;id&quot; column=&quot;idTag&quot;/&gt;
    			&lt;result property=&quot;value&quot; column=&quot;value&quot;/&gt;
	    	&lt;/collection&gt;
	    &lt;/collection&gt;
    &lt;/resultMap&gt;

	&lt;select id=&quot;selectBlogBestPractice&quot; resultMap=&quot;resultBlog&quot;&gt;
    	SELECT
		    B.idBlog as idBlog, B.name as blogName, B.url as url,
		    A.idAuthor as idAuthor, A.name as authorName, A.email as email ,
        	P.idPost as idPost, P.title as title,
		    T.idTag as idTag, T.value as value
		FROM BLOG as B
      		left outer join Author A on B.idBlog = A.idBlog
      		left outer join Post P on P.idBlog = B.idBlog
      		left outer join Post_Tag PT on P.idPost = PT.idPost
		  	left outer join Tag T on PT.idTag = T.idTag
    &lt;/select&gt;

&lt;/mapper&gt;
</pre>
<div>Notice that this is a best practice. You should try to avoid the N+1 Selects problem.</div>
<h2>3 &#8211; BlogDAO</h2>
<div>Now that we have all the configuration we need, let&#8217;s write our DAO:</div>
<div>There are 2 methods: the first one will retrieve the blog data using the first approach: Nested Select and the second method will use the second approach: Nested Results.</div>
<pre class="brush: java; collapse: false; first-line: 1; title: ; toolbar: true; wrap-lines: false; notranslate">
package com.loiane.dao;

import java.util.List;

import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;

import com.loiane.model.Blog;

public class BlogDAO {

	/**
	 * Returns the list of all Contact instances from the database.
	 * @return the list of all Contact instances from the database.
	 */
	@SuppressWarnings(&quot;unchecked&quot;)
	public List&lt;Blog&gt; select(){

		SqlSessionFactory sqlSessionFactory = MyBatisConnectionFactory.getSqlSessionFactory();
		SqlSession session = sqlSessionFactory.openSession();

		try {
			List&lt;Blog&gt; list = session.selectList(&quot;Blog.selectBlog&quot;);
			return list;
		} finally {
			session.close();
		}
	}

	/**
	 * Returns the list of all Contact instances from the database avoiding the N + 1
	 * problem
	 * @return the list of all Contact instances from the database.
	 */
	@SuppressWarnings(&quot;unchecked&quot;)
	public List&lt;Blog&gt; selectN1ProblemSolution(){

		SqlSessionFactory sqlSessionFactory = MyBatisConnectionFactory.getSqlSessionFactory();
		SqlSession session = sqlSessionFactory.openSession();

		try {
			List&lt;Blog&gt; list = session.selectList(&quot;BlogBestPractice.selectBlogBestPractice&quot;);
			return list;
		} finally {
			session.close();
		}
	}
}
</pre>
<h2>4 &#8211; Annotations</h2>
<div>As there is an article explaining iBatis/MyBatis annotations already, I am going to list the differents annotations, ok?</div>
<div>We are going to write 3 selects (one for Blog, another one for Author and another one for Posts and Tags). It is the same thing we did using XML:</div>
<pre class="brush: java; collapse: false; first-line: 1; title: ; toolbar: true; wrap-lines: false; notranslate">
package com.loiane.data;

import java.util.List;

import org.apache.ibatis.annotations.Many;
import org.apache.ibatis.annotations.One;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;

import com.loiane.model.Author;
import com.loiane.model.Blog;
import com.loiane.model.Post;

public interface BlogMapper {

	final String SELECT_POSTS = &quot;SELECT  P.idPost as idPost, P.title as title, T.idTag as idTag, T.value as value &quot; +
			&quot;FROM Post P left outer join Post_Tag PT on P.idPost = PT.idPost &quot; +
			&quot;left outer join Tag T on PT.idTag = T.idTag WHERE P.idBlog = #{idBlog}&quot;;

	/**
	 * Returns the list of all Blog instances from the database.
	 * @return the list of all Blog instances from the database.
	 */
	@Select(&quot;SELECT idBlog, name as blogname, url as blogurl FROM BLOG&quot;)
	@Results(value = {
		@Result(property=&quot;id&quot;, column=&quot;idBlog&quot;),
		@Result(property=&quot;name&quot;, column=&quot;blogname&quot;),
		@Result(property=&quot;url&quot;, column=&quot;blogurl&quot;),
		@Result(property=&quot;author&quot;, column=&quot;idBlog&quot;, javaType=Author.class, one=@One(select=&quot;selectAuthor&quot;)),
		@Result(property=&quot;posts&quot;, column=&quot;idBlog&quot;, javaType=List.class, many=@Many(select=&quot;selectBlogPosts&quot;))
	})
	List&lt;Blog&gt; selectAllBlogs();

	/**
	 * Returns the list of all Author instances from the database of a Blog
	 * @param idBlog
	 * @return the list of all Author instances from the database of a Blog
	 */
	@Select(&quot;SELECT idAuthor as id, name, email FROM AUTHOR WHERE idBlog = #{idBlog}&quot;)
	Author selectAuthor(String idBlog);

	/**
	 * Returns the list of all Post instances from the database of a Blog
	 * @param idBlog
	 * @return the list of all Post instances from the database of a Blog
	 */
	@Select(SELECT_POSTS)
	@Results(value = {
		@Result(property=&quot;id&quot;, column=&quot;idPost&quot;),
		@Result(property=&quot;title&quot;, column=&quot;title&quot;),
		@Result(property=&quot;tags&quot;, column=&quot;idPost&quot;, javaType=List.class, many=@Many)
	})
	List&lt;Post&gt; selectBlogPosts(String idBlog);

}
</pre>
<div>We are going to set the <strong>has-one</strong> or <strong>has-many</strong> relationships using <strong>@One</strong> or <strong>@Many</strong> annotations.</div>
<h3><strong>@</strong><span style="font-weight: normal;">Result</span></h3>
<blockquote>
<div>A single result mapping between a column and a property or field.</div>
<div>Attributes: id, column, property, javaType, jdbcType, typeHandler, <strong>one</strong>, <strong>many</strong>.</div>
<div>The id attribute is a boolean value that indicates that the property should be used for comparisons (similar to &lt;id&gt; in the XML mappings).</div>
<div>The <strong>one </strong>attribute is for single associations, similar to &lt;association&gt;, and the <strong>many </strong>attribute is for collections, similar to &lt;collection&gt;. They are named as they are to avoid class naming conflicts.</div>
</blockquote>
<h3>@One</h3>
<blockquote>
<div>A mapping to a single property value of a complex type.</div>
<div>Attributes: select, which is the fully qualified name of a mapped statement (i.e. mapper method) that can load an instance of the appropriate type.</div>
<div><strong>Note</strong>: You will notice that join mapping is not supported via the Annotations API. This is due to the limitation in Java Annotations that does not allow for circular references.</div>
</blockquote>
<h3>@Many</h3>
<blockquote>
<div>A mapping to a collection property of a complex types.</div>
<div>Attributes: select, which is the fully qualified name of a mapped statement (i.e. mapper method) that can load a collection of instances of the appropriate types.</div>
<div><strong>Note</strong>: You will notice that join mapping is not supported via the Annotations API. This is due to the limitation in Java Annotations that does not allow for circular references.</div>
</blockquote>
<h2 style="font-size: 1.5em;">5 &#8211; SqlMapConfig.xml</h2>
<p>This is how our SqlMapConfig.xml looks like:</p>
<pre class="brush: xml; collapse: false; first-line: 1; title: ; toolbar: true; wrap-lines: false; notranslate">
&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
&lt;!DOCTYPE configuration
	PUBLIC &quot;-//mybatis.org//DTD Config 3.0//EN&quot;
	&quot;http://mybatis.org/dtd/mybatis-3-config.dtd&quot;&gt;

&lt;configuration&gt;

	&lt;typeAliases&gt;
		&lt;typeAlias alias=&quot;Blog&quot; type=&quot;com.loiane.model.Blog&quot;/&gt;
		&lt;typeAlias alias=&quot;Author&quot; type=&quot;com.loiane.model.Author&quot;/&gt;
		&lt;typeAlias alias=&quot;Post&quot; type=&quot;com.loiane.model.Post&quot;/&gt;
		&lt;typeAlias alias=&quot;Tag&quot; type=&quot;com.loiane.model.Tag&quot;/&gt;
	&lt;/typeAliases&gt;

	&lt;environments default=&quot;development&quot;&gt;
		&lt;environment id=&quot;development&quot;&gt;
		  &lt;transactionManager type=&quot;JDBC&quot;/&gt;
			&lt;dataSource type=&quot;POOLED&quot;&gt;
				&lt;property name=&quot;driver&quot; value=&quot;com.mysql.jdbc.Driver&quot;/&gt;
				&lt;property name=&quot;url&quot; value=&quot;jdbc:mysql://localhost:3306/blog_ibatis&quot;/&gt;
				&lt;property name=&quot;username&quot; value=&quot;root&quot;/&gt;
				&lt;property name=&quot;password&quot; value=&quot;root&quot;/&gt;
			&lt;/dataSource&gt;
	   &lt;/environment&gt;
	&lt;/environments&gt;

    &lt;mappers&gt;
  	   &lt;mapper resource=&quot;com/loiane/data/Blog.xml&quot;/&gt;
  	   &lt;mapper resource=&quot;com/loiane/data/BlogBestPractice.xml&quot;/&gt;
    &lt;/mappers&gt;

&lt;/configuration&gt;
</pre>
<h2>6 - MyBatisConnectionFactory</h2>
<div>As you can see, we set alias and 2 mappers on the SqlMapConfig.xml. But we also have a annotation mapper in this project.</div>
<div>We have to set it on the MyBatisConnectionFactory. This is how you can use both: XML and annotations, though I thing it is best if you use only one.</div>
<pre class="brush: java; collapse: false; first-line: 1; highlight: [27]; title: ; toolbar: true; wrap-lines: false; notranslate">
package com.loiane.dao;

import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.Reader;

import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;

import com.loiane.data.BlogMapper;

public class MyBatisConnectionFactory {

	private static SqlSessionFactory sqlSessionFactory;

	static {

		try {

			String resource = &quot;SqlMapConfig.xml&quot;;
			Reader reader = Resources.getResourceAsReader(resource);

			if (sqlSessionFactory == null) {
				sqlSessionFactory = new SqlSessionFactoryBuilder().build(reader);

				sqlSessionFactory.getConfiguration().addMapper(BlogMapper.class);
			}
		}

		catch (FileNotFoundException fileNotFoundException) {
			fileNotFoundException.printStackTrace();
		}
		catch (IOException iOException) {
			iOException.printStackTrace();
		}
	}

	public static SqlSessionFactory getSqlSessionFactory() {

		return sqlSessionFactory;
	}
}
</pre>
<h2 style="text-align: justify;">Download</h2>
<p style="text-align: justify;">If you want to download the complete sample project, you can get it from my GitHub account: <a href="https://github.com/loiane/ibatis-handling-joins" target="_blank">https://github.com/loiane/ibatis-handling-joins</a></p>
<p style="text-align: justify;">If you want to download the zip file of the project, just click on download:</p>
<p style="text-align: center;"><a href="http://loianegroner.com/wp-content/uploads/2011/01/donwload-github-example-loiane.png" target="_blank"><img class="aligncenter size-full wp-image-727" title="donwload-github-example-loiane" src="http://loianegroner.com/wp-content/uploads/2011/01/donwload-github-example-loiane.png" alt="" width="572" height="219" /></a></p>
<p style="text-align: justify;">There are more articles about iBatis to come. Stay tooned!</p>
<p style="text-align: justify;">Happy Coding! <img src='http://loianegroner.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<div class="shr-publisher-767"></div><!-- Start Shareaholic LikeButtonSetBottom Automatic --><!-- End Shareaholic LikeButtonSetBottom Automatic --><img src="http://loianegroner.com/?ak_action=api_record_view&id=767&type=feed" alt="" /><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/LoianeGroner?a=LvQSvQUZjVI:JQ9_ff3holQ:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/LoianeGroner?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/LoianeGroner?a=LvQSvQUZjVI:JQ9_ff3holQ:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/LoianeGroner?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/LoianeGroner?a=LvQSvQUZjVI:JQ9_ff3holQ:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/LoianeGroner?i=LvQSvQUZjVI:JQ9_ff3holQ:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/LoianeGroner?a=LvQSvQUZjVI:JQ9_ff3holQ:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/LoianeGroner?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/LoianeGroner?a=LvQSvQUZjVI:JQ9_ff3holQ:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/LoianeGroner?i=LvQSvQUZjVI:JQ9_ff3holQ:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/LoianeGroner?a=LvQSvQUZjVI:JQ9_ff3holQ:I9og5sOYxJI"><img src="http://feeds.feedburner.com/~ff/LoianeGroner?d=I9og5sOYxJI" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/LoianeGroner/~4/LvQSvQUZjVI" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://loianegroner.com/2011/03/ibatis-mybatis-handling-joins-advanced-result-mapping-association-collections-n1-select-problem/feed/</wfw:commentRss>
		<slash:comments>16</slash:comments>
		<feedburner:origLink>http://loianegroner.com/2011/03/ibatis-mybatis-handling-joins-advanced-result-mapping-association-collections-n1-select-problem/</feedburner:origLink></item>
		<item>
		<title>Getting Started with iBatis (MyBatis): Annotations</title>
		<link>http://feedproxy.google.com/~r/LoianeGroner/~3/H3XTBEsNQTA/</link>
		<comments>http://loianegroner.com/2011/02/getting-started-with-ibatis-mybatis-annotations/#comments</comments>
		<pubDate>Mon, 21 Feb 2011 10:00:17 +0000</pubDate>
		<dc:creator>Loiane</dc:creator>
				<category><![CDATA[iBatis (MyBatis)]]></category>
		<category><![CDATA[annotations]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[delete]]></category>
		<category><![CDATA[iBatis]]></category>
		<category><![CDATA[ibatis annotation]]></category>
		<category><![CDATA[insert]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[MyBatis]]></category>
		<category><![CDATA[MyBatis annotation]]></category>
		<category><![CDATA[mySQL]]></category>
		<category><![CDATA[select]]></category>
		<category><![CDATA[update]]></category>

		<guid isPermaLink="false">http://loianegroner.com/?p=650</guid>
		<description><![CDATA[This tutorial will walk you through how to setup iBatis (MyBatis) in a simple Java project and will present examples using simple insert, update, select and delete statements using annotations. This is the third tutorial of the iBatis/MyBatis series, you can read the first 2 tutorials on the following links: Introduction to iBatis (MyBatis), An alternative to [...]]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop Automatic --><!-- End Shareaholic LikeButtonSetTop Automatic --><p style="text-align: justify;">This tutorial will walk you through how to setup <a href="http://www.mybatis.org/" target="_blank">iBatis</a> (<a href="http://www.mybatis.org/" target="_blank">MyBatis</a>) in a simple Java project and will present examples using simple insert, update, select and delete statements using annotations.</p>
<p style="text-align: justify;"><a href="http://loianegroner.com/wp-content/uploads/2011/01/ibatis_mybatis_loiane.png"><img class="aligncenter size-full wp-image-685" title="ibatis_mybatis_loiane" src="http://loianegroner.com/wp-content/uploads/2011/01/ibatis_mybatis_loiane.png" alt="" width="274" height="149" /></a></p>
<p style="text-align: justify;">This is the third tutorial of the iBatis/MyBatis series, you can read the first 2 tutorials on the following links:</p>
<ol style="text-align: justify;">
<li><strong><a title="Edit “Introduction to iBatis (MyBatis), An alternative to Hibernate and JDBC”" href="http://loianegroner.com/2011/02/introduction-to-ibatis-mybatis-an-alternative-to-hibernate-and-jdbc/" target="_blank">Introduction to iBatis (MyBatis), An alternative to Hibernate and JDBC</a></strong></li>
<li><strong><a title="Edit “Getting Started with iBatis (MyBatis): XML Configuration”" href="http://loianegroner.com/2011/02/getting-started-with-ibatis-mybatis-xml-configuration/" target="_blank">Getting Started with iBatis (MyBatis): XML Configuration</a></strong></li>
</ol>
<p style="text-align: justify;">iBatis/ MyBatis 3 offers a new feature: annotations. But it lacks examples and documentation about annotations. I started to explore and read the MyBatis mailing list archive to write this tutorial.</p>
<p style="text-align: justify;">Another thing you will notice is the limitation related to annotations. I am going to demonstrate some examples that you  can do with annotations in this tutorial. All the power of iBatis is in its XMl configuration.</p>
<p style="text-align: justify;">So let’s play a little bit with annotations. It is much simpler and you can use it for simple queries in small projects. As I already mentioned, if you want something more complex, you will have to use XML configuration.</p>
<p style="text-align: justify;">One more thing before we get started: this tutorial is the same as the previous one, but instead of XML, we are going to use annotations.</p>
<h2 style="text-align: justify;">Pre-Requisites</h2>
<p style="text-align: justify;">For this tutorial I am using:</p>
<p style="text-align: justify;">IDE: <a href="http://eclipse.org/" target="_blank">Eclipse</a> (you can use your favorite one)<br />
DataBase: <a href="http://dev.mysql.com/downloads/" target="_blank">MySQL</a><br />
Libs/jars: <a href="http://www.mybatis.org/" target="_blank">Mybatis</a>, <a href="http://dev.mysql.com/downloads/" target="_blank">MySQL</a> conector and <a href="http://www.junit.org/" target="_blank">JUnit</a> (for testing)</p>
<p style="text-align: justify;">This is how your project should look like:</p>
<p style="text-align: justify;"><a href="http://loianegroner.com/wp-content/uploads/2011/02/ibatis_mybatis_loiane_annotations.png"><img class="aligncenter size-full wp-image-817" title="ibatis_mybatis_loiane_annotations" src="http://loianegroner.com/wp-content/uploads/2011/02/ibatis_mybatis_loiane_annotations.png" alt="" width="271" height="373" /></a></p>
<h2 style="text-align: justify;">Sample Database</h2>
<p style="text-align: justify;">Please run this script into your database before getting started with the project implementation:</p>
<p style="text-align: justify;">I will not post the sample database here again. You can get it from the previous post about iBatis or download this sample project. The files are the same.</p>
<h2 style="text-align: justify;">1 &#8211; Contact POJO</h2>
<p style="text-align: justify;">We will create a POJO class first to respresent a contact with id, name, phone number and email address &#8211; same as previous post.</p>
<h2 style="text-align: justify;">2 &#8211; ContactMapper</h2>
<p style="text-align: justify;">In this file, we are going to set up all the queries using annotations. It is the MyBatis-Interface for the SQLSessionFactory.</p>
<p>A mapper class is simply an interface with method definitions that match up against the SqlSession methods.</p>
<p style="text-align: justify;">You can create some strings with the SQL code. Remember it has to be the same code as in XML Configuration.</p>
<pre class="brush: java; collapse: false; first-line: 1; title: ; toolbar: true; wrap-lines: false; notranslate">
package com.loiane.data;

import java.util.List;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import com.loiane.model.Contact;

public interface ContactMapper {

	final String SELECT_ALL = &quot;SELECT * FROM CONTACT&quot;;
	final String SELECT_BY_ID = &quot;SELECT * FROM CONTACT WHERE CONTACT_ID = #{id}&quot;;
	final String UPDATE = &quot;UPDATE CONTACT SET CONTACT_EMAIL = #{email}, CONTACT_NAME = #{name}, CONTACT_PHONE = #{phone} WHERE CONTACT_ID = #{id}&quot;;
	final String UPDATE_NAME = &quot;UPDATE CONTACT SET CONTACT_NAME = #{name} WHERE CONTACT_ID = #{id}&quot;;
	final String DELETE = &quot;DELETE FROM CONTACT WHERE CONTACT_ID = #{id}&quot;;
	final String INSERT = &quot;INSERT INTO CONTACT (CONTACT_EMAIL, CONTACT_NAME, CONTACT_PHONE) VALUES (#{name}, #{phone}, #{email})&quot;;

	/**
	 * Returns the list of all Contact instances from the database.
	 * @return the list of all Contact instances from the database.
	 */
	@Select(SELECT_ALL)
	@Results(value = {
		@Result(property=&quot;id&quot;, column=&quot;CONTACT_ID&quot;),
		@Result(property=&quot;name&quot;, column=&quot;CONTACT_NAME&quot;),
		@Result(property=&quot;phone&quot;, column=&quot;CONTACT_PHONE&quot;),
		@Result(property=&quot;email&quot;, column=&quot;CONTACT_EMAIL&quot;)
	})
	List selectAll();

	/**
	 * Returns a Contact instance from the database.
	 * @param id primary key value used for lookup.
	 * @return A Contact instance with a primary key value equals to pk. null if there is no matching row.
	 */
	@Select(SELECT_BY_ID)
	@Results(value = {
		@Result(property=&quot;id&quot;),
		@Result(property=&quot;name&quot;, column=&quot;CONTACT_NAME&quot;),
		@Result(property=&quot;phone&quot;, column=&quot;CONTACT_PHONE&quot;),
		@Result(property=&quot;email&quot;, column=&quot;CONTACT_EMAIL&quot;)
	})
	Contact selectById(int id);

	/**
	 * Updates an instance of Contact in the database.
	 * @param contact the instance to be updated.
	 */
	@Update(UPDATE)
	void update(Contact contact);

	/**
	 * Updates an instance of Contact in the database.
	 * @param name name value to be updated.
	 * @param id primary key value used for lookup.
	 */
	void updateName(@Param(&quot;name&quot;) String name, @Param(&quot;id&quot;) int id);

	/**
	 * Delete an instance of Contact from the database.
	 * @param id primary key value of the instance to be deleted.
	 */
	@Delete(DELETE)
	void delete(int id);

	/**
	 * Insert an instance of Contact into the database.
	 * @param contact the instance to be persisted.
	 */
	@Insert(INSERT)
	@Options(useGeneratedKeys = true, keyProperty = &quot;id&quot;)
	void insert(Contact contact);
}
</pre>
<h3 style="text-align: justify;">@Select</h3>
<p style="text-align: justify;">The @Select annotation is very simple. Let&#8217;s take a look at the first select statment of this class: selectAll. Note that you don&#8217;t need to use the mapping if your database table columns mach the name of the class atributes. I used different names to use the @Result annotation. If table columns match with atribute names, you don&#8217;t need to use the @Result annotation.</p>
<p style="text-align: justify;">Not let&#8217;s take a look on the second method: selectById. Notice that we have a parameter. It is a simple parameter &#8211; easy to use when you have a <strong>single parameter.</strong></p>
<h3 style="text-align: justify;">@Update</h3>
<p style="text-align: justify;">Let&#8217;s say you want to update all the columns. You can pass the object as parameter and iBatis will do all the magic for you. Remember to mach the parameter name with the atribute name, otherwise iBatis can get confused,</p>
<p style="text-align: justify;">Now let&#8217;s say you want to use 2 or 3 paramaters, and they don&#8217;t belong to an object. If you take a look at iBatis XML configuration you will see you have to set the option parameterType (remember?) and specify you parameter type in it, in another words, you can use only one parameter. If you are using annotation, you can use more than one parameter using the @Param annotation.</p>
<h3 style="text-align: justify;">@Delete</h3>
<p style="text-align: justify;">The @Delete annotation is also very simple. It follows the previous rules related to parameters.</p>
<h3 style="text-align: justify;">@Insert</h3>
<p style="text-align: justify;">The @Insert annotation also follows the rules related to parameters. You can use an object or use the @Param annotation to specify more than one parameter.</p>
<p style="text-align: justify;">What about the generation key? Well, if your database supports auto generation key, you can set it up using annotations with the @Options annotation. You will need to specify the option useGeneratedKeys and keyProperty. If your database does not support auto generation key, sorry, but I still did not figure out how to do it (in last case, use can do it manually and then pass as parameter to your insert query).</p>
<h2 style="text-align: justify;">3 &#8211; MyBatisConnectionFactory</h2>
<p style="text-align: justify;">Every MyBatis application centers around an instance of SqlSessionFactory. A SqlSessionFactory instance can be acquired by using the SqlSessionFactoryBuilder. SqlSessionFactoryBuilder can build a SqlSessionFactory instance from an XML configuration file, of from a custom prepared instance of the Configuration class.</p>
<p style="text-align: justify;">An observation about this file: on the previous example, we set the mappers on the iBatis Configuration XML file. Using annotations, we will set the mapper manually. In a future example, I&#8217;ll show you how to work with XML and Annotations together.</p>
<pre class="brush: java; collapse: false; first-line: 1; highlight: [27]; title: ; toolbar: true; wrap-lines: false; notranslate">
package com.loiane.dao;

import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.Reader;

import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;

import com.loiane.data.ContactMapper;

public class MyBatisConnectionFactory {

	private static SqlSessionFactory sqlSessionFactory;

	static {

		try {

			String resource = &quot;SqlMapConfig.xml&quot;;
			Reader reader = Resources.getResourceAsReader(resource);

			if (sqlSessionFactory == null) {
				sqlSessionFactory = new SqlSessionFactoryBuilder().build(reader);

				sqlSessionFactory.getConfiguration().addMapper(ContactMapper.class);
			}
		}

		catch (FileNotFoundException fileNotFoundException) {
			fileNotFoundException.printStackTrace();
		}
		catch (IOException iOException) {
			iOException.printStackTrace();
		}
	}

	public static SqlSessionFactory getSqlSessionFactory() {

		return sqlSessionFactory;
	}

}
</pre>
<h2 style="text-align: justify;">4 &#8211; ContactDAO</h2>
<p style="text-align: justify;">Now that we set up everything needed, let&#8217;s create our DAO. To call the sql statments, we need to do one more configuration, that is to set and get the mapper from the SqlSessionFactory. Then we just need to call the mapper method. It is a little bit different, but it does the same thing.</p>
<pre class="brush: java; collapse: false; first-line: 1; highlight: [29,49,68,88]; title: ; toolbar: true; wrap-lines: false; notranslate">
package com.loiane.dao;

import java.util.List;

import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;

import com.loiane.data.ContactMapper;
import com.loiane.model.Contact;

public class ContactDAO {

	private SqlSessionFactory sqlSessionFactory;

	public ContactDAO(){
		sqlSessionFactory = MyBatisConnectionFactory.getSqlSessionFactory();
	}

	/**
	 * Returns the list of all Contact instances from the database.
	 * @return the list of all Contact instances from the database.
	 */
	public List selectAll(){

		SqlSession session = sqlSessionFactory.openSession();

		try {

			ContactMapper mapper = session.getMapper(ContactMapper.class);
			List list = mapper.selectAll();

			return list;
		} finally {
			session.close();
		}
	}

	/**
	 * Returns a Contact instance from the database.
	 * @param id primary key value used for lookup.
	 * @return A Contact instance with a primary key value equals to pk. null if there is no matching row.
	 */
	public Contact selectById(int id){

		SqlSession session = sqlSessionFactory.openSession();

		try {

			ContactMapper mapper = session.getMapper(ContactMapper.class);
			Contact list = mapper.selectById(id);

			return list;
		} finally {
			session.close();
		}
	}

	/**
	 * Updates an instance of Contact in the database.
	 * @param contact the instance to be updated.
	 */
	public void update(Contact contact){

		SqlSession session = sqlSessionFactory.openSession();

		try {

			ContactMapper mapper = session.getMapper(ContactMapper.class);
			mapper.update(contact);

			session.commit();
		} finally {
			session.close();
		}
	}

	/**
	 * Updates an instance of Contact in the database.
	 * @param name name value to be updated.
	 * @param id primary key value used for lookup.
	 */
	public void updateName(String name, int id){

		SqlSession session = sqlSessionFactory.openSession();

		try {

			ContactMapper mapper = session.getMapper(ContactMapper.class);
			mapper.updateName(name, id);

			session.commit();
		} finally {
			session.close();
		}
	}

	/**
	 * Insert an instance of Contact into the database.
	 * @param contact the instance to be persisted.
	 */
	public void insert(Contact contact){

		SqlSession session = sqlSessionFactory.openSession();

		try {

			ContactMapper mapper = session.getMapper(ContactMapper.class);
			mapper.insert(contact);

			session.commit();
		} finally {
			session.close();
		}
	}

	/**
	 * Delete an instance of Contact from the database.
	 * @param id primary key value of the instance to be deleted.
	 */
	public void delete(int id){

		SqlSession session = sqlSessionFactory.openSession();

		try {

			ContactMapper mapper = session.getMapper(ContactMapper.class);
			mapper.delete(id);

			session.commit();
		} finally {
			session.close();
		}
	}
}
</pre>
<h2 style="text-align: justify;">5 &#8211; Mapper Configuration File</h2>
<p style="text-align: justify;">The MyBatis XML configuration file contains settings and properties that have a dramatic effect on how MyBatis behaves.</p>
<p style="text-align: justify;">This time, we do not need to configure alias or xml config files. We did all the magic with annotations, so we have a simple config file with only the information about the database we want to connect with.</p>
<pre class="brush: xml; collapse: false; first-line: 1; title: ; toolbar: true; wrap-lines: false; notranslate">
&lt;!--?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?--&gt;
</pre>
<h2 style="text-align: justify;">Download</h2>
<p style="text-align: justify;">I suggest you to take a look at the <em><strong>org.apache.ibatis.annotations</strong></em> package and try to find out what each annotation can do. Unfortunatelly, you won&#8217;t find much documentation or examples on MyBatis website.</p>
<p style="text-align: justify;">I also created a TestCase class. If you want to download the complete sample project, you can get it from my GitHub account: <a href="https://github.com/loiane/ibatis-annotations-helloworld" target="_blank">https://github.com/loiane/ibatis-annotations-helloworld</a></p>
<p style="text-align: justify;">If you want to download the zip file of the project, just click on download:</p>
<p style="text-align: center;"><a href="http://loianegroner.com/wp-content/uploads/2011/01/donwload-github-example-loiane.png" target="_blank"><img class="aligncenter size-full wp-image-727" title="donwload-github-example-loiane" src="http://loianegroner.com/wp-content/uploads/2011/01/donwload-github-example-loiane.png" alt="" width="572" height="219" /></a></p>
<p style="text-align: justify;">There are more articles about iBatis to come. Stay tooned!</p>
<p style="text-align: justify;">In next articles, I&#8217;m going to demonstrate how to implement the feature using XML and then Annotations (when it is possible).</p>
<p style="text-align: justify;">Happy Coding! <img src='http://loianegroner.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<div class="shr-publisher-650"></div><!-- Start Shareaholic LikeButtonSetBottom Automatic --><!-- End Shareaholic LikeButtonSetBottom Automatic --><img src="http://loianegroner.com/?ak_action=api_record_view&id=650&type=feed" alt="" /><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/LoianeGroner?a=H3XTBEsNQTA:WekB9d84_nE:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/LoianeGroner?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/LoianeGroner?a=H3XTBEsNQTA:WekB9d84_nE:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/LoianeGroner?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/LoianeGroner?a=H3XTBEsNQTA:WekB9d84_nE:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/LoianeGroner?i=H3XTBEsNQTA:WekB9d84_nE:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/LoianeGroner?a=H3XTBEsNQTA:WekB9d84_nE:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/LoianeGroner?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/LoianeGroner?a=H3XTBEsNQTA:WekB9d84_nE:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/LoianeGroner?i=H3XTBEsNQTA:WekB9d84_nE:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/LoianeGroner?a=H3XTBEsNQTA:WekB9d84_nE:I9og5sOYxJI"><img src="http://feeds.feedburner.com/~ff/LoianeGroner?d=I9og5sOYxJI" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/LoianeGroner/~4/H3XTBEsNQTA" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://loianegroner.com/2011/02/getting-started-with-ibatis-mybatis-annotations/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		<feedburner:origLink>http://loianegroner.com/2011/02/getting-started-with-ibatis-mybatis-annotations/</feedburner:origLink></item>
		<item>
		<title>Getting Started with iBatis (MyBatis): XML Configuration</title>
		<link>http://feedproxy.google.com/~r/LoianeGroner/~3/qKhg07yCSJs/</link>
		<comments>http://loianegroner.com/2011/02/getting-started-with-ibatis-mybatis-xml-configuration/#comments</comments>
		<pubDate>Mon, 14 Feb 2011 10:00:31 +0000</pubDate>
		<dc:creator>Loiane</dc:creator>
				<category><![CDATA[iBatis (MyBatis)]]></category>
		<category><![CDATA[delete]]></category>
		<category><![CDATA[iBatis]]></category>
		<category><![CDATA[insert]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[MyBatis]]></category>
		<category><![CDATA[mySQL]]></category>
		<category><![CDATA[select]]></category>
		<category><![CDATA[update]]></category>
		<category><![CDATA[xml configuration]]></category>

		<guid isPermaLink="false">http://loianegroner.com/?p=648</guid>
		<description><![CDATA[This tutorial will walk you through how to setup iBatis (MyBatis) in a simple Java project and will present examples using simple insert, update, select and delete statements. Pre-Requisites For this tutorial I am using: IDE: Eclipse (you can use your favorite one) DataBase: MySQL Libs/jars: Mybatis, MySQL conector and JUnit (for testing) This is [...]]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop Automatic --><!-- End Shareaholic LikeButtonSetTop Automatic --><p style="text-align: justify;">This tutorial will walk you through how to setup <a href="http://www.mybatis.org/" target="_blank">iBatis</a> (<a href="http://www.mybatis.org/" target="_blank">MyBatis</a>) in a simple Java project and will present examples using simple insert, update, select and delete statements.</p>
<p style="text-align: justify;"><a href="http://loianegroner.com/wp-content/uploads/2011/01/ibatis_mybatis_loiane.png"><img class="aligncenter size-full wp-image-685" title="ibatis_mybatis_loiane" src="http://loianegroner.com/wp-content/uploads/2011/01/ibatis_mybatis_loiane.png" alt="" width="274" height="149" /></a></p>
<h2 style="text-align: justify;">Pre-Requisites</h2>
<p style="text-align: justify;">For this tutorial I am using:</p>
<p style="text-align: justify;"><strong><em>IDE</em></strong>: <a href="http://eclipse.org/" target="_blank">Eclipse</a> (you can use your favorite one)<br />
<strong><em> DataBase</em></strong>: <a href="http://dev.mysql.com/downloads/" target="_blank">MySQL</a><br />
<strong><em> Libs/jars</em></strong>: <a href="http://www.mybatis.org/" target="_blank">Mybatis</a>, <a href="http://dev.mysql.com/downloads/" target="_blank">MySQL</a> conector and <a href="http://www.junit.org/" target="_blank">JUnit</a> (for testing)</p>
<p style="text-align: justify;">This is how your project should look like:</p>
<p style="text-align: justify;"><a href="http://loianegroner.com/wp-content/uploads/2011/01/ibatis_mybatis_helloworld_loiane.png"><img class="aligncenter size-full wp-image-731" title="ibatis_mybatis_helloworld_loiane" src="http://loianegroner.com/wp-content/uploads/2011/01/ibatis_mybatis_helloworld_loiane.png" alt="" width="269" height="358" /></a></p>
<h2 style="text-align: justify;">Sample Database</h2>
<p style="text-align: justify;">Please run this script into your database before getting started with the project implementation:</p>
<pre class="brush: sql; collapse: false; first-line: 1; title: ; toolbar: true; wrap-lines: false; notranslate">
DROP TABLE IF EXISTS `blog`.`contact`;
CREATE TABLE  `blog`.`contact` (
  `CONTACT_ID` int(11) NOT NULL AUTO_INCREMENT,
  `CONTACT_EMAIL` varchar(255) NOT NULL,
  `CONTACT_NAME` varchar(255) NOT NULL,
  `CONTACT_PHONE` varchar(255) NOT NULL,
  PRIMARY KEY (`CONTACT_ID`)
)
ENGINE=InnoDB;

insert into CONTACT (CONTACT_NAME, CONTACT_PHONE, CONTACT_EMAIL) values ('Contact0','(000) 000-0000', 'contact0@loianetest.com');
insert into CONTACT (CONTACT_NAME, CONTACT_PHONE, CONTACT_EMAIL) values ('Contact1', '(000) 000-0000', 'contact1@loianetest.com');
insert into CONTACT (CONTACT_NAME, CONTACT_PHONE, CONTACT_EMAIL) values ('Contact2', '(000) 000-0000', 'contact2@loianetest.com');
insert into CONTACT (CONTACT_NAME, CONTACT_PHONE, CONTACT_EMAIL) values ('Contact3', '(000) 000-0000', 'contact3@loianetest.com');
insert into CONTACT (CONTACT_NAME, CONTACT_PHONE, CONTACT_EMAIL) values ('Contact4', '(000) 000-0000', 'contact4@loianetest.com');
insert into CONTACT (CONTACT_NAME, CONTACT_PHONE, CONTACT_EMAIL) values ('Contact5', '(000) 000-0000', 'contact5@loianetest.com');
insert into CONTACT (CONTACT_NAME, CONTACT_PHONE, CONTACT_EMAIL) values ('Contact6', '(000) 000-0000', 'contact6@loianetest.com');
insert into CONTACT (CONTACT_NAME, CONTACT_PHONE, CONTACT_EMAIL) values ('Contact7', '(000) 000-0000', 'contact7@loianetest.com');
insert into CONTACT (CONTACT_NAME, CONTACT_PHONE, CONTACT_EMAIL) values ('Contact8', '(000) 000-0000', 'contact8@loianetest.com');
insert into CONTACT (CONTACT_NAME, CONTACT_PHONE, CONTACT_EMAIL) values ('Contact9', '(000) 000-0000', 'contact9@loianetest.com');
insert into CONTACT (CONTACT_NAME, CONTACT_PHONE, CONTACT_EMAIL) values ('Contact10', '(000) 000-0000', 'contact10@loianetest.com');
insert into CONTACT (CONTACT_NAME, CONTACT_PHONE, CONTACT_EMAIL) values ('Contact11', '(000) 000-0000', 'contact11@loianetest.com');
insert into CONTACT (CONTACT_NAME, CONTACT_PHONE, CONTACT_EMAIL) values ('Contact12', '(000) 000-0000', 'contact12@loianetest.com');
insert into CONTACT (CONTACT_NAME, CONTACT_PHONE, CONTACT_EMAIL) values ('Contact13', '(000) 000-0000', 'contact13@loianetest.com');
insert into CONTACT (CONTACT_NAME, CONTACT_PHONE, CONTACT_EMAIL) values ('Contact14', '(000) 000-0000', 'contact14@loianetest.com');
insert into CONTACT (CONTACT_NAME, CONTACT_PHONE, CONTACT_EMAIL) values ('Contact15', '(000) 000-0000', 'contact15@loianetest.com');
insert into CONTACT (CONTACT_NAME, CONTACT_PHONE, CONTACT_EMAIL) values ('Contact16', '(000) 000-0000', 'contact16@loianetest.com');
insert into CONTACT (CONTACT_NAME, CONTACT_PHONE, CONTACT_EMAIL) values ('Contact17', '(000) 000-0000', 'contact17@loianetest.com');
insert into CONTACT (CONTACT_NAME, CONTACT_PHONE, CONTACT_EMAIL) values ('Contact18', '(000) 000-0000', 'contact18@loianetest.com');
insert into CONTACT (CONTACT_NAME, CONTACT_PHONE, CONTACT_EMAIL) values ('Contact19', '(000) 000-0000', 'contact19@loianetest.com');
</pre>
<h2 style="text-align: justify;">1 &#8211; Contact POJO</h2>
<p style="text-align: justify;">We will create a POJO class first to respresent a contact with id, name, phone number and email address:</p>
<pre class="brush: java; collapse: false; first-line: 1; title: ; toolbar: true; wrap-lines: false; notranslate">
package com.loiane.model;

public class Contact {

	private int id;
	private String name;
	private String phone;
	private String email;

	public Contact(int id, String name, String phone, String email) {
		super();
		this.id = id;
		this.name = name;
		this.phone = phone;
		this.email = email;
	}

	public Contact() {}

	//getters and setters
}
</pre>
<h2 style="text-align: justify;">2 &#8211; Contact.xml</h2>
<p style="text-align: justify;">This is the iBatis/myBatis SQL map configuration file for Contact class. We are going to write all the SQL queries, map a query to object in this file &#8211; here is where all the magic happens!</p>
<pre class="brush: xml; collapse: false; first-line: 1; title: ; toolbar: true; wrap-lines: false; notranslate">
&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
&lt;!DOCTYPE mapper
  PUBLIC &quot;-//mybatis.org//DTD Mapper 3.0//EN&quot;
	&quot;http://mybatis.org/dtd/mybatis-3-mapper.dtd&quot;&gt;

&lt;mapper namespace=&quot;Contact&quot;&gt;

	&lt;resultMap id=&quot;result&quot; type=&quot;Contact&quot;&gt;
	    &lt;result property=&quot;id&quot; column=&quot;CONTACT_ID&quot;/&gt;
	    &lt;result property=&quot;name&quot; column=&quot;CONTACT_NAME&quot;/&gt;
	    &lt;result property=&quot;phone&quot; column=&quot;CONTACT_PHONE&quot;/&gt;
	    &lt;result property=&quot;email&quot; column=&quot;CONTACT_EMAIL&quot;/&gt;
    &lt;/resultMap&gt;

    &lt;select id=&quot;getAll&quot; resultMap=&quot;result&quot;&gt;
    	SELECT * FROM CONTACT
    &lt;/select&gt;

    &lt;select id=&quot;getById&quot; parameterType=&quot;int&quot; resultMap=&quot;result&quot;&gt;
    	SELECT * FROM CONTACT WHERE CONTACT_ID = #{id}
  	&lt;/select&gt;

    &lt;delete id=&quot;deleteById&quot; parameterType=&quot;int&quot;&gt;
    	DELETE from CONTACT WHERE CONTACT_ID = #{id};
    &lt;/delete&gt;

    &lt;insert id=&quot;insert&quot; parameterType=&quot;Contact&quot;&gt;
    INSERT INTO CONTACT (CONTACT_EMAIL, CONTACT_NAME, CONTACT_PHONE)
		VALUES (#{name}, #{phone}, #{email});
      &lt;selectKey keyProperty=&quot;id&quot; resultType=&quot;int&quot; order=&quot;AFTER&quot;&gt;
		select last_insert_id() as id
	  &lt;/selectKey&gt;
    &lt;/insert&gt;

	&lt;update id=&quot;update&quot; parameterType=&quot;Contact&quot;&gt;
	  	UPDATE CONTACT
		SET
			CONTACT_EMAIL = #{email},
			CONTACT_NAME = #{name},
			CONTACT_PHONE = #{phone}
		WHERE CONTACT_ID = #{id};
  &lt;/update&gt;

&lt;/mapper&gt;
</pre>
<p>What this file contains:</p>
<ul>
<li><em>resultMap</em> – The most complicated and powerful element that describes how to load your objects from the database result sets.</li>
<li><em>insert</em> – A mapped INSERT statement.</li>
<li><em>update</em> – A mapped UPDATE statement.</li>
<li><em>delete</em> – A mapped DELEETE statement.</li>
<li><em>select</em> – A mapped SELECT statement.</li>
</ul>
<h3 style="text-align: justify;">Result Map</h3>
<blockquote>
<p style="text-align: justify;">The resultMap element is the most important and powerful element in MyBatis. It’s what allows you to do away with 90% of the code that JDBC requires to retrieve data from ResultSets, and in some cases allows you to do things that JDBC does not even support. In fact, to write the equivalent code for something like a join mapping for a complex statement could probably span thousands of lines of code. The design of the ResultMaps is such that simple statements don’t require explicit result mappings at all, and more complex statements require no more than is absolutely necessary to describe the relationships.</p>
</blockquote>
<p style="text-align: justify;">In this example, the name of the table column is different from the Contact class. That is why we have to map the column with the class property. If the column name is the same as the property, you do not need to use the <em>column=&#8221;"</em> option in the result map.</p>
<p style="text-align: justify;">And remember that TypeAliases are your friend. Use them so that you don’t have to keep typing the fully qualified path of your class out. &#8211; we are going to set it in the myBatis main configuration file.</p>
<h3 style="text-align: justify;">Select statment</h3>
<p style="text-align: justify;">The first select statment in this example is called &#8220;<em>getAll</em>&#8220;, and it means we are going to use this id to call the statment in DAO class. The other option we set is the resultMap, which we mapped to contact class, and it means the statment is going to return a list of contacts (List).</p>
<p style="text-align: justify;">The second select statment in this example is called &#8220;<em>getById</em>&#8220;. We set a option called parameter of type  int (or Integer) and it returns a object of type Contact. Notice the parameter notation <em>#{id}</em>. This tells MyBatis to create a PreparedStatement parameter. With JDBC, such a parameter would be identified by a “?” in SQL passed to a new PreparedStatement.</p>
<h3>Delete Statment</h3>
<p style="text-align: justify;">The delete statment is also very simple. We set a parameter type called id (same thing as <em>getById</em> statment) so we can filter what it is going to be deleted.</p>
<h3>Update Statment</h3>
<p style="text-align: justify;">In the update statement we ser a parameter of type Contact, which means we are going to pass a contact object as parameter to the update method in DAO class. Note the parameter notation #{name}, #{phone}, #{email} and #{id}. All the parameters must have the same name as contact properties, otherwise myBatis will not be able to map the object-parameters.</p>
<h3>Insert Statment</h3>
<blockquote>
<p style="text-align: justify;">Insert is a little bit more rich in that it has a few extra attributes and sub-elements that allow it to deal with key generation in a number of ways. First, if your database supports auto-generated key fields (e.g. MySQL and SQL Server), then you can simply set useGeneratedKeys=”true” and set the keyProperty to the target property and you’re done.</p>
<p style="text-align: justify;">MyBatis has another way to deal with key generation for databases that don’t support auto-generated column types, or perhaps don’t yet support the JDBC driver support for auto-generated keys.</p>
</blockquote>
<p style="text-align: justify;">In this example, we are going to set manually the generated id in the object with the <em>selectKey</em> option. In this example, the <em>selectKey</em> would be run after the insert statment and with the <em>last_insert_id</em>() function we will get the last generated key (of type int) and set it to the id property.</p>
<h2>3 &#8211; Mapper Configuration File</h2>
<p>The MyBatis XML configuration file contains settings and properties that have a dramatic effect on how MyBatis behaves. The high level structure of the document is as follows:</p>
<ul>
<li>Configuration
<ul>
<li>properties</li>
<li>settings</li>
<li>typeAliases</li>
<li>typeHandlers</li>
<li>objectFactory</li>
<li>plugins</li>
<li>environments
<ul>
<li>environment
<ul>
<li>transactionManager</li>
<li>dataSource</li>
</ul>
</li>
</ul>
</li>
</ul>
</li>
<li>mappers</li>
</ul>
<p style="text-align: justify;">Hint: you have to follow the order above, otherwise you will get an exception.</p>
<p style="text-align: justify;">The SqlMapConfig.xml from our project:</p>
<pre class="brush: xml; collapse: false; first-line: 1; title: ; toolbar: true; wrap-lines: false; notranslate">
&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
&lt;!DOCTYPE configuration
	PUBLIC &quot;-//mybatis.org//DTD Config 3.0//EN&quot;
	&quot;http://mybatis.org/dtd/mybatis-3-config.dtd&quot;&gt;

&lt;configuration&gt;

	&lt;typeAliases&gt;
		&lt;typeAlias alias=&quot;Contact&quot; type=&quot;com.loiane.model.Contact&quot;/&gt;
	&lt;/typeAliases&gt;

	&lt;environments default=&quot;development&quot;&gt;
		&lt;environment id=&quot;development&quot;&gt;
		  &lt;transactionManager type=&quot;JDBC&quot;/&gt;
			&lt;dataSource type=&quot;POOLED&quot;&gt;
				&lt;property name=&quot;driver&quot; value=&quot;com.mysql.jdbc.Driver&quot;/&gt;
				&lt;property name=&quot;url&quot; value=&quot;jdbc:mysql://localhost:3306/blog&quot;/&gt;
				&lt;property name=&quot;username&quot; value=&quot;root&quot;/&gt;
				&lt;property name=&quot;password&quot; value=&quot;root&quot;/&gt;
			&lt;/dataSource&gt;
	   &lt;/environment&gt;
	&lt;/environments&gt;

    &lt;mappers&gt;
  	   &lt;mapper resource=&quot;com/loiane/data/Contact.xml&quot;/&gt;
    &lt;/mappers&gt;

&lt;/configuration&gt;
</pre>
<p style="text-align: justify;">Let&#8217;s take a look at the configuration properties we are using.</p>
<h3>Type Aliases</h3>
<blockquote>
<p style="text-align: justify;">A type alias is simply a shorter name for a Java type. It&#8217;s only relevant to the XML configuration and simply exists to reduce redundant typing of fully qualified classnames.</p>
</blockquote>
<p style="text-align: justify;">Remember we used Contact as type in the resultMap property in Contact.xml ()? This is a great help!</p>
<h3>Environments</h3>
<blockquote>
<p style="text-align: justify;">MyBatis can be configured with multiple environments. This helps you to apply your SQL Maps to multiple databases for any number of reasons. For example, you might have a different configuration for your Development, Test and Production environments. Or, you may have multiple production databases that share the same schema, and you’d like to use the same SQL maps for both. There are many use cases.</p>
<p style="text-align: justify;">One important thing to remember though: While you can configure multiple environments, you can only choose ONE per SqlSessionFactory instance.</p>
<p style="text-align: justify;">The default environment and the environment IDs are self explanatory. Name them whatever you like, just make sure the default matches one of them.</p>
</blockquote>
<h3>Transaction Manager</h3>
<p>There are two TransactionManager types (i.e. type=”[JDBC|MANAGED]”) that are included with MyBatis:</p>
<ul>
<blockquote>
<li>JDBC – This configuration simply makes use of the JDBC commit and rollback facilities directly. It relies on the connection retrieved from the dataSource to manage the scope of the transaction.</li>
<li>MANAGED – This configuration simply does almost nothing. It never commits, or rolls back a connection. Instead, it lets the container manage the full lifecycle of the transaction (e.g. Spring or a JEE Application Server context). By default it does close the connection. However, some containers don’t expect this, and thus if you need to stop it from closing the connection, set the closeConnection property to false.</li>
</blockquote>
</ul>
<p style="text-align: justify;">In this example we are going to use JDBC.</p>
<h3>Data Source</h3>
<p>The dataSource element configures the source of JDBC Connection objects using the standard JDBC DataSource interface.</p>
<ul>
<li>driver – This is the fully qualified Java class of the JDBC driver (NOT of the DataSource class if your driver includes one).</li>
<li>url – This is the JDBC URL for your database instance.</li>
<li>username – The database username to log in with.</li>
<li>password &#8211; The database password to log in with.</li>
</ul>
<h2>4 &#8211; MyBatisConnectionFactory</h2>
<blockquote>
<p style="text-align: justify;">Every MyBatis application centers around an instance of SqlSessionFactory. A SqlSessionFactory instance can be acquired by using the SqlSessionFactoryBuilder. SqlSessionFactoryBuilder can build a SqlSessionFactory instance from an XML configuration file, of from a custom prepared instance of the Configuration class.</p>
</blockquote>
<pre class="brush: java; collapse: false; first-line: 1; title: ; toolbar: true; wrap-lines: false; notranslate">
package com.loiane.dao;

import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.Reader;

import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;

public class MyBatisConnectionFactory {

	private static SqlSessionFactory sqlSessionFactory;

	static {
		try {

			String resource = &quot;SqlMapConfig.xml&quot;;
			Reader reader = Resources.getResourceAsReader(resource);

			if (sqlSessionFactory == null) {
				sqlSessionFactory = new SqlSessionFactoryBuilder().build(reader);
			}
		}
		catch (FileNotFoundException fileNotFoundException) {
			fileNotFoundException.printStackTrace();
		}
		catch (IOException iOException) {
			iOException.printStackTrace();
		}
	}

	public static SqlSessionFactory getSqlSessionFactory() {

		return sqlSessionFactory;
	}
}
</pre>
<h2>5 &#8211; ContactDAO</h2>
<p style="text-align: justify;">Now that we set up everything needed, let&#8217;s create our DAO. To call the sql statments, we need to call the namespace and the name of the SQl statment as follows:</p>
<pre class="brush: java; collapse: false; first-line: 1; title: ; toolbar: true; wrap-lines: false; notranslate">
package com.loiane.dao;

import java.util.List;

import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;

import com.loiane.model.Contact;

public class ContactDAO {

	private SqlSessionFactory sqlSessionFactory;

	public ContactDAO(){
		sqlSessionFactory = MyBatisConnectionFactory.getSqlSessionFactory();
	}

	/**
	 * Returns the list of all Contact instances from the database.
	 * @return the list of all Contact instances from the database.
	 */
	@SuppressWarnings(&quot;unchecked&quot;)
	public List&lt;Contact&gt; selectAll(){

		SqlSession session = sqlSessionFactory.openSession();

		try {
			List&lt;Contact&gt; list = session.selectList(&quot;Contact.getAll&quot;);
			return list;
		} finally {
			session.close();
		}
	}

	/**
	 * Returns a Contact instance from the database.
	 * @param id primary key value used for lookup.
	 * @return A Contact instance with a primary key value equals to pk. null if there is no matching row.
	 */
	public Contact selectById(int id){

		SqlSession session = sqlSessionFactory.openSession();

		try {
			Contact contact = (Contact) session.selectOne(&quot;Contact.getById&quot;,id);
			return contact;
		} finally {
			session.close();
		}
	}

	/**
	 * Updates an instance of Contact in the database.
	 * @param contact the instance to be updated.
	 */
	public void update(Contact contact){

		SqlSession session = sqlSessionFactory.openSession();

		try {
			session.update(&quot;Contact.update&quot;, contact);
			session.commit();
		} finally {
			session.close();
		}
	}

	/**
	 * Insert an instance of Contact into the database.
	 * @param contact the instance to be persisted.
	 */
	public void insert(Contact contact){

		SqlSession session = sqlSessionFactory.openSession();

		try {
			session.insert(&quot;Contact.insert&quot;, contact);
			session.commit();
		} finally {
			session.close();
		}
	}

	/**
	 * Delete an instance of Contact from the database.
	 * @param id primary key value of the instance to be deleted.
	 */
	public void delete(int id){

		SqlSession session = sqlSessionFactory.openSession();

		try {
			session.delete(&quot;Contact.deleteById&quot;, id);
			session.commit();
		} finally {
			session.close();
		}
	}
}
</pre>
<h2>Download</h2>
<p style="text-align: justify;">If you want to learn more about the MyBatis configuration options, please read the User Guide. You will find everything you need there. All the quoted sentences are from the MyBatis 3 User Guid. I also used it as reference to implement this sample project.</p>
<p style="text-align: justify;">I also created a TestCase class. If you want to download the complete sample project, you can get it from my GitHub account: <a href="https://github.com/loiane/ibatis-helloworld" target="_blank">https://github.com/loiane/ibatis-helloworld</a></p>
<p style="text-align: justify;">If you want to download the zip file of the project, just click on download:</p>
<p style="text-align: center;"><a href="http://loianegroner.com/wp-content/uploads/2011/01/donwload-github-example-loiane.png" target="_blank"><img class="aligncenter size-full wp-image-727" title="donwload-github-example-loiane" src="http://loianegroner.com/wp-content/uploads/2011/01/donwload-github-example-loiane.png" alt="" width="572" height="219" /></a></p>
<p style="text-align: justify;">Next articles we are going to explore more iBatis/MyBatis options! <img src='http://loianegroner.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p style="text-align: justify;">Happy Coding!</p>
<div class="shr-publisher-648"></div><!-- Start Shareaholic LikeButtonSetBottom Automatic --><!-- End Shareaholic LikeButtonSetBottom Automatic --><img src="http://loianegroner.com/?ak_action=api_record_view&id=648&type=feed" alt="" /><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/LoianeGroner?a=qKhg07yCSJs:LHrL3RB8oto:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/LoianeGroner?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/LoianeGroner?a=qKhg07yCSJs:LHrL3RB8oto:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/LoianeGroner?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/LoianeGroner?a=qKhg07yCSJs:LHrL3RB8oto:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/LoianeGroner?i=qKhg07yCSJs:LHrL3RB8oto:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/LoianeGroner?a=qKhg07yCSJs:LHrL3RB8oto:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/LoianeGroner?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/LoianeGroner?a=qKhg07yCSJs:LHrL3RB8oto:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/LoianeGroner?i=qKhg07yCSJs:LHrL3RB8oto:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/LoianeGroner?a=qKhg07yCSJs:LHrL3RB8oto:I9og5sOYxJI"><img src="http://feeds.feedburner.com/~ff/LoianeGroner?d=I9og5sOYxJI" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/LoianeGroner/~4/qKhg07yCSJs" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://loianegroner.com/2011/02/getting-started-with-ibatis-mybatis-xml-configuration/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		<feedburner:origLink>http://loianegroner.com/2011/02/getting-started-with-ibatis-mybatis-xml-configuration/</feedburner:origLink></item>
		<item>
		<title>Introduction to iBatis (MyBatis), An alternative to Hibernate and JDBC</title>
		<link>http://feedproxy.google.com/~r/LoianeGroner/~3/jcSlvL0UAAo/</link>
		<comments>http://loianegroner.com/2011/02/introduction-to-ibatis-mybatis-an-alternative-to-hibernate-and-jdbc/#comments</comments>
		<pubDate>Mon, 07 Feb 2011 10:00:59 +0000</pubDate>
		<dc:creator>Loiane</dc:creator>
				<category><![CDATA[iBatis (MyBatis)]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[iBatis]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[MyBatis]]></category>
		<category><![CDATA[persistence framework]]></category>

		<guid isPermaLink="false">http://loianegroner.com/?p=646</guid>
		<description><![CDATA[I started to write a new article series about iBatis/MyBatis. This is the first article and it will walk you through what is iBatis/MyBatis and why you should use it. For those who does not know iBatis/MyBatis yet, it is a persistence framework – an alternative to JDBC and Hibernate, available for Java and .NET [...]]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop Automatic --><!-- End Shareaholic LikeButtonSetTop Automatic --><p style="text-align: justify;">I started to write a new article series about <a href="http://ibatis.apache.org/" target="_blank">iBatis</a>/<a href="http://www.mybatis.org/" target="_blank">MyBatis</a>. This is the first article and it will walk you through what is <a href="http://ibatis.apache.org/" target="_blank">iBatis</a>/<a href="http://www.mybatis.org/" target="_blank">MyBatis </a>and why you should use it.</p>
<p style="text-align: center;"><img class="size-full wp-image-685  aligncenter" title="ibatis_mybatis_loiane" src="http://loianegroner.com/wp-content/uploads/2011/01/ibatis_mybatis_loiane.png" alt="" width="274" height="149" /></p>
<p style="text-align: justify;">For those who does not know <a href="http://ibatis.apache.org/" target="_blank">iBatis</a>/<a href="http://www.mybatis.org/" target="_blank">MyBatis </a>yet, it is a persistence framework – an alternative to JDBC and <a href="http://www.hibernate.org/" target="_blank">Hibernate</a>, available for Java and .NET platforms. I&#8217;ve been working with it for almost two year, and I am enjoying it!</p>
<p style="text-align: justify;">The fisrt thin you may notice in this and following articles about iBatis/MyBatis is that I am using iBatis and Mybatis terms. Why? Until June 2010, iBatis was under Apache license and since then, the framework founders decided to move it to Google Code and they renamed it to MyBatis. The framework is still the same though, only has a different name now.</p>
<p style="text-align: justify;">I gathered some resources, so I am just going to quote them:</p>
<h3 style="text-align: justify;">What is MyBatis/iBatis?</h3>
<blockquote style="text-align: justify;"><p>The MyBatis data mapper framework makes it easier to use a relational database with object-oriented applications. MyBatis couples objects with stored procedures or SQL statements using a XML descriptor. Simplicity is the biggest advantage of the MyBatis data mapper over object relational mapping tools.<br />
To use the MyBatis data mapper, you rely on your own objects, XML, and SQL. There is little to learn that you don&#8217;t already know. With the MyBatis Data Mapper, you have the full power of both SQL and stored procedures at your fingertips.<br />
(<a href="http://www.mybatis.org" target="_blank">www.mybatis.org</a>)</p></blockquote>
<p style="text-align: justify;"><a href="http://loianegroner.com/wp-content/uploads/2011/01/flow_mybatis.png"><img class="aligncenter size-full wp-image-688" title="flow_mybatis" src="http://loianegroner.com/wp-content/uploads/2011/01/flow_mybatis.png" alt="" width="490" height="420" /></a></p>
<blockquote style="text-align: justify;"><p>iBATIS is based on the idea that there is value in relational databases and SQL, and that it is a good idea to embrace the industrywide investment in SQL. We have experiences whereby the database and even the SQL itself have outlived the application source code, and even multiple versions of the source code. In some cases we have seen that an application was rewritten in a different language, but the SQL and database remained largely unchanged.</p>
<p>It is for such reasons that iBATIS does not attempt to hide SQL or avoid SQL. It is a persistence layer framework that instead embraces SQL by making it easier to work with and easier to integrate into modern object-oriented software. These days, there are rumors that databases and SQL threaten our object models, but that does not have to be the case. iBATIS can help to ensure that it is not.</p>
<p>(<a href="http://www.amazon.com/gp/product/1932394826?ie=UTF8&amp;tag=loiagron-20&amp;linkCode=as2&amp;camp=1789&amp;creative=9325&amp;creativeASIN=1932394826" target="_blank">iBatis in Action</a> book)</p></blockquote>
<p style="text-align: justify;">So&#8230;</p>
<blockquote style="text-align: justify;"><p><strong><em> What is iBatis ?</em></strong></p>
<ul>
<li>A JDBC Framework</li>
<li>Developers write SQL, iBATIS executes it using JDBC.</li>
<li>No more try/catch/finally/try/catch.</li>
<li>An SQL Mapper</li>
<li>Automatically maps object properties to prepared statement parameters.</li>
<li>Automatically maps result sets to objects.</li>
<li>Support for getting rid of N+1 queries.</li>
<li>A Transaction Manager</li>
<li>iBATIS will provide transaction management for database operations if no other transaction manager is available.</li>
<li>iBATIS will use external transaction management (Spring, EJB CMT, etc.) if available.</li>
<li>Great integration with Spring, but can also be used without Spring (the Spring folks were early supporters of iBATIS).</li>
</ul>
<p><strong><em>What isn&#8217;t iBATIS ?</em></strong></p>
<ul>
<li>An ORM</li>
<li>Does not generate SQL</li>
<li>Does not have a proprietary query language</li>
<li>Does not know about object identity</li>
<li>Does not transparently persist objects</li>
<li>Does not build an object cache</li>
</ul>
<p>Essentially, iBatis is a very lightweight persistence solution that gives you most of the semantics of an O/R Mapping toolkit, without all the drama. In other words ,iBATIS strives to ease the development of data-driven applications by abstracting the low-level details involved in database communication (loading a database driver, obtaining and managing connections, managing transaction semantics, etc.), as well as providing higher-level ORM capabilities (automated and configurable mapping of objects to SQL calls, data type conversion management, support for static queries as well as dynamic queries based upon an object&#8217;s state, mapping of complex joins to complex object graphs, etc.). iBATIS simply maps JavaBeans to SQL statements using a very simple XML descriptor. Simplicity is the key advantage of iBATIS over other frameworks and object relational mapping tools.(<a href="http://www.developersbook.com" target="_blank">http://www.developersbook.com</a> )</p></blockquote>
<h3 style="text-align: justify;">Who is using iBatis/MyBatis?</h3>
<p style="text-align: justify;">See the list in this link: <a href="http://www.apachebookstore.com/confluence/oss/pages/viewpage.action?pageId=25" target="_blank">http://www.apachebookstore.com/confluence/oss/pages/viewpage.action?pageId=25</a></p>
<p style="text-align: justify;">I think the biggest case is <a href="http://www.myspace.com/" target="_blank">MySpace</a>, with millions of users. Very nice!</p>
<p style="text-align: justify;">This was just an introduction, so in next articles I will show how to create an application using iBatis/Mybatis – step-by-step.</p>
<p style="text-align: justify;">Enjoy! <img src='http://loianegroner.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<div class="shr-publisher-646"></div><!-- Start Shareaholic LikeButtonSetBottom Automatic --><!-- End Shareaholic LikeButtonSetBottom Automatic --><img src="http://loianegroner.com/?ak_action=api_record_view&id=646&type=feed" alt="" /><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/LoianeGroner?a=jcSlvL0UAAo:io2HM3diMiU:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/LoianeGroner?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/LoianeGroner?a=jcSlvL0UAAo:io2HM3diMiU:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/LoianeGroner?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/LoianeGroner?a=jcSlvL0UAAo:io2HM3diMiU:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/LoianeGroner?i=jcSlvL0UAAo:io2HM3diMiU:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/LoianeGroner?a=jcSlvL0UAAo:io2HM3diMiU:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/LoianeGroner?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/LoianeGroner?a=jcSlvL0UAAo:io2HM3diMiU:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/LoianeGroner?i=jcSlvL0UAAo:io2HM3diMiU:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/LoianeGroner?a=jcSlvL0UAAo:io2HM3diMiU:I9og5sOYxJI"><img src="http://feeds.feedburner.com/~ff/LoianeGroner?d=I9og5sOYxJI" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/LoianeGroner/~4/jcSlvL0UAAo" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://loianegroner.com/2011/02/introduction-to-ibatis-mybatis-an-alternative-to-hibernate-and-jdbc/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		<feedburner:origLink>http://loianegroner.com/2011/02/introduction-to-ibatis-mybatis-an-alternative-to-hibernate-and-jdbc/</feedburner:origLink></item>
		<item>
		<title>Book Review: OCJP/SCJP: OCP Java SE 6 Programmer Practice Exams by Kathy Sierra and Bert Bates</title>
		<link>http://feedproxy.google.com/~r/LoianeGroner/~3/9xg0hn_Nlzg/</link>
		<comments>http://loianegroner.com/2011/02/book-review-ocjpscjp-ocp-java-se-6-programmer-practice-exams-by-kathy-sierra-and-bert-bates/#comments</comments>
		<pubDate>Tue, 01 Feb 2011 10:00:02 +0000</pubDate>
		<dc:creator>Loiane</dc:creator>
				<category><![CDATA[Book Review]]></category>
		<category><![CDATA[Bert Bates]]></category>
		<category><![CDATA[Java Certification]]></category>
		<category><![CDATA[Kathy Sierra]]></category>
		<category><![CDATA[OCJP]]></category>
		<category><![CDATA[OCP Java SE 6 Programmer Practice Exams]]></category>
		<category><![CDATA[SCJP]]></category>

		<guid isPermaLink="false">http://loianegroner.com/?p=754</guid>
		<description><![CDATA[Last month I published a blog post about the new OCP Java SE 6 Programmer Practice Exams book written by Kathy Sierra and Bert Bates. I bought this book on amazon and it took a month to get to where I live (Brazil). Disclaimer: Neither the publisher or the authors sent me this book for [...]]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop Automatic --><!-- End Shareaholic LikeButtonSetTop Automatic --><p style="text-align: justify;"><a href="http://loianegroner.com/2011/01/book-ocjpscjp-ocp-java-se-6-programmer-practice-exams/" target="_blank">Last month I published a blog post</a> about the new <a href="http://www.amazon.com/gp/product/0072260882?ie=UTF8&amp;tag=loiagron-20&amp;linkCode=as2&amp;camp=1789&amp;creative=9325&amp;creativeASIN=0072260882" target="_blank">OCP Java SE 6 Programmer Practice Exams</a> book written by Kathy Sierra and Bert Bates. I bought this book on amazon and it took a month to get to where I live (Brazil).</p>
<blockquote style="text-align: justify;"><p>Disclaimer: Neither the publisher or the authors sent me this book for review. I bought it with my own money and this is my honest opinion.</p></blockquote>
<p style="text-align: justify;"><a href="http://www.amazon.com/gp/product/0072260882?ie=UTF8&amp;tag=loiagron-20&amp;linkCode=as2&amp;camp=1789&amp;creative=9325&amp;creativeASIN=0072260882" target="_blank"><img class="aligncenter size-full wp-image-757" title="ocj_practice_book_loiane" src="http://loianegroner.com/wp-content/uploads/2011/01/ocj_practice_book_loiane.jpg" alt="" width="356" height="442" /></a></p>
<h3 style="text-align: justify;">Motivation:</h3>
<p style="text-align: justify;">If you are studying to pass the OCJP exam, you must know the most famous OCJP/SCJP book: <a href="http://www.amazon.com/SCJP-Certified-Programmer-Java-310-065/dp/0071591060?&amp;camp=212361&amp;linkCode=wey&amp;tag=loiagron-20&amp;creative=380597" target="_blank">SCJP Sun Certified Programmer for Java 6 Exam 310-065</a> (also written by Kathy Sierra and Bert Bates). And you problably know that it is the best book to prepare your self to pass the OCJP exam.</p>
<p style="text-align: justify;">However, studying theory is not enough to pass the exam. If you want to be successful, you have to practice (a lot), and this book is all about practicing.</p>
<p style="text-align: justify;">And as it says on the book cover: &#8220;Don&#8217;t let the real test be your first test!&#8221;.</p>
<h3 style="text-align: justify;">How the book is organized:</h3>
<p style="text-align: justify;">I liked the way the book is organized.</p>
<p style="text-align: justify;">There are couple of chapters to test your knowledge called Self-Assessment and they also contain some study tips.</p>
<p style="text-align: justify;">There are 4 chapters called Practice Exam, and they are a sample of real exams with multiple choice questions, &#8220;drag and drop&#8221; questions (kind of a complete the sentence question).</p>
<p style="text-align: justify;">And there is also a chapter with study tips and exercises.</p>
<p style="text-align: justify;">After each exam (Self-Assessment or Practice Exam) there is a quick answer key and then the explanation of the answer.</p>
<p style="text-align: justify;">There is also the &#8220;Analysing your Results&#8221; section, where you can see if you are good to go or need more studying.</p>
<p style="text-align: justify;">The book is organized in a great way. Fisrt the Self-Assessment chapters, then a Practice Exam, then some tips and then more 3 Practice Exam chapters, so you can read the book from cover to cover, and you should read it in the order: start from chapter 1, then chapter 2, and on.</p>
<h3 style="text-align: justify;">My opinion about this book:</h3>
<p style="text-align: justify;">As I mentioned, the book is very well organized.</p>
<p style="text-align: justify;">It does what is says on the cover: it is all about practicing.</p>
<p style="text-align: justify;">The questions are great, very close to the real exam and all the question type and exam topics are covered.</p>
<p style="text-align: justify;">The size of the book is good. It is not heavy, the font is in the right size.</p>
<h3 style="text-align: justify;">Conclusion:</h3>
<p style="text-align: justify;">The only thing that I did not like about te book is the fact that it is a book &#8211; in <strong>paper version</strong> <strong>only</strong>. The OCJP exam is online, and if we have a interface that looks like the real exam (a software) it would be better. It would be nice if the book came with a CD, as the <a href="http://www.amazon.com/SCJP-Certified-Programmer-Java-310-065/dp/0071591060?&amp;camp=212361&amp;linkCode=wey&amp;tag=loiagron-20&amp;creative=380597" target="_blank">preparation book</a> does, with a PC version of the exams.</p>
<p style="text-align: justify;">The book is not expensive: I bought it for <a href="http://www.amazon.com/gp/product/0072260882?ie=UTF8&amp;tag=loiagron-20&amp;linkCode=as2&amp;camp=1789&amp;creative=9325&amp;creativeASIN=0072260882" target="_blank">US$ 19 on amazon</a>. The <a href="http://www.mhprofessional.com/book.php?isbn=0072260882" target="_blank">regular price is US$ 35</a>.</p>
<p style="text-align: justify;">So if you are getting ready for OCJP exam, I recommend you to buy the book, it is worth buying. The main reason I recommend you to buy the book is that it was written by the exam creators, so they know what are they talking about and the questions are just like the real exam.</p>
<p style="text-align: justify;">I liked it and I recommend it!</p>
<p style="text-align: justify;">You can check a <a href="http://www.mhprofessional.com/downloads/products/0072260882/0072260882_chap01.pdf" target="_blank">sample chapter of this book here</a>.</p>
<p style="text-align: justify;">And if you want to buy this book, <a href="http://www.amazon.com/gp/product/0072260882?ie=UTF8&amp;tag=loiagron-20&amp;linkCode=as2&amp;camp=1789&amp;creative=9325&amp;creativeASIN=0072260882" target="_blank">here is the link</a>.</p>
<div class="shr-publisher-754"></div><!-- Start Shareaholic LikeButtonSetBottom Automatic --><!-- End Shareaholic LikeButtonSetBottom Automatic --><img src="http://loianegroner.com/?ak_action=api_record_view&id=754&type=feed" alt="" /><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/LoianeGroner?a=9xg0hn_Nlzg:NmUsD66rJq8:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/LoianeGroner?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/LoianeGroner?a=9xg0hn_Nlzg:NmUsD66rJq8:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/LoianeGroner?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/LoianeGroner?a=9xg0hn_Nlzg:NmUsD66rJq8:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/LoianeGroner?i=9xg0hn_Nlzg:NmUsD66rJq8:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/LoianeGroner?a=9xg0hn_Nlzg:NmUsD66rJq8:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/LoianeGroner?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/LoianeGroner?a=9xg0hn_Nlzg:NmUsD66rJq8:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/LoianeGroner?i=9xg0hn_Nlzg:NmUsD66rJq8:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/LoianeGroner?a=9xg0hn_Nlzg:NmUsD66rJq8:I9og5sOYxJI"><img src="http://feeds.feedburner.com/~ff/LoianeGroner?d=I9og5sOYxJI" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/LoianeGroner/~4/9xg0hn_Nlzg" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://loianegroner.com/2011/02/book-review-ocjpscjp-ocp-java-se-6-programmer-practice-exams-by-kathy-sierra-and-bert-bates/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		<feedburner:origLink>http://loianegroner.com/2011/02/book-review-ocjpscjp-ocp-java-se-6-programmer-practice-exams-by-kathy-sierra-and-bert-bates/</feedburner:origLink></item>
		<item>
		<title>How to Learn Ext JS</title>
		<link>http://feedproxy.google.com/~r/LoianeGroner/~3/T3qnmiCtyVE/</link>
		<comments>http://loianegroner.com/2011/01/how-to-learn-ext-js/#comments</comments>
		<pubDate>Mon, 17 Jan 2011 10:00:43 +0000</pubDate>
		<dc:creator>Loiane</dc:creator>
				<category><![CDATA[ExtJS]]></category>
		<category><![CDATA[how to]]></category>
		<category><![CDATA[quick tips]]></category>
		<category><![CDATA[Sencha]]></category>
		<category><![CDATA[tips]]></category>

		<guid isPermaLink="false">http://loianegroner.com/?p=717</guid>
		<description><![CDATA[This tutorial will present some tips of how to learn Sencha Ext JS. For those how do not know, Ext JS is a cross-browser JavaScript library for building rich internet applications. Build rich, sustainable web applications faster than ever. I have been working with Ext JS for almost two years and I like it very [...]]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop Automatic --><!-- End Shareaholic LikeButtonSetTop Automatic --><p style="text-align: justify;">This tutorial will present some tips of how to learn Sencha Ext JS.</p>
<p style="text-align: justify;">For those how do not know,</p>
<blockquote>
<p style="text-align: justify;">Ext JS is a cross-browser JavaScript library for building rich internet applications. Build rich, sustainable web applications faster than ever.</p>
</blockquote>
<p style="text-align: justify;">I have been working with Ext JS for almost two years and I like it very much. That is why I decided to write this tutorial with some tips.</p>
<p style="text-align: center;"><a href="http://www.loiane.com/wp-content/uploads/2010/12/extjs_loiane.gif"><img class="aligncenter size-full wp-image-2101" title="extjs_loiane" src="http://www.loiane.com/wp-content/uploads/2010/12/extjs_loiane.gif" alt="" width="270" height="200" /></a></p>
<h3 style="text-align: justify;">Get to Know Sencha website:</h3>
<p style="text-align: justify;">Sencha is the Ext SJ owner The current Ext JS version is 3.3. The version 4 is going to be released on February (with lots of fun new features).</p>
<p style="text-align: justify;">Sencha website is pretty complete. There are some tutorials (some os them are deprecated &#8211; but you can still read them and learn something from them), there are the offical forum (the development team and some ext js experts will answer your question), documentation, demos and samples and more. I recommend you to spend some time exploring it and of course bookmark it for future reference.</p>
<p>I am going to link some links I think it is important for you to get to know:</p>
<p><strong><em>Mains ExtJS page</em></strong>: <a href="http://www.sencha.com/products/js/" target="_blank">http://www.sencha.com/products/js/</a> &#8211; this is the Ext JS main page, use it as reference.</p>
<p><strong><em>Samples and demos:</em></strong> <a href="http://www.sencha.com/products/js/" target="_blank">http://www.sencha.com/products/js/</a> &#8211; this is the page I explore every week, looking for new components to learn. This page is really great. If you do not know how to get started with a component, use this page.</p>
<p><strong><em>Documentation:</em></strong> <a href="http://dev.sencha.com/deploy/dev/docs/" target="_blank">http://dev.sencha.com/deploy/dev/docs/</a> &#8211; the documentation is great and the layout is very friendly, but it is only for online reference. If you need an offiline reference, please read <a href="http://www.loiane.com/2010/11/documentacao-extjs-como-consultar-offline-e-documentacao-pacote-ux/" target="_blank">this tutorial</a>.</p>
<p><strong><em>Tutorials:</em></strong> <a href="http://www.sencha.com/learn/Tutorials" target="_blank">http://www.sencha.com/learn/Tutorials</a> &#8211; this page is a little bit old, but you can get something from there.</p>
<p><strong><em>Blog </em></strong>: <a href="http://www.sencha.com/blog/" target="_blank">http://www.sencha.com/blog/</a> &#8211; subscribe the feed, because this blog is great!</p>
<h3>Foruns:</h3>
<p><span style="font-weight: normal; font-size: 13px;"><em>English &#8211; Official</em></span><span style="font-weight: normal; font-size: 13px;">: this is the official forum: <a href="http://www.sencha.com/forum/" target="_blank">http://www.sencha.com/forum/<br />
</a></span><span style="font-weight: normal; font-size: 13px;"><em>Spanish</em></span><span style="font-weight: normal; font-size: 13px;">: the Spanish community is very active: <a href="http://extjses.com/" target="_blank">http://extjses.com/<br />
</a></span><span style="font-weight: normal; font-size: 13px;"><em>Portuguese &#8211; Brazil</em></span><span style="font-weight: normal; font-size: 13px;">: the Brazilian community is growing a lot: <a href="http://www.extjs.com.br/forum/" target="_blank">http://www.extjs.com.br/forum/</a></span></p>
<h3>Books:</h3>
<p>There are a few book in the market about Ext JS, but they are fantastic! If you have the change to read all of them, please do it!</p>
<p>To get started I recommend: <a href="http://www.amazon.com/gp/product/1849511209?ie=UTF8&amp;tag=loiagron-20&amp;linkCode=as2&amp;camp=1789&amp;creative=9325&amp;creativeASIN=1849511209" target="_blank">Learning Ext JS 3.2</a> and/or<a href="http://www.amazon.com/gp/product/1935182110?ie=UTF8&amp;tag=loiagron-20&amp;linkCode=as2&amp;camp=1789&amp;creative=9325&amp;creativeASIN=1935182110" target="_blank"> Ext JS in Action</a></p>
<p>If you have some experience &#8211; intermediate knowlegde: <a href="http://www.amazon.com/gp/product/1847198708?ie=UTF8&amp;tag=loiagron-20&amp;linkCode=as2&amp;camp=1789&amp;creative=9325&amp;creativeASIN=1847198708" target="_blank">Ext JS 3.0 Cookbook</a></p>
<p>I have read all the three, the books are great and are worth buying them <img src='http://loianegroner.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<h3>Some other tips:</h3>
<p style="text-align: justify;">Ext JS is a library with lots of features, and it is hard to get to know all the components at once. I recommend you to get started with the one you are going to use the most in your job and then you can study the others to boost your knowledge.</p>
<p style="text-align: justify;">The Sencha website provides you a great resource, but it is not enough to become a Ext JS master. I recommend you to read the books, because they are going to teach you everything you need to know &#8211; from basic to advanced techniques.</p>
<p style="text-align: justify;">Practice is the keyword. Practice, practice and practice. You will not learn if you only read tutorials and books. You need some hands on.</p>
<p style="text-align: justify;">I did a presentation at my work. It is an overview about Ext JS, if you are interested in the Ext JS features, please take a look:</p>
<p style="text-align: center;"><object style="margin:0px" width="425" height="355"><param name="movie" value="http://static.slidesharecdn.com/swf/ssplayer2.swf?doc=id=5828869&amp;doc=extjsoverview-101118182434-phpapp01" /><param name="allowFullScreen" value="true"/><param name="allowScriptAccess" value="always"/><param name="wmode" value="transparent" /><embed src="http://static.slidesharecdn.com/swf/ssplayer2.swf?doc=id=5828869&amp;doc=extjsoverview-101118182434-phpapp01" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="355" wmode="transparent"></embed></object></p>
<p style="text-align: justify;">Enjoy! <img src='http://loianegroner.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<div class="shr-publisher-717"></div><!-- Start Shareaholic LikeButtonSetBottom Automatic --><!-- End Shareaholic LikeButtonSetBottom Automatic --><img src="http://loianegroner.com/?ak_action=api_record_view&id=717&type=feed" alt="" /><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/LoianeGroner?a=T3qnmiCtyVE:vW7BH0fgvvw:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/LoianeGroner?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/LoianeGroner?a=T3qnmiCtyVE:vW7BH0fgvvw:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/LoianeGroner?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/LoianeGroner?a=T3qnmiCtyVE:vW7BH0fgvvw:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/LoianeGroner?i=T3qnmiCtyVE:vW7BH0fgvvw:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/LoianeGroner?a=T3qnmiCtyVE:vW7BH0fgvvw:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/LoianeGroner?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/LoianeGroner?a=T3qnmiCtyVE:vW7BH0fgvvw:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/LoianeGroner?i=T3qnmiCtyVE:vW7BH0fgvvw:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/LoianeGroner?a=T3qnmiCtyVE:vW7BH0fgvvw:I9og5sOYxJI"><img src="http://feeds.feedburner.com/~ff/LoianeGroner?d=I9og5sOYxJI" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/LoianeGroner/~4/T3qnmiCtyVE" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://loianegroner.com/2011/01/how-to-learn-ext-js/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		<feedburner:origLink>http://loianegroner.com/2011/01/how-to-learn-ext-js/</feedburner:origLink></item>
		<item>
		<title>Book: OCJP/SCJP: OCP Java SE 6 Programmer Practice Exams</title>
		<link>http://feedproxy.google.com/~r/LoianeGroner/~3/YPcI5SKqxD8/</link>
		<comments>http://loianegroner.com/2011/01/book-ocjpscjp-ocp-java-se-6-programmer-practice-exams/#comments</comments>
		<pubDate>Thu, 06 Jan 2011 09:30:18 +0000</pubDate>
		<dc:creator>Loiane</dc:creator>
				<category><![CDATA[Book Review]]></category>
		<category><![CDATA[Bert Bates]]></category>
		<category><![CDATA[Book]]></category>
		<category><![CDATA[Java Certification]]></category>
		<category><![CDATA[Kathy Sierra]]></category>
		<category><![CDATA[OCJP]]></category>
		<category><![CDATA[OCP Java SE 6 Programmer Practice Exams]]></category>
		<category><![CDATA[SCJP]]></category>

		<guid isPermaLink="false">http://loianegroner.com/?p=693</guid>
		<description><![CDATA[Written by two of the lead developers of the Java SE Programmer Exam, OCP Java SE 6 Programmer Practice Exams is filled with more than 260 realistic practice questions to prepare you for this challenging exam. To help you understand this material, in-depth explanations of both the correct and incorrect answers are included for every question. [...]]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop Automatic --><!-- End Shareaholic LikeButtonSetTop Automatic --><blockquote>
<p style="text-align: justify;">Written by two of the lead developers of the Java SE Programmer Exam, <em>OCP Java SE 6 Programmer Practice Exams</em> is filled with more than 260 realistic practice questions to prepare you for this challenging exam. To help you understand this material, in-depth explanations of both the correct and incorrect answers are included for every question. This practical guide covers all official objectives for Exam 310-065 and is the perfect companion to <em>SCJP Sun Certified Programmer for Java 6 Study Guide</em>.</p>
<p style="text-align: justify;"><a href="http://www.amazon.com/gp/product/0072260882?ie=UTF8&amp;tag=loiagron-20&amp;linkCode=as2&amp;camp=1789&amp;creative=9325&amp;creativeASIN=0072260882"><img class="aligncenter" title="OCJP/SCJP" src="http://www.loiane.com/wp-content/uploads/2010/12/ocj_practice_book_loiane.jpg" alt="" width="401" height="498" /></a></p>
</blockquote>
<p><strong>Covers all OCP Java SE 6 Programmer exam topics, including:</strong></p>
<ul>
<li>Declarations and Access Control</li>
<li>Object Orientation</li>
<li>Assignments</li>
<li>Operators</li>
<li>Flow Control, Exceptions, and Assertions</li>
<li>Strings, I/O, Formatting, and Parsing</li>
<li>Generics and Collections</li>
<li>Inner Classes</li>
<li>Threads</li>
<li>Development</li>
</ul>
<p><strong>Table of contents</strong></p>
<p>Chapter 1: Self-Assessment Test 1<br />
Chapter 2: Self-Assessment Test 2<br />
Chapter 3: Practice Exam 1<br />
Chapter 4: Coding Exercises<br />
Chapter 5: Practice Exam 2<br />
Chapter 6: Practice Exam 3<br />
Chapter 7: Practice Exam 4<br />
Appendix: Objectives Index</p>
<p><strong>Author comments</strong></p>
<blockquote><p><strong>Bert Bates</strong>, SCJP, was a lead developer of the SCJP and SCJD exams for Sun. He is the coauthor, with Kathy Sierra, of <em>SCJP Sun Certified Programmer for Java 6 Study Guide</em>.</p></blockquote>
<blockquote><p><strong>Kathy Sierra</strong>, SCJP, was a lead developer of the SCJP exam and the SCJD exam. She was also a certified Sun Java instructor and is the founder of the world&#8217;s largest Java certification website, javaranch.com.</p></blockquote>
<p>Source: <a href="http://www.mhprofessional.com/book.php?isbn=0072260882" target="_blank">http://www.mhprofessional.com/book.php?isbn=0072260882</a></p>
<p>I saw this book at amazon.com in December 2010 and I decided to buy it. As I live in Brazil, it is going to take a while until I have it in my hands (~2 months &#8211; we do not have the 2 days shipment &#8211; there is another shipment option, but it is very expensive). So, when I get the book, I am going to write a book review about it and post it here.</p>
<p>I still do not know if it is worth of buying. The resources most used for people to practice for the java certification are <a href="http://www.whizlabs.com/" target="_blank">Whizlabs</a> and <a href="http://www.testkiller.net/" target="_blank">TestKiller</a>. We did not have any official book about it. So I am going to find out if is good in a month! <img src='http://loianegroner.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>I bought it for 19 dolars on amazon.com; On McGraw-hill webiste is 35 dolars:</p>
<p style="text-align: justify;">
<div class="shr-publisher-693"></div><!-- Start Shareaholic LikeButtonSetBottom Automatic --><!-- End Shareaholic LikeButtonSetBottom Automatic --><img src="http://loianegroner.com/?ak_action=api_record_view&id=693&type=feed" alt="" /><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/LoianeGroner?a=YPcI5SKqxD8:ywgLKF7eeZg:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/LoianeGroner?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/LoianeGroner?a=YPcI5SKqxD8:ywgLKF7eeZg:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/LoianeGroner?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/LoianeGroner?a=YPcI5SKqxD8:ywgLKF7eeZg:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/LoianeGroner?i=YPcI5SKqxD8:ywgLKF7eeZg:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/LoianeGroner?a=YPcI5SKqxD8:ywgLKF7eeZg:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/LoianeGroner?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/LoianeGroner?a=YPcI5SKqxD8:ywgLKF7eeZg:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/LoianeGroner?i=YPcI5SKqxD8:ywgLKF7eeZg:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/LoianeGroner?a=YPcI5SKqxD8:ywgLKF7eeZg:I9og5sOYxJI"><img src="http://feeds.feedburner.com/~ff/LoianeGroner?d=I9og5sOYxJI" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/LoianeGroner/~4/YPcI5SKqxD8" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://loianegroner.com/2011/01/book-ocjpscjp-ocp-java-se-6-programmer-practice-exams/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		<feedburner:origLink>http://loianegroner.com/2011/01/book-ocjpscjp-ocp-java-se-6-programmer-practice-exams/</feedburner:origLink></item>
		<item>
		<title>Top 10 Articles of 2010: Spring, Spring Security, Ext JS, Hibernate</title>
		<link>http://feedproxy.google.com/~r/LoianeGroner/~3/zffA3QjzRdI/</link>
		<comments>http://loianegroner.com/2010/12/top-10-articles-of-2010-spring-spring-security-ext-js-hibernate/#comments</comments>
		<pubDate>Tue, 28 Dec 2010 12:37:40 +0000</pubDate>
		<dc:creator>Loiane</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[ExtJS]]></category>
		<category><![CDATA[Ext JS]]></category>
		<category><![CDATA[Ext.Window]]></category>
		<category><![CDATA[ExtJS + J2EE]]></category>
		<category><![CDATA[ExtJS Grid]]></category>
		<category><![CDATA[Hibernate]]></category>
		<category><![CDATA[Spring]]></category>
		<category><![CDATA[Spring Security]]></category>

		<guid isPermaLink="false">http://loianegroner.com/?p=667</guid>
		<description><![CDATA[Hi guys, This blog completed one year and 2010 is coming to an end. So I decided to list the TOP 10 articles/tutorials of 2010. Here is the list of the most viewed articles: Tutorial: Getting Started with Spring Security ExtJS and Spring MVC Framework: CRUD DataGrid Example Ajax File Upload with ExtJS and Spring [...]]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop Automatic --><!-- End Shareaholic LikeButtonSetTop Automatic --><p>Hi guys,</p>
<p>This blog completed one year and 2010 is coming to an end. So I decided to list the TOP 10 articles/tutorials of 2010.</p>
<div style="text-align: justify;"><a href="http://loianegroner.com/wp-content/uploads/2010/12/top-10-of-2010.jpg"><img class="aligncenter size-full wp-image-674" title="top-10-of-2010" src="http://loianegroner.com/wp-content/uploads/2010/12/top-10-of-2010.jpg" alt="" width="222" height="222" /></a></div>
<div style="text-align: justify;"><strong>Here is the list of the most viewed articles:</strong></div>
<ol>
<li><a href="http://loianegroner.com/2010/01/tutorial-getting-started-with-spring-security/">Tutorial: Getting Started with Spring Security</a></li>
<li><a href="http://loianegroner.com/2010/03/extjs-and-spring-mvc-framework-crud-datagrid-example/">ExtJS and Spring MVC Framework: CRUD DataGrid Example</a></li>
<li><a href="http://loianegroner.com/2010/03/ajax-file-upload-with-extjs-and-spring-framework/">Ajax File Upload with ExtJS and Spring Framework</a></li>
<li><a href="http://loianegroner.com/2010/02/integrating-spring-security-with-extjs-login-page/">Integrating Spring Security with ExtJS Login Page</a></li>
<li><a href="http://loianegroner.com/2010/02/spring-mvc-and-ajax-with-json/">Spring MVC and AJAX with JSON</a></li>
<li><a href="http://loianegroner.com/2010/02/extjs-how-to-export-datagrid-to-excel/">ExtJS: How to Export DataGrid to Excel</a></li>
<li><a href="http://loianegroner.com/2010/09/extjs-spring-mvc-3-and-hibernate-3-5-crud-datagrid-example/">ExtJS, Spring MVC 3 and Hibernate 3.5: CRUD DataGrid Example</a></li>
<li><a href="http://loianegroner.com/2010/01/spring-security-login-and-logout-form-jsp/">Spring Security: Login and Logout Form JSP</a></li>
<li><a href="http://loianegroner.com/2010/01/how-to-display-an-imagelink-inside-an-ext-js-gridpanels-cell/">How to Display an Image/Link Inside an Ext JS GridPanel&#8217;s Cell</a></li>
<li><a href="http://loianegroner.com/2010/01/ext-window-panel-show-or-hide/">Ext.Window Panel: Show or Hide?</a></li>
</ol>
<p><strong>Here is the list of top 10 of the most commented articles:</strong></p>
<ol>
<li><a title="ExtJS and Spring MVC Framework: CRUD DataGrid Example" href="http://loianegroner.com/2010/03/extjs-and-spring-mvc-framework-crud-datagrid-example/#comments">ExtJS and Spring MVC Framework: CRUD DataGrid Example </a>discussed 52 times</li>
<li><a title="Ajax File Upload with ExtJS and Spring Framework" href="http://loianegroner.com/2010/03/ajax-file-upload-with-extjs-and-spring-framework/#comments">Ajax File Upload with ExtJS and Spring Framework</a> discussed 22 times</li>
<li><a title="Integrating Spring Security with ExtJS Login Page" href="http://loianegroner.com/2010/02/integrating-spring-security-with-extjs-login-page/#comments">Integrating Spring Security with ExtJS Login Page</a> discussed 21 times</li>
<li><a title="ExtJS, Spring MVC 3 and Hibernate 3.5: CRUD DataGrid Example" href="http://loianegroner.com/2010/09/extjs-spring-mvc-3-and-hibernate-3-5-crud-datagrid-example/#comments">ExtJS, Spring MVC 3 and Hibernate 3.5: CRUD DataGrid Example </a>discussed 17 times</li>
<li><a title="Ext Designer Review" href="http://loianegroner.com/2010/04/ext-designer-review/#comments">Ext Designer Review </a>discussed 16 times</li>
<li><a title="ExtJS: How to Export DataGrid to Excel" href="http://loianegroner.com/2010/02/extjs-how-to-export-datagrid-to-excel/#comments">ExtJS: How to Export DataGrid to Excel </a>discussed 11 times</li>
<li><a title="Getting Started with JSON" href="http://loianegroner.com/2009/12/getting-started-with-json/#comments">Getting Started with JSON </a>discussed 10 times</li>
<li><a title="Tutorial: Getting Started with Spring Security" href="http://loianegroner.com/2010/01/tutorial-getting-started-with-spring-security/#comments">Tutorial: Getting Started with Spring Security </a>discussed 9 times</li>
<li><a title="Spring MVC and AJAX with JSON" href="http://loianegroner.com/2010/02/spring-mvc-and-ajax-with-json/#comments">Spring MVC and AJAX with JSON </a>discussed 9 times</li>
<li><a title="How to Display an Image/Link Inside an Ext JS GridPanel’s Cell" href="http://loianegroner.com/2010/01/how-to-display-an-imagelink-inside-an-ext-js-gridpanels-cell/#comments">How to Display an Image/Link Inside an Ext JS GridPanel’s Cell</a> discussed 6 times</li>
</ol>
<p>Thank you so much for reading this blog, I hope you enjoyed the tutorials, there is more coming in 2011!</p>
<p>Happy Coding!</p>
<p>And a Happy and Healthy New Year! <img src='http://loianegroner.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<div class="shr-publisher-667"></div><!-- Start Shareaholic LikeButtonSetBottom Automatic --><!-- End Shareaholic LikeButtonSetBottom Automatic --><img src="http://loianegroner.com/?ak_action=api_record_view&id=667&type=feed" alt="" /><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/LoianeGroner?a=zffA3QjzRdI:vZ4-e471F-c:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/LoianeGroner?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/LoianeGroner?a=zffA3QjzRdI:vZ4-e471F-c:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/LoianeGroner?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/LoianeGroner?a=zffA3QjzRdI:vZ4-e471F-c:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/LoianeGroner?i=zffA3QjzRdI:vZ4-e471F-c:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/LoianeGroner?a=zffA3QjzRdI:vZ4-e471F-c:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/LoianeGroner?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/LoianeGroner?a=zffA3QjzRdI:vZ4-e471F-c:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/LoianeGroner?i=zffA3QjzRdI:vZ4-e471F-c:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/LoianeGroner?a=zffA3QjzRdI:vZ4-e471F-c:I9og5sOYxJI"><img src="http://feeds.feedburner.com/~ff/LoianeGroner?d=I9og5sOYxJI" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/LoianeGroner/~4/zffA3QjzRdI" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://loianegroner.com/2010/12/top-10-articles-of-2010-spring-spring-security-ext-js-hibernate/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		<feedburner:origLink>http://loianegroner.com/2010/12/top-10-articles-of-2010-spring-spring-security-ext-js-hibernate/</feedburner:origLink></item>
		<item>
		<title>JavaOne Brazil: Dinner with Oracle and Java Leaders</title>
		<link>http://feedproxy.google.com/~r/LoianeGroner/~3/i624-XnAxxQ/</link>
		<comments>http://loianegroner.com/2010/12/javaone-brazil-dinner-with-oracle-and-java-leaders/#comments</comments>
		<pubDate>Tue, 07 Dec 2010 16:51:16 +0000</pubDate>
		<dc:creator>Loiane</dc:creator>
				<category><![CDATA[Oracle]]></category>
		<category><![CDATA[JavaOne]]></category>
		<category><![CDATA[JavaOne Brazil]]></category>
		<category><![CDATA[JUG Leaders]]></category>
		<category><![CDATA[Oracle Open World]]></category>

		<guid isPermaLink="false">http://loianegroner.com/?p=654</guid>
		<description><![CDATA[Yesterday I had the opportunity to have dinner with some Oracle fellows (Java, Netbeans, Glassfish evangelists) and some Java Leaders in a pizza bar in Sao Paulo &#8211; Brazil. JavaOne Brazil is starting today. It was really nice and we had to much pizza. We talked about Java, Oracle and we also talked about movies, [...]]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop Automatic --><!-- End Shareaholic LikeButtonSetTop Automatic --><p style="text-align: justify;">Yesterday I had the opportunity to have dinner with some Oracle fellows (Java, Netbeans, Glassfish evangelists) and some Java Leaders in a <a href="http://www.leonapizzabar.com.br/" target="_blank">pizza bar in Sao Paulo</a> &#8211; Brazil. JavaOne Brazil is starting today.</p>
<p style="text-align: center;"><a href="http://loianegroner.com/wp-content/uploads/2010/12/Oracle_Dinner_Java_leaders_loiane.jpg" target="_blank"><img class="aligncenter size-full wp-image-655" title="Oracle_Dinner_Java_leaders_loiane" src="http://loianegroner.com/wp-content/uploads/2010/12/Oracle_Dinner_Java_leaders_loiane.jpg" alt="" width="480" height="360" /></a></p>
<p style="text-align: justify;">It was really nice and we had to much pizza. We talked about Java, Oracle and we also talked about movies, relationships, barbecuing, embarrassing moments in our lives. It was nice to know the other side of Java experts.</p>
<p style="text-align: justify;">I also had the pleasure to meet Nichole, from JUG Leaders mailing list. She is really nice (and pretty! <img src='http://loianegroner.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> ).</p>
<p style="text-align: justify;">Some pictures we took at the dinner: <a href="http://www.flickr.com/photos/loiane/sets/72157625423438891/" target="_blank">http://www.flickr.com/photos/loiane/sets/72157625423438891/</a></p>
<p style="text-align: left;">Oracle also published a blog entry on its blog:<br />
<a href="http://blogs.oracle.com/java/2010/12/javaone_latin_america_underway.html" target="_blank">http://blogs.oracle.com/java/2010/12/javaone_latin_america_underway.html</a></p>
<p style="text-align: justify;">I will write a JavaOne Brazil + Oracle Open World review on next posts.</p>
<p style="text-align: justify;">See ya!</p>
<div class="shr-publisher-654"></div><!-- Start Shareaholic LikeButtonSetBottom Automatic --><!-- End Shareaholic LikeButtonSetBottom Automatic --><img src="http://loianegroner.com/?ak_action=api_record_view&id=654&type=feed" alt="" /><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/LoianeGroner?a=i624-XnAxxQ:VLJxNvCDBYo:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/LoianeGroner?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/LoianeGroner?a=i624-XnAxxQ:VLJxNvCDBYo:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/LoianeGroner?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/LoianeGroner?a=i624-XnAxxQ:VLJxNvCDBYo:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/LoianeGroner?i=i624-XnAxxQ:VLJxNvCDBYo:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/LoianeGroner?a=i624-XnAxxQ:VLJxNvCDBYo:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/LoianeGroner?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/LoianeGroner?a=i624-XnAxxQ:VLJxNvCDBYo:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/LoianeGroner?i=i624-XnAxxQ:VLJxNvCDBYo:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/LoianeGroner?a=i624-XnAxxQ:VLJxNvCDBYo:I9og5sOYxJI"><img src="http://feeds.feedburner.com/~ff/LoianeGroner?d=I9og5sOYxJI" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/LoianeGroner/~4/i624-XnAxxQ" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://loianegroner.com/2010/12/javaone-brazil-dinner-with-oracle-and-java-leaders/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://loianegroner.com/2010/12/javaone-brazil-dinner-with-oracle-and-java-leaders/</feedburner:origLink></item>
	</channel>
</rss><!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Served from: loianegroner.com @ 2012-02-03 07:28:12 -->

