<?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:atom="http://www.w3.org/2005/Atom" xmlns:openSearch="http://a9.com/-/spec/opensearch/1.1/" xmlns:georss="http://www.georss.org/georss" xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr="http://purl.org/syndication/thread/1.0" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0"><channel><atom:id>tag:blogger.com,1999:blog-8012835501539055810</atom:id><lastBuildDate>Thu, 21 Apr 2011 17:51:54 +0000</lastBuildDate><category>Mobile</category><category>How To</category><category>alphagrip</category><category>ISO 8583</category><category>Hibernate</category><category>JUnir</category><category>Parsing</category><category>Generics</category><category>RPC</category><category>Security</category><category>Java 5</category><category>Java</category><category>Testing</category><category>Java Spring SpringSource</category><category>Remoting</category><category>SOSE</category><category>ergonomic</category><category>JMock</category><category>trackball</category><category>XDoclet</category><category>ORM</category><category>keyboard</category><category>SourceForge</category><category>Spring</category><category>JavaScript</category><category>review</category><category>ACEGI</category><category>Android</category><category>Class</category><title>Franklin Garcia Tech</title><description /><link>http://fggarcia.blogspot.com/</link><managingEditor>noreply@blogger.com (fr4gus)</managingEditor><generator>Blogger</generator><openSearch:totalResults>12</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/FranklinGarciaTech" /><feedburner:info uri="franklingarciatech" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><item><guid isPermaLink="false">tag:blogger.com,1999:blog-8012835501539055810.post-5708403147395834808</guid><pubDate>Fri, 05 Sep 2008 20:13:00 +0000</pubDate><atom:updated>2008-09-05T14:14:19.312-06:00</atom:updated><title>What we can learn from spaghetti sauce</title><description>I found this talk, from Malcolm Gladwell very inspiring:&lt;br /&gt;&lt;br /&gt;&lt;!--cut and paste--&gt;&lt;object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" id="VE_Player" width="320" align="middle" height="285"&gt;&lt;param name="movie" value="http://static.videoegg.com/ted/flash/loader.swf"&gt;&lt;param name="FlashVars" value="bgColor=FFFFFF&amp;amp;file=http://static.videoegg.com/ted/movies/MALCOLMGLADWELL_high.flv&amp;amp;autoPlay=false&amp;amp;fullscreenURL=http://static.videoegg.com/ted/flash/fullscreen.html&amp;amp;forcePlay=false&amp;amp;logo=&amp;amp;allowFullscreen=true"&gt;&lt;param name="quality" value="high"&gt;&lt;param name="allowScriptAccess" value="always"&gt;&lt;param name="bgcolor" value="#FFFFFF"&gt;&lt;param name="scale" value="noscale"&gt;&lt;param name="wmode" value="window"&gt;&lt;embed src="http://static.videoegg.com/ted/flash/loader.swf" flashvars="bgColor=FFFFFF&amp;amp;file=http://static.videoegg.com/ted/movies/MALCOLMGLADWELL_high.flv&amp;amp;autoPlay=false&amp;amp;fullscreenURL=http://static.videoegg.com/ted/flash/fullscreen.html&amp;amp;forcePlay=false&amp;amp;logo=&amp;amp;allowFullscreen=true" quality="high" allowscriptaccess="always" bgcolor="#FFFFFF" scale="noscale" wmode="window" name="VE_Player" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" width="320" align="middle" height="285"&gt;&lt;/embed&gt;&lt;/object&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8012835501539055810-5708403147395834808?l=fggarcia.blogspot.com' alt='' /&gt;&lt;/div&gt;</description><link>http://feedproxy.google.com/~r/FranklinGarciaTech/~3/dxNtCwiDPSY/what-we-can-learn-from-spaghetti-sauce.html</link><author>noreply@blogger.com (fr4gus)</author><thr:total>1</thr:total><feedburner:origLink>http://fggarcia.blogspot.com/2008/09/what-we-can-learn-from-spaghetti-sauce.html</feedburner:origLink></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-8012835501539055810.post-4670762147901968055</guid><pubDate>Tue, 02 Sep 2008 21:53:00 +0000</pubDate><atom:updated>2008-09-03T14:17:20.339-06:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">keyboard</category><category domain="http://www.blogger.com/atom/ns#">alphagrip</category><category domain="http://www.blogger.com/atom/ns#">trackball</category><category domain="http://www.blogger.com/atom/ns#">ergonomic</category><category domain="http://www.blogger.com/atom/ns#">review</category><title>AlphaGrip Ergonomic Keyboard Review</title><description>&lt;div&gt;As PC Gamer and Coder, the consequencies of using a keyBOARD and MICE during all these years had finally appeared. My right wrist hurts after hours of been in front of my computer, and get worst, after hours and hours of playing video games (Mi name is Franklin and I'm WoWcoholic)&lt;/div&gt;&lt;br /&gt;&lt;div&gt;After using for months a wirst supporter, trying to mitigate the symptoms of my carpal tunnel syndrome, I realize that I had to attack the problem from its source.... the keyboard and the mice. So I stated a little research looking for the most ergonomic devices in the market. May be the causality (I know Morpheus... there is no such thing as fate) or the causality (hmmm may be the Merovingian was right), my brother send my this URL: http://www.alphagrips.com. Not sure why he did it... may be because I'm a compulsive shopper, but the thing is that I found what I was looking... actually more than what I was looking for.&lt;/div&gt;&lt;br /&gt;&lt;div&gt;I did some research on reviews and what the AlphaGrip has been doing, and when I felt confortable with the review I took the decision of trying one of those keyboards... eh gamepads... ehh keypads. The last week I received my AlphaGrip Keybard/Trackball, and after a week of using it I want to share with you my impressions.&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_s3RihcmokIY/SL29CFKeX-I/AAAAAAAAABM/ZOACAk3UrDg/s1600-h/IMG_3538.jpg"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="http://2.bp.blogspot.com/_s3RihcmokIY/SL29CFKeX-I/AAAAAAAAABM/ZOACAk3UrDg/s400/IMG_3538.jpg" alt="" id="BLOGGER_PHOTO_ID_5241553384772624354" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;At the first look, you can be impressed with how it looks. You can think its a gamepad and not a keyboard. With only 48 keys it can perform almost all the actions you could do with a standard 101 keys keyboard. It doesn't weight too much, so I was able to hold it all work day. It has a pause button in some how like a lock button, so no other keys will react if you press them, neither the trackball. I can guarantee this keyboard if fully ergonomic, my fingers fits on the keys without put my hands in any weird position.&lt;br /&gt;&lt;br /&gt;Learning to type again is a little frustating, since I know I can type faster in a standard keyboard. But after using it for some days, I feel I'm getting faster and accurate when typing. This make me remember when I started to type in the a regular keyboard, and I think it took me longer with it.&lt;br /&gt;&lt;br /&gt;But not everything is good with this keyboard... whell I like to name it keypad, since is not a "board". Holding the keypad requires to hold it with all your hand, so after using it for several minutes makes your hand sweat. Some of its keys are really sensitive, while others are a little hard to press. Also, when typing, you can press more than one key accidentally (just with the keys that should be managed with your thumbs), but nothing to be worried with more practice.&lt;br /&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;I was quite impressed with the trackball. This mice replacement is really comfortable and has really good response. I tried it with World of Warcraft and I feel I could play with it without problems. On day-by-day work, the trackball is very good, and requires less practice that I thought.&lt;br /&gt;&lt;br /&gt;If you are looking for a ergonomic 2-in-1 keyboard and you have $100 burning in your pocket this is a good option.&lt;br /&gt;&lt;br /&gt;I'll give my final score after two months of using, and see if I finally was able to use it.&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8012835501539055810-4670762147901968055?l=fggarcia.blogspot.com' alt='' /&gt;&lt;/div&gt;</description><link>http://feedproxy.google.com/~r/FranklinGarciaTech/~3/0N6LmzF3XS8/alphagrip-ergonomic-keyboard.html</link><author>noreply@blogger.com (fr4gus)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://2.bp.blogspot.com/_s3RihcmokIY/SL29CFKeX-I/AAAAAAAAABM/ZOACAk3UrDg/s72-c/IMG_3538.jpg" height="72" width="72" /><thr:total>0</thr:total><feedburner:origLink>http://fggarcia.blogspot.com/2008/09/alphagrip-ergonomic-keyboard.html</feedburner:origLink></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-8012835501539055810.post-7992071363433572310</guid><pubDate>Wed, 30 Apr 2008 20:15:00 +0000</pubDate><atom:updated>2008-04-30T14:47:08.565-06:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">ISO 8583</category><category domain="http://www.blogger.com/atom/ns#">SourceForge</category><category domain="http://www.blogger.com/atom/ns#">Java</category><category domain="http://www.blogger.com/atom/ns#">SOSE</category><category domain="http://www.blogger.com/atom/ns#">Parsing</category><title>SOSE 1.0 Beta 1 Released</title><description>I'm happy to announce that SOSE has been released as Beta 1. This has been a personal project for 1 year. I developed this tool in my last job, for helping us process transactional information between legacy and our Java systems. Now I created this project at SourceForge.net.&lt;br /&gt;&lt;br /&gt;Simple Object String Extractor (previously called Parsernate) is a tool for plain-text messages processing, that contains information that can be stored as property values in a Java class.&lt;br /&gt;&lt;br /&gt;Let's see an example:&lt;br /&gt;&lt;br /&gt;&lt;img src="http://img514.imageshack.us/img514/2504/tramave5.png" alt="" border="0" /&gt;&lt;br /&gt;&lt;br /&gt;Where the first 4 characters represents an application ID, the next 15 characters the Firstname, the other 15 characters represents the Lastname, then 9 characters for a personal ID,  other 9 characters for phone number and the lasta 20 characters for Job Title.&lt;br /&gt;&lt;br /&gt;So typically, you could use the famous String.subString() method, and get all those values and set it in a Java object for application porpouses... but if you have to set more than one message type, the work makes more complicated. And this gets worst if you have to make updates on your code in order to handle message changes.&lt;br /&gt;&lt;br /&gt;Now imagine you need to work with the &lt;a href="http://en.wikipedia.org/wiki/ISO_8583"&gt;ISO 8583 &lt;/a&gt; and parse several messages, well may be SOSE is for you.&lt;br /&gt;&lt;br /&gt;When I did this library on the first time, I did a lot of type handling and I divided the property in three groups: Simple, Complex and Container properties. The Simple properties were Java primitives as class properties. Complex properties, refers to property class that are User-made classes. And the last one are Container properties, that can be List or Maps.&lt;br /&gt;&lt;br /&gt;Since Java 5 release and above, I did a lot of changes on my code, so right now, and for this beta , I'm just handling simple and complex properties. I'll probably release a new one with this functionality soon. I also want to provide a documentation about how to use it and create a web page (at the first time hosted at SourceForge) for this.&lt;br /&gt;&lt;br /&gt;SOSE is available at SourceForge: http://sourceforge.net/projects/sose/&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8012835501539055810-7992071363433572310?l=fggarcia.blogspot.com' alt='' /&gt;&lt;/div&gt;</description><link>http://feedproxy.google.com/~r/FranklinGarciaTech/~3/DWN5oeG_eao/sose-10-beta-1-released.html</link><author>noreply@blogger.com (fr4gus)</author><thr:total>0</thr:total><feedburner:origLink>http://fggarcia.blogspot.com/2008/04/sose-10-beta-1-released.html</feedburner:origLink></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-8012835501539055810.post-6121636138141147990</guid><pubDate>Tue, 29 Apr 2008 15:00:00 +0000</pubDate><atom:updated>2008-04-29T09:23:14.160-06:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">SOSE</category><category domain="http://www.blogger.com/atom/ns#">Generics</category><category domain="http://www.blogger.com/atom/ns#">Class</category><category domain="http://www.blogger.com/atom/ns#">Java 5</category><title>Class and Generics</title><description>Well, I was working in a Java library I'm developing and I found a little issue(may be lack of knowledge) using Class and Generics together. I'm not sure if could be a better solution, I hope to find it soon.&lt;br /&gt;&lt;br /&gt;As you know, from Java 5 and above, the Class class now has a generic parameter, so now it is Class&amp;lt;T&amp;gt;. I have a method with the following contract:&lt;br /&gt;&lt;br /&gt;Before Generics:&lt;br /&gt;&lt;pre&gt;public Object getObject(String source);&lt;/pre&gt;&lt;br /&gt;With Generics:&lt;br /&gt;&lt;pre&gt;public T getObject(String source);&lt;/pre&gt;&lt;br /&gt;Where the basic idea is convert the String into an Object. I don't know which kind of object is until Runtime, so I used to use the following code:&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;// Getting an instance of the object&lt;br /&gt;Class classDefinition = Class.forName( className );&lt;br /&gt;Object result = classDefinition.newInstance();&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;But now with generics I would like to use them and change my code to this:&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;// Getting an instance of the object&lt;br /&gt;Class&amp;lt;T&amp;gt; classDefinition = Class.forName( className );&lt;br /&gt;T result = classDefinition.newInstance();&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;receiving an error from the compiler, since Class&amp;lt;capture-of ?&amp;gt;&lt;t&gt;&lt;capture-of&gt; is not equals to Class&lt;/capture-of&gt;&lt;/t&gt;&amp;lt;T&amp;gt;&lt;t&gt;&lt;capture-of&gt;. So the only fast and not fancy solution is cast it (LOL so why generics??).&lt;br /&gt;&lt;/capture-of&gt;&lt;/t&gt;&lt;pre&gt;&lt;br /&gt;// Getting an instance of the object&lt;br /&gt;Class&amp;lt;T&amp;gt; classDefinition = &lt;span style="font-weight: bold;"&gt;(Class&amp;lt;T&amp;gt;)&lt;/span&gt; Class.forName( className );&lt;br /&gt;T result = classDefinition.newInstance();&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;My code works, but I would like to not use the down-casting. I'll be digging about this and update this post as soon I find the solution. Comments about this are welcome.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8012835501539055810-6121636138141147990?l=fggarcia.blogspot.com' alt='' /&gt;&lt;/div&gt;</description><link>http://feedproxy.google.com/~r/FranklinGarciaTech/~3/GrgDnOLYLBw/class-and-generics.html</link><author>noreply@blogger.com (fr4gus)</author><thr:total>0</thr:total><feedburner:origLink>http://fggarcia.blogspot.com/2008/04/class-and-generics.html</feedburner:origLink></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-8012835501539055810.post-3067492636097163459</guid><pubDate>Thu, 13 Dec 2007 04:08:00 +0000</pubDate><atom:updated>2007-12-12T22:39:33.448-06:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Java Spring SpringSource</category><title>D-Day: The Spring Experience</title><description>I'm really excited to be here in Hollywood, Florida, attending The Spring Experience Conference at the Westing Diplomat Hotel.&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://www.thespringexperience.com/images/tse/tse_logo.gif"&gt;&lt;img style="margin: 0pt 10px 10px 0pt; cursor: pointer;" src="http://www.thespringexperience.com/images/tse/tse_logo.gif" alt="" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;During the registration, we received our ID and also a gift set that has a back-pack, a binder, and a T-Shirt. At the end of the day we received also a Rob Johnson "bubble-head".&lt;br /&gt;&lt;br /&gt;After a delicious dinner, Rod Johnson (the man behind Spring Framework) talked about what should we expect from this conference. He started to talk about how SpringSource is growing. He also remarked his vision of Spring as the best way instead JavaEE. I can agree with that sentence when talking about non-distributable web applications. I know that in so many ways, EJBs are ugly, but they have a nice side, they are distributable.&lt;br /&gt;&lt;br /&gt;He also talked about the new products available in the Spring Portfolio:&lt;br /&gt;&lt;br /&gt;Spring Security (one of the topic I'm interested to). Basically, the Spring Security 2.0 is meant to replace Acegi Security. One of the biggest changes is the configuration, now is shorter and easier.&lt;br /&gt;&lt;br /&gt;Spring Web Service 1.0. Again, meant to do web services easy.&lt;br /&gt;&lt;br /&gt;Spring IDE. Stand-alone / add-on for Eclipse to make Spring development smooth, offering also a graphical tool to configure Spring.&lt;br /&gt;&lt;br /&gt;Rob also mentioned how software development companies are choosing Spring instead other solutions like JavaEE pointing that the community is the one in charge to decide what is the path to follow based on real requirements, instead of a "committee".&lt;br /&gt;&lt;br /&gt;Looks like SpringSource (Interface21) is aiming the framework to become an Open Source integration tool for developers providing new growing technologies and adding new features based on what the community needs. A good example is Annotations that is being used to configure Spring, if you don't want to use the XML style.&lt;br /&gt;&lt;br /&gt;I can't wait for tomorrow and attend so interesting presentations.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8012835501539055810-3067492636097163459?l=fggarcia.blogspot.com' alt='' /&gt;&lt;/div&gt;</description><link>http://feedproxy.google.com/~r/FranklinGarciaTech/~3/fgUfO1C8ZyQ/d-day-spring-experience.html</link><author>noreply@blogger.com (fr4gus)</author><thr:total>0</thr:total><feedburner:origLink>http://fggarcia.blogspot.com/2007/12/d-day-spring-experience.html</feedburner:origLink></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-8012835501539055810.post-2377395180290862626</guid><pubDate>Tue, 20 Nov 2007 16:26:00 +0000</pubDate><atom:updated>2007-11-20T10:30:46.464-06:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Java</category><category domain="http://www.blogger.com/atom/ns#">Android</category><title>Setting up proxy for Android Emulator</title><description>I think this information could be useful, is available at Android Group, but is difficult to find as messages there are growing, and the search could retrieve you a lot of messages related. So I want to paste here a message by Jason Chen that explains how to do it:&lt;br /&gt;&lt;br /&gt;Here's how you can specify a proxy server for the Android browser.&lt;br /&gt;&lt;p&gt;1) Connect to the emulator using the "adb shell" command&lt;br /&gt;2) Once you have a prompt, issue the following command:&lt;br /&gt;&lt;/p&gt;&lt;p  style="font-family:courier new;"&gt;&lt;span style="font-size:85%;"&gt;sqlite3 /data/data/com.google.android.providers.settings/databases/&lt;br /&gt;settings.db "INSERT INTO system&lt;br /&gt;VALUES(99,'http_proxy','&lt;your_proxy_ip_or_host&gt;:&lt;proxy_port_number&gt;');"&lt;br /&gt;&lt;/proxy_port_number&gt;&lt;/your_proxy_ip_or_host&gt;&lt;/span&gt; &lt;/p&gt;&lt;p&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:courier new;"&gt;where &lt;your_proxy_ip_or_host&gt; and &lt;proxy_port_number&gt; should be &lt;/proxy_port_number&gt;&lt;/your_proxy_ip_or_host&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt; replaced by the IP or hostname and port number, respectively, for the &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt; proxy server you're using.  (The command should be on one line.) &lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;*Note*: you may need to restart the emulator for the change to be&lt;br /&gt;recognized by the browser.&lt;br /&gt;&lt;/p&gt;&lt;p&gt;While in "adb shell", you can check to see if your proxy was added&lt;br /&gt;correctly by issuing the following:&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=";font-family:courier new;font-size:85%;"  &gt;sqlite3 /data/data/com.google.android.providers.settings/databases/&lt;br /&gt;settings.db "SELECT * FROM system" &lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;If things worked correctly, you should see something like:&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=";font-family:courier new;font-size:85%;"  &gt;# sqlite3 /data/data/com.google.android.providers.settings/databases/&lt;br /&gt;settings.db "SELECT * FROM system"&lt;br /&gt;1|music_volume|3&lt;br /&gt;2|voice_volume|3&lt;br /&gt;3|ringer_volume|3&lt;br /&gt;99|http_proxy|proxy.example.com:4242 &lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;To remove the proxy setting, issue the following command via "adb&lt;br /&gt;shell":&lt;br /&gt;&lt;/p&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:courier new;"&gt;sqlite3 /data/data/com.google.android.providers.settings/databases/ &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt; settings.db "DELETE FROM system WHERE _id=99" &lt;/span&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8012835501539055810-2377395180290862626?l=fggarcia.blogspot.com' alt='' /&gt;&lt;/div&gt;</description><link>http://feedproxy.google.com/~r/FranklinGarciaTech/~3/8FNNarjGkjw/setting-up-proxy-for-android-emulator.html</link><author>noreply@blogger.com (fr4gus)</author><thr:total>0</thr:total><feedburner:origLink>http://fggarcia.blogspot.com/2007/11/setting-up-proxy-for-android-emulator.html</feedburner:origLink></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-8012835501539055810.post-5650460586564010981</guid><pubDate>Fri, 16 Nov 2007 22:21:00 +0000</pubDate><atom:updated>2007-11-16T16:27:12.613-06:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Java</category><category domain="http://www.blogger.com/atom/ns#">Mobile</category><category domain="http://www.blogger.com/atom/ns#">Android</category><title>A first look of Android</title><description>&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://code.google.com/android/index.html"&gt;&lt;img style="margin: 0pt 10px 10px 0pt; float: left; cursor: pointer;" src="http://code.google.com/android/images/logo_android.gif" alt="" border="0" /&gt;&lt;/a&gt;OpenAlliance recently released an “early look” edition of its Android platform. Android is a set of software for mobile devices: an operating system, middleware and mobile applications. Built on the open Linux kernel, it utilizes a custom virtual machine called Dalvik. OpenAlliance hasn’t yet released the SDK code, but promises to “open it” in the future. The SDK provides a phone emulator, debugging tools and sample code.&lt;br /&gt;&lt;br /&gt;&lt;a href="http://insidethebox.schematic.com/2007/11/16/a-first-look-at-android/"&gt;Read More&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8012835501539055810-5650460586564010981?l=fggarcia.blogspot.com' alt='' /&gt;&lt;/div&gt;</description><link>http://feedproxy.google.com/~r/FranklinGarciaTech/~3/Aoz99c5Jwms/first-look-of-android.html</link><author>noreply@blogger.com (fr4gus)</author><thr:total>0</thr:total><feedburner:origLink>http://fggarcia.blogspot.com/2007/11/first-look-of-android.html</feedburner:origLink></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-8012835501539055810.post-2693153797657776282</guid><pubDate>Mon, 12 Nov 2007 16:41:00 +0000</pubDate><atom:updated>2007-11-16T16:13:55.162-06:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Security</category><category domain="http://www.blogger.com/atom/ns#">Java</category><category domain="http://www.blogger.com/atom/ns#">Testing</category><category domain="http://www.blogger.com/atom/ns#">JUnir</category><category domain="http://www.blogger.com/atom/ns#">JMock</category><category domain="http://www.blogger.com/atom/ns#">ACEGI</category><category domain="http://www.blogger.com/atom/ns#">Spring</category><title>Mocking ACEGI security users</title><description>In one of my projects I had to test some features, using JUnit and JMock. The features that I had to test were based on roles assigned to an already logged user. I realized that I have to populate the SecurityContextHolder with some dummy user data to be able to test. Based on ACEGI Security source code of some tests I could find a solution for that (actually is the test case for BasicProcessingFilter class).&lt;br /&gt;&lt;br /&gt;This is the code:&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;public class MyAcegiTest{&lt;br /&gt;&lt;br /&gt; Mockery context = new Mockery();&lt;br /&gt; private BasicProcessingFilter filter = new BasicProcessingFilter();&lt;br /&gt;&lt;br /&gt; @Before&lt;br /&gt; public void init() throws Exception{&lt;br /&gt;   // Cleaning any previous information on SecurityContextHolder&lt;br /&gt;   SecurityContextHolder.clearContext()&lt;br /&gt; &lt;br /&gt;   // Using in-memory DAO&lt;br /&gt;   InMemoryDaoImpl dao = new InMemoryDaoImpl();  &lt;br /&gt;   UserMapEditor editor = new UserMapEditor();&lt;br /&gt; &lt;br /&gt;   // the user jsmith will have two roles, Manager and User, you can use whatever you need here.&lt;br /&gt;   editor.setAsText("jsmith=jsmith,ROLE_MANAGER,ROLE_USER,enabled\r\n");&lt;br /&gt;   dao.setUserMap((UserMap)editor.getValue());&lt;br /&gt;   DaoAuthenticationProvider provider = new DaoAuthenticationProvider();&lt;br /&gt;   provider.setUserDetailsService(dao);&lt;br /&gt;&lt;br /&gt;   ProviderManager manager = new ProviderManager();&lt;br /&gt;   manager.setProviders(Arrays.asList(new Object[] {&lt;br /&gt;     provider&lt;br /&gt;   }));&lt;br /&gt;   // The mock for ApplicationEventPublisher is at the end of this class&lt;br /&gt;   manager.setApplicationEventPublisher(new MockApplicationEventPublisher());&lt;br /&gt;   manager.afterPropertiesSet();&lt;br /&gt; &lt;br /&gt;   // Setting up the filter&lt;br /&gt;   filter.setAuthenticationManager(manager);&lt;br /&gt;   filter.setAuthenticationEntryPoint(new BasicProcessingFilterEntryPoint());&lt;br /&gt; &lt;br /&gt; }&lt;br /&gt;&lt;br /&gt; @Test&lt;br /&gt; public void mytest() throws Exception{&lt;br /&gt;   // The token represents as if the user has used a basic authentication form to log in.&lt;br /&gt;   String token = "jsmith:jsmith";&lt;br /&gt; &lt;br /&gt;   //Creating a mock request&lt;br /&gt;   MockHttpServletRequest request = new MockHttpServletRequest();&lt;br /&gt; &lt;br /&gt;   // Filling the request with the necesary headers and properties&lt;br /&gt;   request.addHeader("Authorization", "Basic " + new String(Base64.encodeBase64(token.getBytes())));&lt;br /&gt;   request.setServletPath("/test.do");&lt;br /&gt;   request.setMethod("POST");&lt;br /&gt;   request.setSession(new MockHttpSession());&lt;br /&gt;&lt;br /&gt;   //Here is where the magic is done. Checks the login information (on Authorization header)&lt;br /&gt;   //and populates the SecurityContextHolder with the user information creating the Authentication object&lt;br /&gt;   //, so you can use SecurityContextHolder.getContext().getAuthentication() after this line&lt;br /&gt;   filter.doFilter(request, response, new MockFilterChain());&lt;br /&gt; &lt;br /&gt; &lt;br /&gt; &lt;br /&gt; }&lt;br /&gt;&lt;br /&gt; private class MockApplicationEventPublisher implements ApplicationEventPublisher{&lt;br /&gt;&lt;br /&gt;   public MockApplicationEventPublisher(){}&lt;br /&gt;&lt;br /&gt;   public void publishEvent(ApplicationEvent event){}&lt;br /&gt;&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8012835501539055810-2693153797657776282?l=fggarcia.blogspot.com' alt='' /&gt;&lt;/div&gt;</description><link>http://feedproxy.google.com/~r/FranklinGarciaTech/~3/-ybOo6EbBtQ/mocking-acegi-security-users.html</link><author>noreply@blogger.com (fr4gus)</author><thr:total>0</thr:total><feedburner:origLink>http://fggarcia.blogspot.com/2007/11/mocking-acegi-security-users.html</feedburner:origLink></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-8012835501539055810.post-444105719901449156</guid><pubDate>Fri, 08 Jun 2007 15:30:00 +0000</pubDate><atom:updated>2007-11-16T16:16:37.062-06:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">JavaScript</category><category domain="http://www.blogger.com/atom/ns#">RPC</category><category domain="http://www.blogger.com/atom/ns#">Java</category><category domain="http://www.blogger.com/atom/ns#">Remoting</category><title>How to use: JSON-RPC for Java</title><description>&lt;h2&gt;Why write about this?&lt;/h2&gt;&lt;br /&gt;&lt;p&gt; Basically you can find all the information needed on JSON-RPC official site (http://oss.metaparadigm.com/jsonrpc/). But when I started to use the tutorial I realized that there is more information needed if you are a newbie using remoting technology. I'm not saying tutorial is not complete, If you follow the tutorial you will get the results expected, but you aren't going to understand what really happen and what you can modify to fit you project requirements. Actually I'll probably write more of these "how-to's" when I start to mix frameworks, API's etc; mixes that you probably will find in real world projects. So this little explanation about how to use JSON-RPC is the official tutorial but I'm adding what I'm think should be explained too and is not present in the original.&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;h2&gt;What is JSON-RPC for Java&lt;/h2&gt;&lt;br /&gt;&lt;p&gt; JSON-RPC-Java is a key piece of Java web application middleware that allows JavaScript DHTML web applications to call remote methods in a Java Application Server without the need for page reloading (now referred to as AJAX). It enables a new breed of fast and highly dynamic enterprise Web 2.0 applications (using similar techniques to Gmail and Google Suggests).&lt;/p&gt;&lt;br /&gt;&lt;p&gt; From: http://oss.metaparadigm.com/jsonrpc/&lt;/p&gt;&lt;br /&gt;&lt;h2&gt;Requirements&lt;/h2&gt;&lt;br /&gt;&lt;p&gt; * ant 1.6 or later (to build)&lt;br /&gt;&lt;br /&gt; * A Java Servlet container (such Apache Tomcat, the Tomcat service in JBoss, etc.).&lt;/p&gt;&lt;br /&gt;&lt;h2&gt;&lt;br /&gt;&lt;br /&gt; Setup you environment:&lt;/h2&gt;&lt;br /&gt;&lt;p&gt; * You will need to have configured Java Development Kit and your Servlet container&lt;br /&gt;&lt;br /&gt; * Download JSON-RPC-Java at http://oss.metaparadigm.com/jsonrpc/download.html. The zip file will contain the JAR Library that will be part of your app library and a javascript file needed in your client side files.&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;  Configuring web.xml&lt;/p&gt; You need to configure the JSON-RPC servlet that will handle all the request from the client side. You just should add the following configuration into your web.xml&lt;br /&gt;&lt;pre&gt;    &lt;br /&gt;  &amp;lt;!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"&lt;br /&gt;  "http://java.sun.com/dtd/web-app_2_3.dtd"&amp;gt;&lt;br /&gt;  &amp;lt;web-app&amp;gt;&lt;br /&gt;     &amp;lt;servlet&amp;gt;&lt;br /&gt;         &amp;lt;servlet-name&amp;gt;com.metaparadigm.jsonrpc.JSONRPCServlet&amp;lt;/servlet-name&amp;gt;&lt;br /&gt;         &amp;lt;servlet-class&amp;gt;com.metaparadigm.jsonrpc.JSONRPCServlet&amp;lt;/servlet-class&amp;gt;&lt;br /&gt;     &amp;lt;/servlet&amp;gt;&lt;br /&gt;     &amp;lt;servlet-mapping&amp;gt;&lt;br /&gt;         &amp;lt;servlet-name&amp;gt;com.metaparadigm.jsonrpc.JSONRPCServlet&amp;lt;/servlet-name&amp;gt;&lt;br /&gt;         &amp;lt;url-pattern&amp;gt;/JSON-RPC&amp;lt;/url-pattern&amp;gt;&lt;br /&gt;     &amp;lt;/servlet-mapping&amp;gt;&lt;br /&gt;  &amp;lt;/web-app&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;h2&gt;Registering your services.&lt;/h2&gt;&lt;br /&gt;&lt;p&gt; When we talk about services we are talking about Java Object. Any object with public methods are candidate to be a service. In a multi-tier application the service layer will have the objects that we want to expose to the presentation layer.&lt;/p&gt;&lt;br /&gt;   &lt;br /&gt;&lt;p&gt;For this tut, we are going create a POJO called test.jsonrpc.TestService (OMG what a original name!!!). This service will return a string with server date and will receive the format you need that date.&lt;/p&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;package test.jsonrpc;&lt;br /&gt;&lt;br /&gt;   public class TestService{&lt;br /&gt;     public String getHello(){&lt;br /&gt;        return "Hello friend!";&lt;br /&gt;     }&lt;br /&gt;      public String getRandomValue(int seed){&lt;br /&gt;        Integer value = Integer.valueOf( (int)( Math.random() * (double) seed) );&lt;br /&gt;        return value.toString();&lt;br /&gt;     }&lt;br /&gt;   }&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;p&gt;In order to expose your services using JSON-RPC, you need to register them in somewhere. There are two ways to register your objects (as you will see at the end is the same ;) ).&lt;/p&gt;&lt;br /&gt;&lt;p&gt;In both case, you are going to use the JSONRPCBridge. The JSONRPCBridge holds references to exported objects and decodes and dispatches method calls to them. This means: if you need a object service (register or invoke) JSONRPCBridge is the man.&lt;/p&gt;&lt;br /&gt;&lt;h3&gt; Registering objects via JSP:&lt;/h3&gt;&lt;br /&gt;&lt;p&gt; Get a reference of JSONRPCBridge&lt;/p&gt;&lt;br /&gt;&lt;pre&gt;...&lt;br /&gt;  &amp;lt;jsp:useBean id="JSONRPCBridge" scope="session"&lt;br /&gt;  class="com.metaparadigm.jsonrpc.JSONRPCBridge" /&amp;gt;&lt;br /&gt;  ...&lt;/pre&gt;&lt;br /&gt;&lt;p&gt;Get a reference of the object you want to register&lt;/p&gt;&lt;br /&gt;&lt;pre&gt;...&lt;br /&gt;  &amp;lt;jsp:useBean id="testService" scope="session"&lt;br /&gt;   class="test.jsonrpc.TestService" /&amp;gt;&lt;br /&gt;...&lt;/pre&gt;&lt;br /&gt;&lt;p&gt; Registerint the object. The first parameter is the id what you want to register and the second parameter is the:&lt;/p&gt;&lt;br /&gt;&lt;pre&gt; ...&lt;br /&gt;  &amp;lt;% JSONRPCBridge.registerObject("testService", testService); %&amp;gt;&lt;br /&gt;...&lt;/pre&gt;&lt;br /&gt;&lt;h3&gt; Registering via Servlet&lt;/h3&gt;&lt;br /&gt;&lt;p&gt; Basically is the same thing, except you have to use pure java code:&lt;/p&gt;&lt;br /&gt;&lt;pre&gt;  &lt;br /&gt;   ...&lt;br /&gt;   // Find the JSONRPCBridge for this session or create one&lt;br /&gt;   // if it doesn't exist. Note the bridge must be named "JSONRPCBridge"&lt;br /&gt;   // in the HttpSession for the JSONRPCServlet to find it.&lt;br /&gt;   HttpSession session = request.getSession();&lt;br /&gt;   JSONRPCBridge json_bridge = null;&lt;br /&gt;   json_bridge = (JSONRPCBridge) session.getAttribute("JSONRPCBridge");&lt;br /&gt;   if(json_bridge == null) {&lt;br /&gt;     json_bridge = new JSONRPCBridge();&lt;br /&gt;     session.setAttribute("JSONRPCBridge", json_bridge);&lt;br /&gt;   }&lt;br /&gt;   ...&lt;br /&gt;   json_bridge.registerObject("testService", new test.jsonrpc.TestService() );&lt;br /&gt;   ...&lt;br /&gt;     &lt;/pre&gt;&lt;br /&gt;&lt;p&gt; For this tutorial we are going to use the JSP version for registering java objects.&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;h2&gt;Using your service on JavaScript:&lt;/h2&gt;&lt;br /&gt;&lt;p&gt; Now that you have your service exposed through JSON-RPC is time to use it on a web page. We need to add the following code&lt;br /&gt;&lt;br /&gt; on your web page.&lt;/p&gt;&lt;br /&gt;&lt;pre&gt; &amp;lt;script type="text/javascript" src="jsonrpc.js"&amp;gt;&lt;/pre&gt;&lt;br /&gt;&lt;p&gt; With the JSON-RPC distribution file, there is a javascript file called jsonrpc.js. You need to add it to your web project. In the above code, we are assuming the javascript file is at the same folder than the web page.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt; In order to invoke you service you need a JSON-RPC client on your JavaScript code. You get it creating a new JSONRpcClient.&lt;/p&gt;&lt;br /&gt;&lt;pre&gt; jsonrpc = new JSONRpcClient("JSON-RPC");&lt;/pre&gt;&lt;br /&gt;&lt;p&gt;The following code creates two functions and creates a JSONRpcClient reference when the pages is loading.&lt;/p&gt;&lt;br /&gt;&lt;pre&gt; &amp;lt;script type="text/javascript" &amp;gt;&lt;br /&gt;  function onLoad()&lt;br /&gt;  {&lt;br /&gt;    jsonrpc = new JSONRpcClient("JSON-RPC");&lt;br /&gt;  }&lt;br /&gt; &lt;br /&gt;  function test1()&lt;br /&gt;  {&lt;br /&gt;    var text1 = document.getElementById("text");&lt;br /&gt;    var result = jsonrpc.testService.getHello();&lt;br /&gt;    alert("The server replied: " + result);&lt;br /&gt;    text1.value = result;&lt;br /&gt;  }&lt;br /&gt; &lt;br /&gt;  function test2()&lt;br /&gt;  {&lt;br /&gt;    var text2 = document.getElementById("text2");&lt;br /&gt;    var result = jsonrpc.testService.getRandomValue(5);&lt;br /&gt;    alert("The server replied: " + result);&lt;br /&gt;    text2.value = result;&lt;br /&gt;  }&lt;br /&gt; &lt;br /&gt;&amp;lt;/script&amp;gt;&lt;br /&gt;  &lt;/pre&gt;&lt;br /&gt;&lt;p&gt;When you want to invoke a service method you should use the following sentence:&lt;/p&gt;&lt;br /&gt;&lt;pre&gt;jsonrpc.&amp;lt;registered name&amp;gt;.&amp;lt;methodname&amp;gt;( &amp;lt;parameters if apply&amp;gt; );&lt;/pre&gt;&lt;br /&gt;&lt;p&gt;In our example, the methods test1 and test2 use the jsonrpc&lt;/p&gt;&lt;br /&gt;&lt;pre&gt; var result = jsonrpc.testService.getHello();&lt;br /&gt;var result = jsonrpc.testService.getRandomValue(5);&lt;/pre&gt;&lt;br /&gt;&lt;pre&gt; &lt;/pre&gt;&lt;br /&gt;&lt;p&gt;JSON-RPC is really easy to use for a project:&lt;/p&gt;&lt;br /&gt;&lt;ol&gt;&lt;br /&gt; &lt;li&gt; You just need to add the necesary libraries on your WEB-INF/lib folder&lt;/li&gt;&lt;br /&gt; &lt;li&gt;Configure the JSON-RPC Servlet on web.xml&lt;/li&gt;&lt;br /&gt; &lt;li&gt;Add the jsonrcp.js javascript file &lt;/li&gt;&lt;br /&gt; &lt;li&gt;Register your Service using JSP or Servlet way&lt;/li&gt;&lt;br /&gt; &lt;li&gt;Create a JSONRpcClient on JSP you want to invoke your service&lt;/li&gt;&lt;br /&gt; &lt;li&gt;Use JSONRpcClient reference to invoke it. &lt;/li&gt;&lt;br /&gt;&lt;/ol&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8012835501539055810-444105719901449156?l=fggarcia.blogspot.com' alt='' /&gt;&lt;/div&gt;</description><link>http://feedproxy.google.com/~r/FranklinGarciaTech/~3/hAuKpKVbeaU/how-to-use-json-rpc-for-java.html</link><author>noreply@blogger.com (fr4gus)</author><thr:total>0</thr:total><feedburner:origLink>http://fggarcia.blogspot.com/2007/06/how-to-use-json-rpc-for-java.html</feedburner:origLink></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-8012835501539055810.post-8169005534852800093</guid><pubDate>Mon, 28 May 2007 22:26:00 +0000</pubDate><atom:updated>2007-11-16T16:19:28.553-06:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Java</category><category domain="http://www.blogger.com/atom/ns#">How To</category><category domain="http://www.blogger.com/atom/ns#">Hibernate</category><category domain="http://www.blogger.com/atom/ns#">ORM</category><title>How to use: Hibernate 3</title><description>&lt;h2&gt; What it's Hibernate &lt;/h2&gt;Hibernate is an object/relational mapping tool for Java environments. The term object/relational mapping (ORM) refers to the technique of mapping a data representation from an object model to a relational data model with a SQL-based schema.&lt;br /&gt;&lt;h2&gt; Requirements &lt;/h2&gt;&lt;ul&gt;&lt;li&gt;Download and unpack the Hibernate distribution from the Hibernate website.&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Make sure you have JDK 5.0 installed.&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;h2&gt; Set up your environment &lt;/h2&gt;&lt;p&gt;Set up your classpath:&lt;br /&gt;&lt;/p&gt;&lt;ul&gt;&lt;li&gt;Copy all Hibernate3 core and required 3rd party library files (see lib/README.txt in Hibernate distribution folder).&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;h2&gt; A simple mapping &lt;/h2&gt;&lt;p&gt;Suppose we want to persist the following JavaBean class:&lt;br /&gt;&lt;/p&gt;&lt;pre&gt;package events;&lt;br /&gt;import java.util.Date;&lt;br /&gt;&lt;br /&gt;public class Event {&lt;br /&gt;private Long id;&lt;br /&gt;private String title;&lt;br /&gt;private Date date;&lt;br /&gt;public Event() {}&lt;br /&gt;&lt;br /&gt;public Long getId() {&lt;br /&gt;   return id;&lt;br /&gt;}&lt;br /&gt;private void setId(Long id) {&lt;br /&gt;   this.id = id;&lt;br /&gt;}&lt;br /&gt;public Date getDate() {&lt;br /&gt;   return date;&lt;br /&gt;}&lt;br /&gt;public void setDate(Date date) {&lt;br /&gt;   this.date = date;&lt;br /&gt;}&lt;br /&gt;public String getTitle() {&lt;br /&gt;   return title;&lt;br /&gt;}&lt;br /&gt;public void setTitle(String title) {&lt;br /&gt;   this.title = title;&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;p&gt;The basis structure of a mapping file looks like this:&lt;br /&gt;&lt;/p&gt;&lt;pre&gt;&amp;lt;?xml version="1.0"?&amp;gt;&lt;br /&gt;&amp;lt;!DOCTYPE hibernate-mapping PUBLIC&lt;br /&gt;   "-//Hibernate/Hibernate Mapping DTD 3.0//EN"&lt;br /&gt;   "&lt;a href="http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd" class="external free" title="http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd" rel="nofollow"&gt;http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd&lt;/a&gt;"&amp;gt;&lt;br /&gt;&amp;lt;hibernate-mapping&amp;gt;&lt;br /&gt;&lt;br /&gt;[...]&lt;br /&gt;&amp;lt;/hibernate-mapping&amp;gt;&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;Between the two hibernate-mapping tags, include a class element:&lt;br /&gt;&lt;pre&gt;&amp;lt;hibernate-mapping&amp;gt;&lt;br /&gt;&amp;lt;class name="events.Event" table="EVENTS"&amp;gt;&lt;br /&gt;  ...&lt;br /&gt;&amp;lt;/class&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;/hibernate-mapping&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;p&gt;Now, we must map the primary key and the rest of the properties (this will be event.hbm.xml file):&lt;br /&gt;&lt;/p&gt;&lt;pre&gt;&amp;lt;hibernate-mapping&amp;gt;&lt;br /&gt;&amp;lt;class name="events.Event" table="EVENTS"&amp;gt;&lt;br /&gt;    &amp;lt;id name="id" column="EVENT_ID"&amp;gt;&lt;br /&gt;        &amp;lt;generator class="identity"/&amp;gt;&lt;br /&gt;    &amp;lt;/id&amp;gt;&lt;br /&gt;&lt;br /&gt;    &amp;lt;property name="date" type="timestamp" column="EVENT_DATE"/&amp;gt;&lt;br /&gt;    &amp;lt;property name="title" type="string" column="TITLE"/&amp;gt;&lt;br /&gt;&amp;lt;/class&amp;gt;&lt;br /&gt;&amp;lt;/hibernate-mapping&amp;gt;&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;&lt;p&gt;With the &lt;tt&gt;&amp;lt;id&amp;gt;&lt;/tt&gt;tag, you map the object property with the table primary key. The &lt;tt&gt;&amp;lt;generator&amp;gt;&lt;/tt&gt; tag, define the generation strategy for that primary key and must match with the defined in the table.  The generator class can be: identity, sequence, assigned as the common choices. For other generator class please refer to the &lt;a href="http://www.hibernate.org/hib_docs/v3/reference/en/html/mapping.html#mapping-declaration-id-generator" class="external text" title="http://www.hibernate.org/hib_docs/v3/reference/en/html/mapping.html#mapping-declaration-id-generator" rel="nofollow"&gt;hibernate documentation&lt;/a&gt;.&lt;br /&gt;&lt;/p&gt;&lt;p&gt;The &lt;tt&gt;&amp;lt;property&amp;gt;&lt;/tt&gt; tag define the rest of columns mapped with the respectively object attribute.&lt;br /&gt;&lt;/p&gt;&lt;p&gt;When a key is composite, we must use the &lt;tt&gt;&amp;lt;composite-id&amp;gt;&lt;/tt&gt; tag as the following example, where a person in an event can have a position in a room:&lt;br /&gt;&lt;/p&gt;&lt;pre&gt;package events;&lt;br /&gt;&lt;br /&gt;public class SeatPosition {&lt;br /&gt;private SeatPositionPK id;&lt;br /&gt;// properties&lt;br /&gt;private int color;&lt;br /&gt;// Accessor methods for all properties, private setter for 'id'&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;&lt;p&gt;The definition of the primary key class:&lt;br /&gt;&lt;/p&gt;&lt;pre&gt;package events;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;public class SeatPositionPK {&lt;br /&gt;// composite key properties&lt;br /&gt;private int room;&lt;br /&gt;private int seat;&lt;br /&gt;&lt;br /&gt;// Accessor methods for all properties&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;p&gt;The mapping file will looks like:&lt;br /&gt;&lt;/p&gt;&lt;pre&gt;&amp;lt;hibernate-mapping&amp;gt;&lt;br /&gt;&amp;lt;class name="events.SeatPosition" table="SEAT_POSITION"&amp;gt;&lt;br /&gt;    &amp;lt;composite-id name="id" type="events.SeatPositionPK" column="id"&amp;gt;&lt;br /&gt;        &amp;lt;key-property name="room" column="ROOM" type="integer"/&amp;gt;&lt;br /&gt;&lt;br /&gt;        &amp;lt;key-property name="seat" column="SEAT" type="integer"/&amp;gt;&lt;br /&gt;    &amp;lt;/composite-id&amp;gt;&lt;br /&gt;    &amp;lt;property name="color" type="integer"/&amp;gt;&lt;br /&gt;&amp;lt;/class&amp;gt;&lt;br /&gt;&amp;lt;/hibernate-mapping&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;h2&gt; Maping Associations &lt;/h2&gt;&lt;p&gt;A database will have more than "simple" tables and you will need map different kinds of relationship between tables.&lt;br /&gt;&lt;/p&gt;&lt;h3&gt; Many-To-Many &lt;/h3&gt;&lt;p&gt;Given the following class definition&lt;br /&gt;&lt;/p&gt;&lt;pre&gt;package events;&lt;br /&gt;&lt;br /&gt;public class Person {&lt;br /&gt;private Long id;&lt;br /&gt;private int age;&lt;br /&gt;private String firstname;&lt;br /&gt;private String lastname;&lt;br /&gt;&lt;br /&gt;public Person() {}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;// Accessor methods for all properties, private setter for 'id'&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;p&gt;And the following given mapping file (for person, Person.hbm.xml):&lt;br /&gt;&lt;/p&gt;&lt;pre&gt;&amp;lt;hibernate-mapping&amp;gt;&lt;br /&gt;&amp;lt;class name="events.Person" table="PERSON"&amp;gt;&lt;br /&gt;    &amp;lt;id name="id" column="PERSON_ID"&amp;gt;&lt;br /&gt;        &amp;lt;generator class="identity"/&amp;gt;&lt;br /&gt;    &amp;lt;/id&amp;gt;&lt;br /&gt;&lt;br /&gt;    &amp;lt;property name="age"/&amp;gt;&lt;br /&gt;    &amp;lt;property name="firstname"/&amp;gt;&lt;br /&gt;    &amp;lt;property name="lastname"/&amp;gt;&lt;br /&gt;&amp;lt;/class&amp;gt;&lt;br /&gt;&amp;lt;/hibernate-mapping&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;p&gt;Suppose that a person can participate in one or more events, so we must add a collection that contains Event objects in a Person instance.&lt;br /&gt;&lt;/p&gt;&lt;pre&gt;public class Person {&lt;br /&gt;// Properties definition&lt;br /&gt;...&lt;br /&gt;&lt;br /&gt;private Set events = new HashSet();&lt;br /&gt;&lt;br /&gt;public Set getEvents() {&lt;br /&gt;    return events;&lt;br /&gt;}&lt;br /&gt;public void setEvents(Set events) {&lt;br /&gt;    this.events = events;&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;p&gt;And the mapping file change like this:&lt;br /&gt;&lt;/p&gt;&lt;pre&gt;&amp;lt;hibernate-mapping&amp;gt;&lt;br /&gt;&amp;lt;class name="events.Person" table="PERSON"&amp;gt;&lt;br /&gt;    &amp;lt;id name="id" column="PERSON_ID"&amp;gt;&lt;br /&gt;&lt;br /&gt;        &amp;lt;generator class="identity"/&amp;gt;&lt;br /&gt;    &amp;lt;/id&amp;gt;&lt;br /&gt;    &amp;lt;property name="age"/&amp;gt;&lt;br /&gt;    &amp;lt;property name="firstname"/&amp;gt;&lt;br /&gt;    &amp;lt;property name="lastname"/&amp;gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;&amp;lt;set name="events" table="PERSON_EVENT"&amp;gt;&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;    &lt;b&gt;&amp;lt;key column="PERSON_ID"/&amp;gt;&lt;/b&gt;&lt;br /&gt;    &lt;b&gt;&amp;lt;many-to-many column="EVENT_ID" class="events.Event"/&amp;gt;&lt;/b&gt;&lt;br /&gt;&lt;b&gt;&amp;lt;/set&amp;gt;&lt;/b&gt;&lt;br /&gt;&amp;lt;/class&amp;gt;&lt;br /&gt;&amp;lt;/hibernate-mapping&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;p&gt;We have mapped the database schema:&lt;br /&gt;&lt;/p&gt;&lt;pre&gt;    _____________        __________________&lt;br /&gt;|             |      |                  |       _____________&lt;br /&gt;|   EVENTS    |      |   PERSON_EVENT   |      |             |&lt;br /&gt;|_____________|      |__________________|      |    PERSON   |&lt;br /&gt;|             |      |                  |      |_____________|&lt;br /&gt;| *EVENT_ID   | &amp;lt;--&amp;gt; | *EVENT_ID        |      |             |&lt;br /&gt;|  EVENT_DATE |      | *PERSON_ID       | &amp;lt;--&amp;gt; | *PERSON_ID  |&lt;br /&gt;|  TITLE      |      |__________________|      |  AGE        |&lt;br /&gt;|_____________|                                |  FIRSTNAME  |&lt;br /&gt;                                              |  LASTNAME   |&lt;br /&gt;                                              |_____________|&lt;br /&gt;&lt;/pre&gt;&lt;p&gt;If you want to do a bidirectional relationship, where from a event you can get the event participants. First, add a collection of participants to the Event Event class:&lt;br /&gt;&lt;/p&gt;&lt;pre&gt;private Set&amp;lt;Person&amp;gt; participants = new HashSet&amp;lt;Person&amp;gt;();&lt;br /&gt;public Set&amp;lt;Person&amp;gt; getParticipants() {&lt;br /&gt;return participants;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;public void setParticipants(Set&amp;lt;Person&amp;gt; participants) {&lt;br /&gt;this.participants = participants;&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;p&gt;Now map this side of the association too, in Event.hbm.xml.&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;pre&gt;&amp;lt;set name="participants" table="PERSON_EVENT" inverse="true"&amp;gt;&lt;br /&gt;&amp;lt;key column="EVENT_ID"/&amp;gt;&lt;br /&gt;&amp;lt;many-to-many column="PERSON_ID" class="events.Person"/&amp;gt;&lt;br /&gt;&amp;lt;/set&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;h3&gt; One-To-Many &lt;/h3&gt;&lt;p&gt;If a person can have one or more email addresses:&lt;br /&gt;&lt;/p&gt;&lt;pre&gt;private Set&amp;lt;String&amp;gt; emailAddresses = new HashSet();&lt;br /&gt;public Set&amp;lt;String&amp;gt; getEmailAddresses() {&lt;br /&gt;return emailAddresses;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;public void setEmailAddresses(Set&amp;lt;String&amp;gt; emailAddresses) {&lt;br /&gt;this.emailAddresses = emailAddresses;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;&lt;p&gt;The mapping of this Set:&lt;br /&gt;&lt;/p&gt;&lt;pre&gt;&amp;lt;set name="emailAddresses" table="PERSON_EMAIL"&amp;gt;&lt;br /&gt;&amp;lt;key column="PERSON_ID"/&amp;gt;&lt;br /&gt;&amp;lt;element type="string" column="EMAIL_ADDR"/&amp;gt;&lt;br /&gt;&amp;lt;/set&amp;gt;&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;&lt;p&gt;Look at the updated schema:&lt;br /&gt;&lt;/p&gt;&lt;pre&gt;  _____________        __________________&lt;br /&gt;|             |      |                  |       _____________&lt;br /&gt;|   EVENTS    |      |   PERSON_EVENT   |      |             |       ______________&lt;br /&gt;|_____________|      |__________________|      |    PERSON   |      |              |&lt;br /&gt;|             |      |                  |      |_____________|      | PERSON_EMAIL |&lt;br /&gt;| *EVENT_ID   | &amp;lt;--&amp;gt; | *EVENT_ID        |      |             |      |______________|&lt;br /&gt;|  EVENT_DATE |      | *PERSON_ID       | &amp;lt;--&amp;gt; | *PERSON_ID  | &amp;lt;--&amp;gt; |  *PERSON_ID  |&lt;br /&gt;|  TITLE      |      |__________________|      |  AGE        |      |  *EMAIL_ADDR |&lt;br /&gt;|_____________|                                |  FIRSTNAME  |      |______________|&lt;br /&gt;                                            |  LASTNAME   |&lt;br /&gt;                                            |_____________|&lt;br /&gt;&lt;/pre&gt;&lt;h3&gt; One-To-One &lt;/h3&gt;&lt;p&gt;Suppose you want to know who the owner of a specific vehicle is:&lt;br /&gt;&lt;/p&gt;&lt;pre&gt;public class Vehicle {&lt;br /&gt;private String id;&lt;br /&gt;private String model;&lt;br /&gt;private String brand;&lt;br /&gt;private int year;&lt;br /&gt;private Person owner;&lt;br /&gt;&lt;br /&gt;public Vehicle(){}&lt;br /&gt;// Accessor methods for all properties, private setter for 'id'&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;p&gt;The mapping file (Vehicle.hbm.xml) will be like:&lt;br /&gt;&lt;/p&gt;&lt;pre&gt;&amp;lt;hibernate-mapping&amp;gt;&lt;br /&gt;&amp;lt;class name="events.Vehicle" table="VEHICLE"&amp;gt;&lt;br /&gt;    &amp;lt;id name="id" column="VEHICLE_ID"&amp;gt;&lt;br /&gt;&lt;br /&gt;        &amp;lt;generator class="identity"/&amp;gt;&lt;br /&gt;    &amp;lt;/id&amp;gt;&lt;br /&gt;    &amp;lt;property name="brand"/&amp;gt;&lt;br /&gt;    &amp;lt;property name="year"/&amp;gt;&lt;br /&gt;    &amp;lt;property name="model"/&amp;gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;&amp;lt;one-to-one name="owner" class="Person" constrained="true"/&amp;gt;&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;/class&amp;gt;&lt;br /&gt;&amp;lt;/hibernate-mapping&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;h2&gt; Configuring Hibernate &lt;/h2&gt;&lt;p&gt;After known how to map JavaBeans with database tables its time to make this mapping works. First than all, we must specify how Hibernate will connect to the database. The principal configuration file is hibernate.cfg.xml, and this is an example:&lt;br /&gt;&lt;/p&gt;&lt;pre&gt;&amp;lt;?xml version='1.0' encoding='utf-8'?&amp;gt;&lt;br /&gt;&amp;lt;!DOCTYPE hibernate-configuration PUBLIC&lt;br /&gt;    "-//Hibernate/Hibernate Configuration DTD 3.0//EN"&lt;br /&gt;    "&lt;a href="http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd" class="external free" title="http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd" rel="nofollow"&gt;http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd&lt;/a&gt;"&amp;gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;hibernate-configuration&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;session-factory&amp;gt;&lt;br /&gt;&lt;br /&gt;    &amp;lt;property name="connection.driver_class"&amp;gt;org.hsqldb.jdbcDriver&amp;lt;/property&amp;gt;&lt;br /&gt;    &amp;lt;property name="connection.url"&amp;gt;jdbc:hsqldb:hsql://localhost&amp;lt;/property&amp;gt;&lt;br /&gt;    &amp;lt;property name="connection.username"&amp;gt;sa&amp;lt;/property&amp;gt;&lt;br /&gt;&lt;br /&gt;    &amp;lt;property name="connection.password"&amp;gt;&amp;lt;/property&amp;gt;&lt;br /&gt;&lt;br /&gt;    &amp;lt;property name="connection.pool_size"&amp;gt;1&amp;lt;/property&amp;gt;&lt;br /&gt;&lt;br /&gt;    &amp;lt;property name="dialect"&amp;gt;org.hibernate.dialect.HSQLDialect&amp;lt;/property&amp;gt;&lt;br /&gt;&lt;br /&gt;    &amp;lt;property name="current_session_context_class"&amp;gt;thread&amp;lt;/property&amp;gt;&lt;br /&gt;&lt;br /&gt;    &amp;lt;property name="cache.provider_class"&amp;gt;org.hibernate.cache.NoCacheProvider&amp;lt;/property&amp;gt;&lt;br /&gt;&lt;br /&gt;    &amp;lt;property name="show_sql"&amp;gt;true&amp;lt;/property&amp;gt;&lt;br /&gt;&lt;br /&gt;    &amp;lt;property name="hbm2ddl.auto"&amp;gt;create&amp;lt;/property&amp;gt;&lt;br /&gt;&lt;br /&gt;    &amp;lt;mapping resource="events/Event.hbm.xml"/&amp;gt;&lt;br /&gt;    &amp;lt;mapping resource="events/Person.hbm.xml"/&amp;gt;&lt;br /&gt;    &amp;lt;mapping resource="events/SeatPosition.hbm.xml"/&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;/session-factory&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;/hibernate-configuration&amp;gt;&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;&lt;p&gt;It's time to load and store some objects, but first we have to complete the setup with some infrastructure code. We have to startup Hibernate. This startup includes building a global SessionFactory object and to store it somewhere for easy access in application code. A SessionFactory can open up new Session's. A Session represents a single-threaded unit of work, the SessionFactory is a thread-safe global object, instantiated once.&lt;br /&gt;&lt;/p&gt;&lt;p&gt;We'll create a HibernateUtil helper class which takes care of startup and makes accessing a SessionFactory convenient. Let's have a look at the implementation:&lt;br /&gt;&lt;/p&gt;&lt;pre&gt;package util;&lt;br /&gt;import org.hibernate.*;&lt;br /&gt;import org.hibernate.cfg.*;&lt;br /&gt;&lt;br /&gt;public class HibernateUtil {&lt;br /&gt;&lt;br /&gt;private static final SessionFactory sessionFactory;&lt;br /&gt;&lt;br /&gt;static {&lt;br /&gt;    try {&lt;br /&gt;        // Create the SessionFactory from hibernate.cfg.xml&lt;br /&gt;        sessionFactory = new Configuration().configure().buildSessionFactory();&lt;br /&gt;    } catch (Throwable ex) {&lt;br /&gt;        // Make sure you log the exception, as it might be swallowed&lt;br /&gt;        System.err.println("Initial SessionFactory creation failed." + ex);&lt;br /&gt;        throw new ExceptionInInitializerError(ex);&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;public static SessionFactory getSessionFactory() {&lt;br /&gt;    return sessionFactory;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;The hibernate configuration file (hibernate.cfg.xml) must be in the root of the application classpath. Every mapping file must be with its respective class. This is an example of application structure for the whole example that we have been working on:&lt;br /&gt;&lt;pre&gt;+ lib&lt;br /&gt;&amp;lt;Hibernate and third-party libraries&amp;gt;&lt;br /&gt;&lt;br /&gt;+scr&lt;br /&gt;hibernate.cfg.xml&lt;br /&gt;+events&lt;br /&gt;      Event.java&lt;br /&gt;      Event.hbm.xml&lt;br /&gt;      Person.java&lt;br /&gt;      Person.hbm.xml&lt;br /&gt;      SeatPosition.java&lt;br /&gt;+classes    // it’s a copy of src, but with binary files (except xml of course)&lt;br /&gt;hibernate.cfg.xml&lt;br /&gt;+events&lt;br /&gt;      Event.class&lt;br /&gt;      Event.hbm.xml&lt;br /&gt;      Person.class&lt;br /&gt;      Person.hbm.xml&lt;br /&gt;      SeatPosition.class&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;h2&gt; Loanding and storing object &lt;/h2&gt;&lt;p&gt;Now, the following example show how to use the session object. Remember that on N-Layer Application the persistence layer will use the services of sessionFactory and session objects.&lt;br /&gt;&lt;/p&gt;&lt;pre&gt;package events;&lt;br /&gt;import org.hibernate.Session;&lt;br /&gt;&lt;br /&gt;import java.util.Date;&lt;br /&gt;import util.HibernateUtil;&lt;br /&gt;&lt;br /&gt;public class EventManager {&lt;br /&gt;&lt;br /&gt;public static void main(String[] args) {&lt;br /&gt;    EventManager mgr = new EventManager();&lt;br /&gt;&lt;br /&gt;    if (args[0].equals("store")) {&lt;br /&gt;        mgr.createAndStoreEvent("My Event", new Date());&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    HibernateUtil.getSessionFactory().close();&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;private void createAndStoreEvent(String title, Date theDate) {&lt;br /&gt;    Session session = HibernateUtil.getSessionFactory().getCurrentSession();          &lt;br /&gt;    session.beginTransaction();&lt;br /&gt;&lt;br /&gt;    Event theEvent = new Event();&lt;br /&gt;    theEvent.setTitle(title);&lt;br /&gt;    theEvent.setDate(theDate);&lt;br /&gt;&lt;br /&gt;    session.save(theEvent);&lt;br /&gt;&lt;br /&gt;    session.getTransaction().commit();&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;h2&gt; Querying &lt;/h2&gt;&lt;p&gt;Another important functionality that hibernate provide, beside persist objects, it’s the querying capabilities. Hibernate provide a cross-platform language, very similar than SQL named Hibernate Query Language (HQL). For programmatic query creation, Hibernate supports a sophisticated Criteria and Example query feature (QBC and QBE). You may also express your query in the native SQL of your database, with optional support from Hibernate for result set conversion into objects.&lt;br /&gt;&lt;/p&gt;&lt;h3&gt; Executing Queries &lt;/h3&gt;&lt;p&gt;HQL and native SQL queries are represented with an instance of org.hibernate.Query. This interface offers methods for parameter binding, result set handling, and for the execution of the actual query. You always obtain a Query using the current Session:&lt;br /&gt;&lt;/p&gt;&lt;pre&gt;List cats = session.createQuery(&lt;br /&gt;"from Cat as cat where cat.birthdate &amp;lt; ?")&lt;br /&gt;.setDate(0, date)&lt;br /&gt;.list();&lt;br /&gt;&lt;br /&gt;List mothers = session.createQuery(&lt;br /&gt;"select mother from Cat as cat join cat.mother as mother where cat.name = ?")&lt;br /&gt;.setString(0, name)&lt;br /&gt;.list();&lt;br /&gt;&lt;br /&gt;List kittens = session.createQuery(&lt;br /&gt;"from Cat as cat where cat.mother = ?")&lt;br /&gt;.setEntity(0, pk)&lt;br /&gt;.list();&lt;br /&gt;&lt;br /&gt;Cat mother = (Cat) session.createQuery(&lt;br /&gt;"select cat.mother from Cat as cat where cat = ?")&lt;br /&gt;.setEntity(0, izi)&lt;br /&gt;.uniqueResult();]]&lt;br /&gt;&lt;br /&gt;Query mothersWithKittens = (Cat) session.createQuery(&lt;br /&gt;"select mother from Cat as mother left join fetch&lt;br /&gt;other.kittens");&lt;br /&gt;Set uniqueMothers = new HashSet(mothersWithKittens.list());&lt;br /&gt;&lt;/pre&gt;&lt;h3&gt; Bind Parameters &lt;/h3&gt;&lt;p&gt;Methods on Query are provided for binding values to named parameters or JDBC-style ? parameters. Contrary to JDBC, Hibernate numbers parameters from zero.  Named parameters are identifiers of the form :name in the query string. The advantages of named parameters are:&lt;br /&gt;&lt;/p&gt;&lt;ul&gt;&lt;li&gt;named parameters are insensitive to the order they occur in the query string&lt;br /&gt;&lt;/li&gt;&lt;li&gt;they may occur multiple times in the same query&lt;br /&gt;&lt;/li&gt;&lt;li&gt;they are self-documenting&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;pre&gt;//named parameter (preferred)&lt;br /&gt;Query q = sess.createQuery("from DomesticCat cat where cat.name = :name");&lt;br /&gt;q.setString("name", "Fritz");&lt;br /&gt;Iterator cats = q.iterate();&lt;br /&gt;&lt;br /&gt;//positional parameter&lt;br /&gt;Query q = sess.createQuery("from DomesticCat cat where cat.name = ?");&lt;br /&gt;q.setString(0, "Izi");&lt;br /&gt;Iterator cats = q.iterate();&lt;br /&gt;&lt;br /&gt;//named parameter list&lt;br /&gt;List names = new ArrayList();&lt;br /&gt;names.add("Izi");&lt;br /&gt;names.add("Fritz");&lt;br /&gt;Query q = sess.createQuery("from DomesticCat cat where cat.name in (:namesList)");&lt;br /&gt;q.setParameterList("namesList", names);&lt;br /&gt;List cats = q.list();&lt;br /&gt;&lt;/pre&gt;&lt;h2&gt; Summary &lt;/h2&gt;&lt;ul&gt;&lt;li&gt;Hibenate it’s a object/relational mapping tool, for object persisting and querying.&lt;br /&gt;&lt;/li&gt;&lt;li&gt;The mapping from an object to a table is defined in a xml file, usually one file per class.&lt;br /&gt;&lt;/li&gt;&lt;li&gt;The hibernate configuration is keeped in hibernate.cfg.xml file.&lt;br /&gt;&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;tt&gt;&amp;lt;class&amp;gt;&lt;/tt&gt; tag defines which object will map an table.&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;tt&gt;&amp;lt;id&amp;gt;&lt;/tt&gt; tag defines which object property will map the table primary-key.&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;tt&gt;&amp;lt;property&amp;gt;&lt;/tt&gt; tag defines all non-primary-key attributes of the object.&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;tt&gt;&amp;lt;composite-id&amp;gt;&lt;/tt&gt; is used, when the table that will be mapped, have a composite primary key. To use this tag, you must define a helper class that wraps all the attributes that compound the primary key.&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;tt&gt;&amp;lt;many-to-many&amp;gt;&lt;/tt&gt; tag defines a collection that will hold the 1-n relationship from one direction in a N-M relationship between tables. For a bidirectional link, you must define a many-to-many tag in the other class.&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;tt&gt;&amp;lt;one-to-many&amp;gt;&lt;/tt&gt; tag defines a collections that will hold the 1-n relationship between two tables.&lt;br /&gt;&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;tt&gt;&amp;lt;one-to-one&amp;gt;&lt;/tt&gt; tag defines a object that will hold the link for a 1-1 relationship between two tables.&lt;br /&gt;&lt;/li&gt;&lt;li&gt;For specific queries, you can use the createQuery service from session object, and obtain an org.hibernate.Query object. Its recommended use the HQL, but its possible use native SQL.&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;h2&gt; External Links &lt;/h2&gt;&lt;p&gt;Parts of this HOW-TO had been extracted from: &lt;a href="http://www.hibernate.org/hib_docs/v3/reference/en/html/index.html" class="external free" title="http://www.hibernate.org/hib_docs/v3/reference/en/html/index.html" rel="nofollow"&gt;http://www.hibernate.org/hib_docs/v3/reference/en/html/index.html&lt;/a&gt;&lt;br /&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8012835501539055810-8169005534852800093?l=fggarcia.blogspot.com' alt='' /&gt;&lt;/div&gt;</description><link>http://feedproxy.google.com/~r/FranklinGarciaTech/~3/lMql7qtlaps/how-to-use-hibernate-3.html</link><author>noreply@blogger.com (fr4gus)</author><thr:total>0</thr:total><feedburner:origLink>http://fggarcia.blogspot.com/2007/05/how-to-use-hibernate-3.html</feedburner:origLink></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-8012835501539055810.post-4803667916030330679</guid><pubDate>Tue, 15 May 2007 15:30:00 +0000</pubDate><atom:updated>2008-05-08T20:01:13.918-06:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Java</category><category domain="http://www.blogger.com/atom/ns#">Hibernate</category><category domain="http://www.blogger.com/atom/ns#">XDoclet</category><category domain="http://www.blogger.com/atom/ns#">ORM</category><title>Hibernate composite keys with XDoclet</title><description>&lt;div&gt;The XDoclet documentation is not cleaver about composite keys. It only shows which annotation must be used (composite-id), but doesn't show where the "key-property" annotation must be placed. After several test I could realize that you should put the key-property in the class that will be used as composite key.&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;/**&lt;br /&gt;* @hibernate.class table="parent"&lt;br /&gt;*/&lt;br /&gt;public class Parent{&lt;br /&gt;private ParentId id;&lt;br /&gt;private String name;&lt;br /&gt;public void setId(Parent Id){..}&lt;br /&gt;/**&lt;br /&gt;* @hiberante.composite-id&lt;br /&gt;*/&lt;br /&gt;public ParentId getId(){...}&lt;br /&gt;public void setName(String name){...}&lt;br /&gt;/**&lt;br /&gt;* @hibernate.property column="name" type="string"&lt;br /&gt;*/&lt;br /&gt;public String getName(){...}&lt;br /&gt;}&lt;br /&gt;public class ParentId{&lt;br /&gt;private Integer personId;&lt;br /&gt;private Integer code;&lt;br /&gt;public void setPersonId(Integer p){...}&lt;br /&gt;/**&lt;br /&gt;* @hibernate.key-property column="person_id" type="integer"&lt;br /&gt;*/&lt;br /&gt;public Integer getPersonId(){...}&lt;br /&gt;public void setCode(Integer c){...}&lt;br /&gt;/**&lt;br /&gt;* @hibernate.key-property column="code" type="integer"&lt;br /&gt;*/&lt;br /&gt;public Integer getCode(){...}&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8012835501539055810-4803667916030330679?l=fggarcia.blogspot.com' alt='' /&gt;&lt;/div&gt;</description><link>http://feedproxy.google.com/~r/FranklinGarciaTech/~3/KutWi4TDCa8/hibernate-composite-keys-with-xdoclet.html</link><author>noreply@blogger.com (fr4gus)</author><thr:total>7</thr:total><feedburner:origLink>http://fggarcia.blogspot.com/2007/05/hibernate-composite-keys-with-xdoclet.html</feedburner:origLink></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-8012835501539055810.post-5607986584527025016</guid><pubDate>Tue, 08 May 2007 19:51:00 +0000</pubDate><atom:updated>2007-05-15T09:26:32.826-06:00</atom:updated><title>A second blog?</title><description>Yes, I know, could be a little weird to have two blogs, but, I have two identities, one here... in the real world, the other one in the cyber world.&lt;br /&gt;&lt;br /&gt;I just want to share my experiences developing (right now in Java) software, what obstacles I found and how I solved them. Post relevant information about PC's and general development.&lt;br /&gt;&lt;br /&gt;I'll "migrate" some posts that I have in my Windows Live Blog (Live Spaces), to start sharing :).&lt;br /&gt;&lt;br /&gt;If you want to see my "dark" side (when you get the another blog you will understand) just click &lt;a href="http://fr4gus.blogspot.com/"&gt;here&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;Franklin Garcia&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8012835501539055810-5607986584527025016?l=fggarcia.blogspot.com' alt='' /&gt;&lt;/div&gt;</description><link>http://feedproxy.google.com/~r/FranklinGarciaTech/~3/OrcB3ipElgM/second-blog.html</link><author>noreply@blogger.com (fr4gus)</author><thr:total>1</thr:total><feedburner:origLink>http://fggarcia.blogspot.com/2007/05/second-blog.html</feedburner:origLink></item></channel></rss>

