<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>A blog by Osama Dwairi</title>
	<atom:link href="http://blog.osamadwairi.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.osamadwairi.com</link>
	<description>Thoughts &#38; Experience!</description>
	<lastBuildDate>Mon, 20 Feb 2012 07:33:23 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
		<item>
		<title>unleash the joke :)</title>
		<link>http://blog.osamadwairi.com/2012/02/20/unleash-the-joke/</link>
		<comments>http://blog.osamadwairi.com/2012/02/20/unleash-the-joke/#comments</comments>
		<pubDate>Mon, 20 Feb 2012 06:51:23 +0000</pubDate>
		<dc:creator>Osama</dc:creator>
				<category><![CDATA[jokes]]></category>
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blog.osamadwairi.com/?p=358</guid>
		<description><![CDATA[scan the code to unleash the joke using your mobile! http://bit.ly/w28Vsb ]]></description>
			<content:encoded><![CDATA[<p style="text-align: center;"><a href="http://bit.ly/w28Vsb"><img class="size-medium wp-image-360 aligncenter" title="unleash the joke" src="http://blog.osamadwairi.com/wp-content/uploads/2012/02/1-300x300.png" alt="unleash the joke" width="300" height="300" /></a></p>
<p>scan the code to unleash the joke <img src='http://blog.osamadwairi.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  using your mobile! <a href="http://bit.ly/w28Vsb">http://bit.ly/w28Vsb </a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.osamadwairi.com/2012/02/20/unleash-the-joke/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Java ORM: Hibernate example</title>
		<link>http://blog.osamadwairi.com/2011/05/31/java-orm-hibernate/</link>
		<comments>http://blog.osamadwairi.com/2011/05/31/java-orm-hibernate/#comments</comments>
		<pubDate>Tue, 31 May 2011 12:05:27 +0000</pubDate>
		<dc:creator>Osama</dc:creator>
				<category><![CDATA[code snippet]]></category>
		<category><![CDATA[concepts]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[example]]></category>
		<category><![CDATA[hibernate]]></category>
		<category><![CDATA[ORM]]></category>
		<category><![CDATA[sessionFactory]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://blog.osamadwairi.com/?p=255</guid>
		<description><![CDATA[Hibernate is Hibernate is an object-relational mapping (ORM) library for the Java language, providing a framework for mapping an object-oriented domain model to a traditional relational database. Hibernate solves object-relational impedance mismatch problems by [..]]]></description>
			<content:encoded><![CDATA[<p>Hibernate is</p>
<blockquote><p><strong>Hibernate</strong> is an <a href="http://en.wikipedia.org/wiki/Object-relational_mapping">object-relational mapping</a> (ORM) library for the <a title="Java (programming language)" href="http://en.wikipedia.org/wiki/Java_(programming_language)">Java</a> language, providing a <a title="Software framework" href="http://en.wikipedia.org/wiki/Software_framework">framework</a> for mapping an <a title="Object-oriented programming" href="http://en.wikipedia.org/wiki/Object-oriented_programming">object-oriented</a> <a href="http://en.wikipedia.org/wiki/Domain_model">domain model</a> to a traditional <a href="http://en.wikipedia.org/wiki/Relational_database">relational database</a>. Hibernate solves <a href="http://en.wikipedia.org/wiki/Object-relational_impedance_mismatch">object-relational impedance mismatch</a> problems by replacing direct <a title="Persistence (computer science)" href="http://en.wikipedia.org/wiki/Persistence_(computer_science)">persistence</a>-related database accesses with high-level object handling functions.</p></blockquote>
<blockquote><p><strong>Hibernate&#8217;s primary feature</strong> is mapping from Java classes to database tables (and from Java data types to <a href="http://en.wikipedia.org/wiki/SQL">SQL</a> data types). Hibernate also provides data query and retrieval facilities. Hibernate generates the SQL calls and attempts to relieve the developer from manual result set handling and object conversion and keep the application portable to all supported SQL databases with little performance overhead.</p></blockquote>
<p>well, as we know what is hibernate and what is the primary feature is, let&#8217;s go deeper from developers&#8217; perspective, inspecting three areas:</p>
<ol>
<li>Configuring hibernate for your application: please note that I will configure hibernate as a stand alone database layer, don&#8217;t assume I am getting it ready for production use into web application.</li>
<li>Querying a database: single simple queries to complex joins.</li>
<li>Updating a database using save and update.</li>
</ol>
<p>In this article we will do hibernate configuration with simple DB interaction, persisting data. I will cover different ways of query DB and updating/saving data to DB in later articles.</p>
<p>&nbsp;</p>
<p><strong>Getting ready, Organized!</strong></p>
<p>Simply open your preferred Java IDE and start a new Java project and create a <strong><em>lib </em></strong>directory that will contain required jars for our application and <strong><em>config</em></strong> directory that will contain any config files we might need.</p>
<p>your application hierarchy should look something like this</p>
<p style="text-align: center;"><a href="http://blog.osamadwairi.com/wp-content/uploads/2011/04/img1.png"><img class="aligncenter size-medium wp-image-300" title="eclipse" src="http://blog.osamadwairi.com/wp-content/uploads/2011/04/img1-300x168.png" alt="eclipse IDE, Simple Hibernate application" width="500" height="289" /></a></p>
<p>&nbsp;</p>
<p>now, let&#8217;s start the real work</p>
<ul>
<li>create <em><strong>users </strong></em>table on database, that we will use as an example to interact with DB.</li>
</ul>

<div class="wp_codebox_msgheader wp_codebox_hide"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p255code7'); return false;">View Code</a> SQL</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p2557"><td class="code" id="p255code7"><pre class="sql" style="font-family:monospace;"><span style="color: #993333; font-weight: bold;">CREATE</span> <span style="color: #993333; font-weight: bold;">TABLE</span>  <span style="color: #ff0000;">`example_db`</span><span style="color: #66cc66;">.</span><span style="color: #ff0000;">`users`</span> <span style="color: #66cc66;">&#40;</span>
<span style="color: #ff0000;">`id`</span> INT <span style="color: #993333; font-weight: bold;">NOT</span> <span style="color: #993333; font-weight: bold;">NULL</span> <span style="color: #993333; font-weight: bold;">AUTO_INCREMENT</span> <span style="color: #66cc66;">,</span>
<span style="color: #ff0000;">`username`</span> VARCHAR<span style="color: #66cc66;">&#40;</span> <span style="color: #cc66cc;">255</span> <span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">NOT</span> <span style="color: #993333; font-weight: bold;">NULL</span> <span style="color: #66cc66;">,</span>
<span style="color: #ff0000;">`password`</span> VARCHAR<span style="color: #66cc66;">&#40;</span> <span style="color: #cc66cc;">255</span> <span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">NOT</span> <span style="color: #993333; font-weight: bold;">NULL</span> <span style="color: #66cc66;">,</span>
<span style="color: #993333; font-weight: bold;">PRIMARY</span> <span style="color: #993333; font-weight: bold;">KEY</span> <span style="color: #66cc66;">&#40;</span>  <span style="color: #ff0000;">`id`</span> <span style="color: #66cc66;">&#41;</span>
<span style="color: #66cc66;">&#41;</span>;</pre></td></tr></table></div>

<ul>
<li>you need to tell hibernate what class maps to which table, you can achieve this using POJO class, as follows:</li>
</ul>

<div class="wp_codebox_msgheader wp_codebox_hide"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p255code8'); return false;">View Code</a> JAVA</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p2558"><td class="code" id="p255code8"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">package</span> <span style="color: #006699;">com.dwairi.example.hibernate.model</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.persistence.Column</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.persistence.Entity</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.persistence.GeneratedValue</span><span style="color: #339933;">;</span>import <span style="color: #006699;">javax.persistence.Id</span><span style="color: #339933;">;</span>import <span style="color: #006699;">javax.persistence.Table</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.hibernate.Session</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">com.dwairi.example.hibernate.HibernateUtil</span><span style="color: #339933;">;</span>
&nbsp;
@<a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Aentity+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">Entity</span></a>
@Table<span style="color: #009900;">&#40;</span>name<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;users&quot;</span><span style="color: #009900;">&#41;</span>
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> User <span style="color: #009900;">&#123;</span>
 <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> save<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
  Session session <span style="color: #339933;">=</span> HibernateUtil.<span style="color: #006633;">getSessionfactory</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">getCurrentSession</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  session.<span style="color: #006633;">getTransaction</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">begin</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  session.<span style="color: #006633;">save</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
 <span style="color: #009900;">&#125;</span>
&nbsp;
 @Id
 @GeneratedValue
 <span style="color: #000000; font-weight: bold;">private</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Ainteger+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">Integer</span></a> id<span style="color: #339933;">;</span>
 @Column<span style="color: #009900;">&#40;</span>name<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;username&quot;</span><span style="color: #009900;">&#41;</span>
 <span style="color: #000000; font-weight: bold;">private</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Astring+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">String</span></a> userName<span style="color: #339933;">;</span>
&nbsp;
 @Column<span style="color: #009900;">&#40;</span>name<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;password&quot;</span><span style="color: #009900;">&#41;</span>
 <span style="color: #000000; font-weight: bold;">private</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Astring+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">String</span></a> password<span style="color: #339933;">;</span>
&nbsp;
 <span style="color: #000000; font-weight: bold;">public</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Ainteger+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">Integer</span></a> getId<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #000000; font-weight: bold;">return</span> id<span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span>
 <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> setId<span style="color: #009900;">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Ainteger+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">Integer</span></a> id<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">id</span> <span style="color: #339933;">=</span> id<span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span>
 <span style="color: #000000; font-weight: bold;">public</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Astring+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">String</span></a> getUserName<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #000000; font-weight: bold;">return</span> userName<span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span>
 <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> setUserName<span style="color: #009900;">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Astring+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">String</span></a> userName<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">userName</span> <span style="color: #339933;">=</span> userName<span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span>
 <span style="color: #000000; font-weight: bold;">public</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Astring+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">String</span></a> getPassword<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #000000; font-weight: bold;">return</span> password<span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span>
 <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> setPassword<span style="color: #009900;">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Astring+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">String</span></a> password<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">password</span> <span style="color: #339933;">=</span> password<span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<ul>
<li>hibernate provide a layer to interact with DBs, that is sessionFactory, that we will be using in this example; it provides a transactional environment and gives you the power of ORM in a simplified way.<br />
Following is a helper class that will handle creating one sessionFactory object in the course of application life:</li>
</ul>

<div class="wp_codebox_msgheader wp_codebox_hide"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p255code9'); return false;">View Code</a> JAVA</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p2559"><td class="code" id="p255code9"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">package</span> <span style="color: #006699;">com.dwairi.example.hibernate</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.io.File</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.hibernate.SessionFactory</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.hibernate.cfg.AnnotationConfiguration</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">com.dwairi.example.hibernate.model.User</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> HibernateUtil <span style="color: #009900;">&#123;</span>
 <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000000; font-weight: bold;">final</span> SessionFactory sessionFactory<span style="color: #339933;">;</span>
 <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">try</span> <span style="color: #009900;">&#123;</span>
   AnnotationConfiguration annotationConfiguration <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> AnnotationConfiguration<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
   annotationConfiguration.<span style="color: #006633;">configure</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Afile+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">File</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;config/hibernate.cfg.xml&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
   annotationConfiguration.<span style="color: #006633;">addAnnotatedClass</span><span style="color: #009900;">&#40;</span>User.<span style="color: #000000; font-weight: bold;">class</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
   sessionFactory <span style="color: #339933;">=</span> annotationConfiguration.<span style="color: #006633;">buildSessionFactory</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #009900;">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Athrowable+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">Throwable</span></a> ex<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
   <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Asystem+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">System</span></a>.<span style="color: #006633;">err</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Initial SessionFactory creation failed.&quot;</span> <span style="color: #339933;">+</span> ex<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
   <span style="color: #000000; font-weight: bold;">throw</span> <span style="color: #000000; font-weight: bold;">new</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Aexceptionininitializererror+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">ExceptionInInitializerError</span></a><span style="color: #009900;">&#40;</span>ex<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
 <span style="color: #009900;">&#125;</span>
 <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> SessionFactory getSessionfactory<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">return</span> sessionFactory<span style="color: #339933;">;</span>
 <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<ul>
<li>as you might noticed, it seems we have used a file <em><strong>hibernate.cfg.xml </strong></em>, what is this? actually, it&#8217;s the configuration file for hibernate that will help you configure how to interact with DB using hibernate. here how it will look like</li>
</ul>

<div class="wp_codebox_msgheader wp_codebox_hide"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p255code10'); return false;">View Code</a> XML</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p25510"><td class="code" id="p255code10"><pre class="xml" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">&lt;!--?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?--&gt;</span>
&nbsp;
	  com.mysql.jdbc.Driver
&nbsp;
	  jdbc:mysql://localhost/example_db
	  root
	  org.hibernate.dialect.MySQLDialect
	  1
	  true
	  true
	  org.hibernate.transaction.JDBCTransactionFactory
	  thread
	  org.hibernate.cache.NoCacheProvider</pre></td></tr></table></div>

<ul>
<li>create application runner, I will call it <strong><em>Test</em></strong>.</li>
</ul>

<div class="wp_codebox_msgheader wp_codebox_hide"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p255code11'); return false;">View Code</a> JAVA</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p25511"><td class="code" id="p255code11"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">package</span> <span style="color: #006699;">com.dwairi.example.hibernate</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">com.dwairi.example.hibernate.model.User</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> Test <span style="color: #009900;">&#123;</span>
 <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000066; font-weight: bold;">void</span> main<span style="color: #009900;">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Astring+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">String</span></a><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> args<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
 User user <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> User<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
 user.<span style="color: #006633;">setUserName</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;dwairi&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
 user.<span style="color: #006633;">setPassword</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;password&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
 user.<span style="color: #006633;">save</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
 <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Asystem+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">System</span></a>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;user object saved to DB: &quot;</span> <span style="color: #339933;">+</span> user.<span style="color: #006633;">getId</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<ul>
<li>we will add a <strong><em>log4j.properties</em></strong> file to the root of <em>classpath</em> and turn on debug mode, in order to see what going on, it will look something like this</li>
</ul>

<div class="wp_codebox_msgheader wp_codebox_hide"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p255code12'); return false;">View Code</a> PROPERTIES</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p25512"><td class="code" id="p255code12"><pre class="properties" style="font-family:monospace;"><span style="color: #000080; font-weight:bold;">log4j.rootLogger</span><span style="color: #000000;">=</span><span style="color: #008000; font-weight:bold;">DEBUG, A1</span>
<span style="color: #808080; font-style: italic;"># A1 is set to be a ConsoleAppender</span>
<span style="color: #000080; font-weight:bold;">log4j.appender.A1</span><span style="color: #000000;">=</span><span style="color: #008000; font-weight:bold;">org.apache.log4j.ConsoleAppender</span>
<span style="color: #000080; font-weight:bold;">log4j.appender.A1.layout</span><span style="color: #000000;">=</span><span style="color: #008000; font-weight:bold;">org.apache.log4j.PatternLayout</span>
<span style="color: #000080; font-weight:bold;">log4j.appender.A1.layout.ConversionPattern</span><span style="color: #000000;">=</span><span style="color: #008000; font-weight:bold;">%-4r <span style="">&#91;</span>%t<span style="">&#93;</span> %-5p %c %x - %m%n</span></pre></td></tr></table></div>

<p>&nbsp;</p>
<p>Time to see what have we got, run the application, read the debug data logged by hibernate and watch it successfully persists data to DB.</p>
<p>&nbsp;</p>
<p><em><strong>Happy DB-hibernate-ing!</strong></em></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.osamadwairi.com/2011/05/31/java-orm-hibernate/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>protecting your apache virtual host howto</title>
		<link>http://blog.osamadwairi.com/2011/04/21/protecting-your-apache-virtual-host-howto/</link>
		<comments>http://blog.osamadwairi.com/2011/04/21/protecting-your-apache-virtual-host-howto/#comments</comments>
		<pubDate>Thu, 21 Apr 2011 06:45:57 +0000</pubDate>
		<dc:creator>Osama</dc:creator>
				<category><![CDATA[howto]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Ruby and Ruby On Rails]]></category>
		<category><![CDATA[System Administration]]></category>
		<category><![CDATA[troubleshooting]]></category>
		<category><![CDATA[.htaccess]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[httpd]]></category>

		<guid isPermaLink="false">http://blog.osamadwairi.com/?p=269</guid>
		<description><![CDATA[how to use .htaccess to protect your website deployed on apache web server httpd <a href="http://blog.osamadwairi.com/2011/04/21/protecting-your-apache-virtual-host-howto/"><span class="read-more">Read more <span class="meta-nav">&#187;</span></span></a>]]></description>
			<content:encoded><![CDATA[<p>if you need to have apache web server protect a specific virtual host (website) you need four simple steps.</p>
<ol>
<li><strong>Create .htpassword file in a root protected path and add the first user</strong>

<div class="wp_codebox_msgheader wp_codebox_hide"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p269code13'); return false;">View Code</a> LINUX</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p26913"><td class="code" id="p269code13"><pre class="linux" style="font-family:monospace;">su -
mkdir /var/www/htpassword/
htpass -cm /var/www/htpassword/.htpassword admin</pre></td></tr></table></div>

</li>
<li><strong>add more users to .htpassword file</strong>

<div class="wp_codebox_msgheader wp_codebox_hide"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p269code14'); return false;">View Code</a> LINUX</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p26914"><td class="code" id="p269code14"><pre class="linux" style="font-family:monospace;">htpass -m /var/www/htpassword/.htpassword username</pre></td></tr></table></div>

</li>
<li><strong>add .htaccess to your host public directory (or document root), it will look similar to this</strong>

<div class="wp_codebox_msgheader wp_codebox_hide"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p269code15'); return false;">View Code</a> LINUX</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p26915"><td class="code" id="p269code15"><pre class="linux" style="font-family:monospace;">AuthName &quot;Restricted Area&quot;
AuthType Basic
AuthUserFile /var/www/htpass/.htpasswd
AuthGroupFile /dev/null
require valid-user</pre></td></tr></table></div>

<p>this is simple and obvious, but in case of ruby on rails you need to add it to your public directory not rails project root directory.</li>
</ol>
<p>now, you need to restart your apache websrever to update to latest configuration, then point your browser to your website and check it&#8217;s working, it should prompt you for username and password.</p>
<p>have a nice sys admin!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.osamadwairi.com/2011/04/21/protecting-your-apache-virtual-host-howto/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>starting a software project &#8211; ror as example</title>
		<link>http://blog.osamadwairi.com/2011/04/14/starting-a-software-project-ror-as-example/</link>
		<comments>http://blog.osamadwairi.com/2011/04/14/starting-a-software-project-ror-as-example/#comments</comments>
		<pubDate>Thu, 14 Apr 2011 13:36:28 +0000</pubDate>
		<dc:creator>Osama</dc:creator>
				<category><![CDATA[concepts]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[Ruby and Ruby On Rails]]></category>
		<category><![CDATA[System Administration]]></category>
		<category><![CDATA[deployment]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[ror]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[software managent]]></category>

		<guid isPermaLink="false">http://blog.osamadwairi.com/?p=258</guid>
		<description><![CDATA[Working in software development field you need to work on &#8220;devil&#8221; details, manage dependencies, commit to deadlines and ensure a smooth process of development and maintenance and not be [..]]]></description>
			<content:encoded><![CDATA[<p>Working in software development field you need to work on &#8220;devil&#8221; details, manage dependencies, commit to deadlines and ensure a smooth process of development and maintenance and not be the bottleneck of a project success.</p>
<p>While being organized is an important aspect of anyone&#8217;s life style, it&#8217;s an important aspect of every developer&#8217;s life to ensure &#8211; in the first place &#8211; a lesser-stressed day to day work (uh, well!).</p>
<p>in this article I am telling the story of setting up a development environment for a Ruby on rails application, but you can apply the same concepts for any project, regardless of the programming language you use, regardless of the techniques you use and regardless of any 3rd party integration requirements.</p>
<p>to start simply, after receiving project requirements, doing your researches and decide on technology to use, you need to start thinking about the process of development, deployment and testing, until the first production ready product is in place.</p>
<p><strong>Development</strong></p>
<p>Obviously you need to install Ruby on Rails framework (here we use the latest stable ruby version 1.9.2 and rails 3.x at the time of writing this article) to start developing a Ruby on Rails based-project, so, here are the steps to install RoR for your Linux Machine (Ruby on Rails on Windows machines works on a one-click installer).</p>
<ul>
<li>using Linux famous software manager yum, we will install the OS dependencies for ruby
<pre>su - root
yum install zlib zlib-devel openssl openssl-devel readline readline-devel</pre>
</li>
<li>download <a style="color: #0071bb; outline-style: none; outline-width: initial; outline-color: initial; padding: 0px; margin: 0px;" title="ruby 1.9.2x" href="http://www.ruby-lang.org/en/downloads/" target="_blank">ruby 1.9.2x</a> from source.</li>
<li>compile ruby source and install additional libraries using the following commands

<div class="wp_codebox_msgheader wp_codebox_hide"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p258code19'); return false;">View Code</a> LINUX</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p25819"><td class="code" id="p258code19"><pre class="linux" style="font-family:monospace;">cd ruby-1.9.2-p0
./configure
make
make install
cd ext/zlib
ruby extconf.rb
make
make install
cd ../openssl
make
make install
cd ../readline
make
make install
sudo gem install rails
cd ext/zlib
ruby extconf.rb
make
make install
cd ../openssl
make
make install
cd ../readline
make
make install</pre></td></tr></table></div>

<p><span style="font-family: 'Segoe UI', Calibri, 'Myriad Pro', Myriad, 'Trebuchet MS', Helvetica, Arial, sans-serif; line-height: 19px; white-space: normal;">ruby 1.9.2 ships with gem! that means you don&#8217;t need to install gem.</span></li>
</ul>
<ul>
<li>install rails using gem command that just installed with ruby

<div class="wp_codebox_msgheader wp_codebox_hide"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p258code20'); return false;">View Code</a> LINUX</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p25820"><td class="code" id="p258code20"><pre class="linux" style="font-family:monospace;">gem install rails</pre></td></tr></table></div>

</li>
<li>logout from super user <em>root</em> and create your ruby on rails application</li>
</ul>
<ul>
<li>

<div class="wp_codebox_msgheader wp_codebox_hide"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p258code21'); return false;">View Code</a> LINUX</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p25821"><td class="code" id="p258code21"><pre class="linux" style="font-family:monospace;">rails new my_app
rails server</pre></td></tr></table></div>

</li>
<li>go to http://127.0.0.1:3000/ to test that your installation is working as expected, you should get the default ruby on rails page.</li>
<li>you need an IDE (I prefer Aptana for rails, Eclipse for Java, and vim editor for php and python <img src='http://blog.osamadwairi.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' />  )</li>
</ul>
<p><strong>Deployment</strong></p>
<p>Deployment process is meant to make your development process more comfortable, know who did what, keep track of code revisions and safely rollback to any revision of the software &#8211; simply ensure your product is stable in production (that is in front of your customers), and maintainable.</p>
<p>on the other hand, you need to have software configuration system that is to manage source code revisions, smoothly aggregate multi-developers work and have a better rollback process.</p>
<p>speaking web application is meant to run into an application server, that will serve your users request, for ruby on rails, I will set up apache http server with Phusion (know as mod_rails) on next article.pro</p>
<p>Common saying: &#8220;most projects failures is management failures&#8221;, well, the first step is to get yourself organized.</p>
<p>have a nice and organized coding!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.osamadwairi.com/2011/04/14/starting-a-software-project-ror-as-example/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>ORM: The concept, problem and the solution</title>
		<link>http://blog.osamadwairi.com/2011/03/02/orm-the-concept-problem-and-the-solution/</link>
		<comments>http://blog.osamadwairi.com/2011/03/02/orm-the-concept-problem-and-the-solution/#comments</comments>
		<pubDate>Wed, 02 Mar 2011 19:27:58 +0000</pubDate>
		<dc:creator>Osama</dc:creator>
				<category><![CDATA[concepts]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[object relation mapping]]></category>
		<category><![CDATA[ORM]]></category>

		<guid isPermaLink="false">http://blog.osamadwairi.com/?p=244</guid>
		<description><![CDATA[ORM in computer software stands for Object Relational Mapping, which is a technique for mapping system types into Relational Database types and make DB tables available for use [..]]]></description>
			<content:encoded><![CDATA[<p>ORM in computer software stands for <strong>O</strong>bject <strong>R</strong>elational <strong>M</strong>apping, which is a technique for mapping system types into Relational Database types and make DB tables available for use as Objects and Classes, thus creating virtual Object-Relational Database.</p>
<p>In ORM, a one Class instance is mapped to one Relational Database table record. for example, suppose we have a table called &#8220;users&#8221; that have three columns &#8220;id&#8221;, &#8220;full_name&#8221; and &#8220;email_address&#8221;, to express this table into Object a Class that have three member variables that is mapped to the three table&#8217;s columns, converting columns values from Database data types into system types when querying for records and back into columns data types when saving or updating record.</p>
<p>Every software technique has come to solve an issue, reduce cost, time and effort. ORM &#8211; alike &#8211; is here for the sake of making Developers&#8217; life easier when it comes to dealing with Databases.</p>
<p>Many ORM softwares &#8211; both commercial and open source &#8211; are off the shelf to pick and use, and as always, each software has its own hassle, for instance looking at libraries implemented using Java language you can find many ranging from complex to plain ORM implementations.</p>
<p>obstacles raise when it comes to implementing ORM softwares, this can be viewed from database and software side; as for database side: we can talk about securing data integrity, doing Joins and bulk operations. and from software point of view we can talk about performance, debugging and concurrency.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.osamadwairi.com/2011/03/02/orm-the-concept-problem-and-the-solution/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>print days &#8211; ruby language</title>
		<link>http://blog.osamadwairi.com/2011/01/13/print-days-ruby-language/</link>
		<comments>http://blog.osamadwairi.com/2011/01/13/print-days-ruby-language/#comments</comments>
		<pubDate>Thu, 13 Jan 2011 06:44:42 +0000</pubDate>
		<dc:creator>Osama</dc:creator>
				<category><![CDATA[code snippet]]></category>
		<category><![CDATA[Ruby and Ruby On Rails]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Date]]></category>
		<category><![CDATA[date range]]></category>
		<category><![CDATA[days]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[Time]]></category>

		<guid isPermaLink="false">http://blog.osamadwairi.com/?p=234</guid>
		<description><![CDATA[print out the days from one day to another for your Rails project, using mixins. <a href="http://blog.osamadwairi.com/2011/01/13/print-days-ruby-language/"><span class="read-more">Read more <span class="meta-nav">&#187;</span></span></a>]]></description>
			<content:encoded><![CDATA[<p>In the context of don&#8217;t talk it, show it to me: this is a helper method for Date class I used in a recent Ruby on Rails project that make it easy to walk from one day to another.</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p234code22'); return false;">View Code</a> RUBY</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p23422"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
</pre></td><td class="code" id="p234code22"><pre class="ruby" style="font-family:monospace;"><span style="color:#9966CC; font-weight:bold;">class</span> <span style="color:#CC00FF; font-weight:bold;">Date</span>
  <span style="color:#9966CC; font-weight:bold;">def</span> <span style="color:#0000FF; font-weight:bold;">self</span>.<span style="color:#9900CC;">walk_days</span><span style="color:#006600; font-weight:bold;">&#40;</span>start_date, end_date, <span style="color:#CC0066; font-weight:bold;">format</span> = <span style="color:#996600;">&quot;%m/%d/%Y&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
    dates = <span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#006600; font-weight:bold;">&#93;</span>
    s = <span style="color:#CC00FF; font-weight:bold;">Date</span>.<span style="color:#9900CC;">strptime</span><span style="color:#006600; font-weight:bold;">&#40;</span>start_date, <span style="color:#CC0066; font-weight:bold;">format</span><span style="color:#006600; font-weight:bold;">&#41;</span>
    e = <span style="color:#CC00FF; font-weight:bold;">Date</span>.<span style="color:#9900CC;">strptime</span><span style="color:#006600; font-weight:bold;">&#40;</span>end_date, <span style="color:#CC0066; font-weight:bold;">format</span><span style="color:#006600; font-weight:bold;">&#41;</span>
    cur = s
    <span style="color:#9966CC; font-weight:bold;">while</span> <span style="color:#0000FF; font-weight:bold;">true</span>
      <span style="color:#9966CC; font-weight:bold;">if</span> cur === e
        dates <span style="color:#006600; font-weight:bold;">&lt;&lt;</span> cur
        <span style="color:#9966CC; font-weight:bold;">break</span>
      <span style="color:#9966CC; font-weight:bold;">end</span>
      dates <span style="color:#006600; font-weight:bold;">&lt;&lt;</span> cur
      cur = cur.<span style="color:#9900CC;">next_day</span>
    <span style="color:#9966CC; font-weight:bold;">end</span>
    dates
  <span style="color:#9966CC; font-weight:bold;">end</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre></td></tr></table></div>

<p>this code snippet use mixins and it can be used as follows</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p234code23'); return false;">View Code</a> RUBY</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p23423"><td class="line_numbers"><pre>1
2
3
</pre></td><td class="code" id="p234code23"><pre class="ruby" style="font-family:monospace;"><span style="color:#CC00FF; font-weight:bold;">Date</span>.<span style="color:#9900CC;">walk_days</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;01/21/2011&quot;</span>, <span style="color:#996600;">&quot;02/09/2011&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color:#9900CC;">each</span> <span style="color:#9966CC; font-weight:bold;">do</span> <span style="color:#006600; font-weight:bold;">|</span>d<span style="color:#006600; font-weight:bold;">|</span>
  <span style="color:#CC0066; font-weight:bold;">puts</span> <span style="color:#996600;">&quot;Day: &quot;</span> <span style="color:#006600; font-weight:bold;">+</span> d.<span style="color:#9900CC;">strftime</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;%B %d, %Y&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://blog.osamadwairi.com/2011/01/13/print-days-ruby-language/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Secret to Success &#8211; video</title>
		<link>http://blog.osamadwairi.com/2010/09/22/secret-to-success-video/</link>
		<comments>http://blog.osamadwairi.com/2010/09/22/secret-to-success-video/#comments</comments>
		<pubDate>Wed, 22 Sep 2010 13:24:48 +0000</pubDate>
		<dc:creator>Osama</dc:creator>
				<category><![CDATA[howto]]></category>
		<category><![CDATA[Personal]]></category>
		<category><![CDATA[secret]]></category>
		<category><![CDATA[success]]></category>

		<guid isPermaLink="false">http://blog.osamadwairi.com/?p=194</guid>
		<description><![CDATA[watch this, he has a good story to tell]]></description>
			<content:encoded><![CDATA[<p>watch this, he has a good story to tell<br />
<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="480" height="385" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="allowFullScreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="src" value="http://www.youtube.com/v/3NQREuc7JX8?fs=1&amp;hl=en_US&amp;rel=0" /><param name="allowfullscreen" value="true" /><embed type="application/x-shockwave-flash" width="480" height="385" src="http://www.youtube.com/v/3NQREuc7JX8?fs=1&amp;hl=en_US&amp;rel=0" allowscriptaccess="always" allowfullscreen="true"></embed></object></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.osamadwairi.com/2010/09/22/secret-to-success-video/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>know how and what</title>
		<link>http://blog.osamadwairi.com/2010/09/14/know-how-and-what/</link>
		<comments>http://blog.osamadwairi.com/2010/09/14/know-how-and-what/#comments</comments>
		<pubDate>Tue, 14 Sep 2010 07:03:15 +0000</pubDate>
		<dc:creator>Osama</dc:creator>
				<category><![CDATA[howto]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[projects]]></category>
		<category><![CDATA[Software Management]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[research]]></category>
		<category><![CDATA[SOA]]></category>
		<category><![CDATA[spring]]></category>
		<category><![CDATA[spring DM]]></category>
		<category><![CDATA[spring dynamic modules]]></category>
		<category><![CDATA[spring sources]]></category>
		<category><![CDATA[spring-osgi]]></category>
		<category><![CDATA[springsources]]></category>

		<guid isPermaLink="false">http://blog.osamadwairi.com/?p=175</guid>
		<description><![CDATA[An important point when researching any topic is &#8220;how to start researching&#8221;. Take in mind that you might and might not know a thing about the topic you [..]]]></description>
			<content:encoded><![CDATA[<p>An important point when researching any topic is &#8220;how to start researching&#8221;.</p>
<p>Take in mind that you might and might not know a thing about the topic you are requested to research; here I will point my finger to a good starting point.</p>
<p>first thing first: Google the exact phrase but don&#8217;t mess with a long article on howto and so on. you only need to find out what is and why. for me and in many topics I check a <a title="Slide Share" href="http://www.slideshare.net/">slideshare </a>document (that is my favourite place) and start writing questions to answer.</p>
<p>actually, every research start with a question and a good researcher is the one who can ask the right questions &#8211; easy, ha!</p>
<p>Ok, let&#8217;s put on hands a real example, recently I decided to take a look at Spring-OSGi (Spring Dynamic Modules) as an example on <a title="Service Oriented Architecture" href="http://en.wikipedia.org/wiki/Service-oriented_architecture">SOA</a>.</p>
<p>Google it: Spring Dynamic Module and pick the slideshar presentation, below is the questions we need to answer about this topic:</p>
<ol>
<li>What is Spring-OSGi?</li>
<li>Its lifecycle</li>
<li>what are the pros and cons of using it over other OSGi implemntations?<br />
you don&#8217;t need to read about every other alternative in the world in this stage of research, you could look for reviews on the topic. and that can lead you to research another topic, but be careful not to fall in the Dip!</li>
<li>how to use it &#8211; a tutorial?</li>
</ol>
<p>answering the above questions will lead you to a good understanding for Spring-OSGi and you should be able (as a software developer) to write a POC of it.</p>
<p>for me, the above questions shouldn&#8217;t take more than 15 working hours to get the POC up and running.</p>
<p>- Osama</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.osamadwairi.com/2010/09/14/know-how-and-what/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>an advise for Entrepreneur</title>
		<link>http://blog.osamadwairi.com/2010/07/11/an-advise-for-entrepreneur/</link>
		<comments>http://blog.osamadwairi.com/2010/07/11/an-advise-for-entrepreneur/#comments</comments>
		<pubDate>Sun, 11 Jul 2010 07:37:09 +0000</pubDate>
		<dc:creator>Osama</dc:creator>
				<category><![CDATA[howto]]></category>
		<category><![CDATA[in short]]></category>
		<category><![CDATA[projects]]></category>
		<category><![CDATA[Software Management]]></category>
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.osamadwairi.com/blog/?p=141</guid>
		<description><![CDATA[saying it in short is Entrepreneur: You’re No Steve Jobs, So Look Before You Leap Not every person who have an idea is the 2nd Steve Jobs. Life [..]]]></description>
			<content:encoded><![CDATA[<p>saying it in short is <a title="TechCrunch" href="http://techcrunch.com/2010/07/10/entrepreneur-you%E2%80%99re-no-steve-jobs-so-look-before-you-leap/">Entrepreneur: You’re No Steve Jobs, So Look Before You Leap</a></p>
<ul>
<li>Not every person who have an idea is the 2nd Steve Jobs.</li>
<li>Life does not work like this: &#8220;if you build it, they will come”, you should be careful to fancy your ideas to yourself!</li>
<li>lack of customer validation is one of the biggest reasons for startup failures, you need to figure out what &#8211; potential &#8211; customers really need.</li>
<li>One example of successful startup is <a title="Campfire labs" href="http://www.campfirelabs.com/">Campfire Labs</a>, check them out!</li>
<li>a five-steps process is to become more successful &#8211; like Jobs? OK, stick to high standards, be disciplined, an idea should solve customers&#8217; problem and try to have as few as possible products at one time.</li>
</ul>
<p>well, that is a good article, but who will work on these guidelines? most new entrepreneur know the above mentioned, but who can stick to it? what could prevent you from sticking to these guidelines?</p>
<p>Good Luck for All!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.osamadwairi.com/2010/07/11/an-advise-for-entrepreneur/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>In Short</title>
		<link>http://blog.osamadwairi.com/2010/07/11/in-short/</link>
		<comments>http://blog.osamadwairi.com/2010/07/11/in-short/#comments</comments>
		<pubDate>Sun, 11 Jul 2010 06:58:50 +0000</pubDate>
		<dc:creator>Osama</dc:creator>
				<category><![CDATA[in short]]></category>

		<guid isPermaLink="false">http://www.osamadwairi.com/blog/?p=143</guid>
		<description><![CDATA[if you look under this blog&#8217;s categories, you will find category named &#8220;in short&#8221;, there where I will be adding articles I read, but said in short. many [..]]]></description>
			<content:encoded><![CDATA[<p>if you look under this blog&#8217;s categories, you will find category named &#8220;in short&#8221;, there where I will be adding articles I read, but said in short. many of us have read a long-long article to discover at the end of it, you are reading a repeated ideas, but this time from source with fancy title or bad writing!!</p>
<p>well, since I used to read alot &#8211; when having time, of course &#8211; , I will be putting here what a normal man can understand from an article, say 400 word in 50 word only &#8211; certainly, don&#8217;t count on that!</p>
<p>good reading for All</p>
<p>- Osama</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.osamadwairi.com/2010/07/11/in-short/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>CodeIgniter, I like it!</title>
		<link>http://blog.osamadwairi.com/2010/07/05/codeigniter-i-like-it/</link>
		<comments>http://blog.osamadwairi.com/2010/07/05/codeigniter-i-like-it/#comments</comments>
		<pubDate>Mon, 05 Jul 2010 12:37:07 +0000</pubDate>
		<dc:creator>Osama</dc:creator>
				<category><![CDATA[howto]]></category>
		<category><![CDATA[MVC]]></category>
		<category><![CDATA[Open Source]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[projects]]></category>
		<category><![CDATA[Ruby and Ruby On Rails]]></category>
		<category><![CDATA[System Administration]]></category>
		<category><![CDATA[codeigniter]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[doctrine]]></category>
		<category><![CDATA[mvc]]></category>
		<category><![CDATA[ORM]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://www.osamadwairi.com/blog/?p=135</guid>
		<description><![CDATA[well, since I have started programming, I am a Java guy! I got the chance to work with ruby and ruby on rails (around 2 years), python, shell [..]]]></description>
			<content:encoded><![CDATA[<p>well, since I have started programming, I am a Java guy! I got the chance to work with ruby and ruby on rails (around 2 years), python, shell scripting, and PHP for integration and maintenance purposes.</p>
<p>last weekend I was messing with <a title="Code Igniter" href="http://codeigniter.com/">CodeIgnitor</a> following a <a title="great series of articles" href="http://www.phpandstuff.com/articles/codeigniter-doctrine-from-scratch-day-1-install-and-setup">great series of articles</a> that explains how to work with CodeIgniter and <a title="Doctrine PHP-ORM" href="http://www.doctrine-project.org/">Doctrine</a> step by step.</p>
<p>I advice you to have a look at it, you can install it on windows with <a title="WAMP PHP MySql Apache windows" href="http://www.wampserver.com/en/">WAMP</a> and have it up and running in less than 5 minutes!</p>
<p>why I am looking at it? ok, I have a curse that is looking for new things, and flipping every stone and rock I notice.</p>
<p>that said, my last week was a productive weekend, I have a thing in my pocket for PHP development Now.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.osamadwairi.com/2010/07/05/codeigniter-i-like-it/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

