<?xml version="1.0"?><rss version="2.0">
<channel>
  <title>Java Beans dot Asia - hibernate category</title>
  <link>http://javabeans.asia/categories/hibernate/</link>
  <description>Just a few simple tutorials</description>
  <language>en</language>
  <copyright>Alexander Zagniotov</copyright>
  <lastBuildDate>Tue, 23 Feb 2010 11:04:00 GMT</lastBuildDate>
  <generator>Pebble (http://pebble.sourceforge.net)</generator>
  <docs>http://backend.userland.com/rss</docs>
  <image>
    <url>/images/blog-image.jpg</url>
    <title>Java Beans dot Asia (hibernate category)</title>
    <link>http://javabeans.asia/</link>
  </image>
  <item>
    <title>Hibernate Event Interceptor</title>
    <link>http://javabeans.asia/2009/03/08/hibernate_event_interceptor.html</link>
	 <description>
        Its quite common when you create an application, there is a need to create an audit trail on the application level where all entity insert, update and delete events are logged. &lt;br /&gt;
&lt;br /&gt;
In this post, I would like to describe a simple approach that can help you to avoid littering with unnecessary statements in your application code. The solution is to register a class as a listener on Hibernate events. Once class is triggered, you will be able to write audit information to a database or log file.&lt;br /&gt;
&lt;br /&gt;
The following shows a Hibernate event interceptor class that is triggered when persistent entity is inserted, deleted or updated.
&lt;pre class=&#034;java:firstline[1]&#034; name=&#034;code&#034;&gt;public class HibernateEventInterceptor&lt;br /&gt;	implements	&lt;br /&gt;	        PostInsertEventListener, &lt;br /&gt;		PostUpdateEventListener,&lt;br /&gt;		PostDeleteEventListener, &lt;br /&gt;				Initializable {&lt;br /&gt;&lt;br /&gt;  public HibernateEventInterceptor() {&lt;br /&gt;		&lt;br /&gt;  }&lt;br /&gt;&lt;br /&gt;  public void initialize(Configuration cfg) {&lt;br /&gt;&lt;br /&gt;  }&lt;br /&gt;	&lt;br /&gt;  public void onPostInsert(PostInsertEvent event) {&lt;br /&gt;   String entityName = event.getPersister().&lt;br /&gt;                                   getEntityName();&lt;br /&gt;   System.out.println(&amp;quot;Inserted entity: &amp;quot; + entityName);&lt;br /&gt;  }&lt;br /&gt;&lt;br /&gt;  public void onPostUpdate(PostUpdateEvent event) {&lt;br /&gt;   String entityName = event.getPersister().&lt;br /&gt;                                   getEntityName();&lt;br /&gt;   System.out.println(&amp;quot;Updated entity: &amp;quot; + entityName);&lt;br /&gt;  }&lt;br /&gt;&lt;br /&gt;  public void onPostDelete(PostDeleteEvent event) {&lt;br /&gt;    String entityName = event.getPersister().&lt;br /&gt;                                    getEntityName();&lt;br /&gt;    System.out.println(&amp;quot;Deleted entity: &amp;quot; + entityName);&lt;br /&gt;  }&lt;br /&gt;}&lt;/pre&gt;
The following shows extra configuration that must be added to &lt;em&gt;persistence.xml&lt;/em&gt;, in order for the interceptor class to be triggered:
&lt;pre class=&#034;xml:firstline[1]&#034; name=&#034;code&#034;&gt;&amp;lt;persistence&amp;gt;&lt;br /&gt;  &amp;lt;persistence-unit name=&amp;quot;org.example.demo&amp;quot;&amp;gt;&lt;br /&gt;    &amp;lt;jta-data-source&amp;gt;java:/test&amp;lt;/jta-data-source&amp;gt;&lt;br /&gt;      &amp;lt;properties&amp;gt;&lt;br /&gt;	.&lt;br /&gt;	.&lt;br /&gt;	.&lt;br /&gt;	.&lt;br /&gt;	&amp;lt;property name=&amp;quot;hibernate.ejb.event.post-insert&amp;quot;&lt;br /&gt;	value=&amp;quot;org.example.demo.HibernateEventInterceptor&amp;quot;/&amp;gt;&lt;br /&gt;		&lt;br /&gt;	&amp;lt;property name=&amp;quot;hibernate.ejb.event.post-update&amp;quot;&lt;br /&gt;	value=&amp;quot;org.example.demo.HibernateEventInterceptor&amp;quot;/&amp;gt;&lt;br /&gt;		&lt;br /&gt;	&amp;lt;property name=&amp;quot;hibernate.ejb.event.post-delete&amp;quot;&lt;br /&gt;	value=&amp;quot;org.example.demo.HibernateEventInterceptor&amp;quot;/&amp;gt;&lt;br /&gt;			&lt;br /&gt;    &amp;lt;/properties&amp;gt;&lt;br /&gt;  &amp;lt;/persistence-unit&amp;gt;&lt;br /&gt; &amp;lt;/persistence&amp;gt;&lt;/pre&gt;&lt;div class=&#034;tags&#034;&gt;&lt;span&gt;Social Bookmarks : &lt;/span&gt;&amp;nbsp;&lt;a href=&#034;http://slashdot.org/bookmark.pl?url=http://javabeans.asia/2009/03/08/hibernate_event_interceptor.html&amp;amp;title=Hibernate Event Interceptor&#034; target=&#034;_blank&#034; title=&#034;Add this post to Slash Dot&#034;&gt;&lt;img src=&#034;common/images/slashdot.png&#034; alt=&#034;Add this post to Slashdot&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://digg.com/submit?url=http://javabeans.asia/2009/03/08/hibernate_event_interceptor.html&amp;amp;title=Hibernate Event Interceptor&#034; target=&#034;_blank&#034; title=&#034;Digg this post&#034;&gt;&lt;img src=&#034;common/images/digg.png&#034; alt=&#034;Add this post to Digg&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://reddit.com/submit?url=http://javabeans.asia/2009/03/08/hibernate_event_interceptor.html&amp;amp;title=Hibernate Event Interceptor&#034; target=&#034;_blank&#034; title=&#034;Add this post to Reddit&#034;&gt;&lt;img src=&#034;common/images/reddit.png&#034; alt=&#034;Add this post to Reddit&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://del.icio.us/post?url=http://javabeans.asia/2009/03/08/hibernate_event_interceptor.html&amp;amp;title=Hibernate Event Interceptor&#034; target=&#034;_blank&#034; title=&#034;Save this post to Del.icio.us&#034;&gt;&lt;img src=&#034;common/images/delicious.png&#034; alt=&#034;Add this post to Delicious&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://www.stumbleupon.com/submit?url=http://javabeans.asia/2009/03/08/hibernate_event_interceptor.html&amp;amp;title=Hibernate Event Interceptor&#034; target=&#034;_blank&#034; title=&#034;Stumble this post&#034;&gt;&lt;img src=&#034;common/images/stumbleupon.png&#034; alt=&#034;Add this post to Stumble it&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://www.google.com/bookmarks/mark?op=edit&amp;amp;bkmk=http://javabeans.asia/2009/03/08/hibernate_event_interceptor.html&amp;amp;title=Hibernate Event Interceptor&#034; target=&#034;_blank&#034; title=&#034;Add this post to Google&#034;&gt;&lt;img src=&#034;common/images/google.png&#034; alt=&#034;Add this post to Google&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://technorati.com/faves?add=http://javabeans.asia/2009/03/08/hibernate_event_interceptor.html&#034; target=&#034;_blank&#034; title=&#034;Add this post to Technorati&#034;&gt;&lt;img src=&#034;common/images/technorati.png&#034; alt=&#034;Add this post to Technorati&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://www.bloglines.com/sub/http://javabeans.asia/2009/03/08/hibernate_event_interceptor.html&#034; target=&#034;_blank&#034; title=&#034;Add this post to Bloglines&#034;&gt;&lt;img src=&#034;common/images/bloglines.png&#034; alt=&#034;Add this post to Bloglines&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://www.facebook.com/share.php?u=http://javabeans.asia/2009/03/08/hibernate_event_interceptor.html&#034; target=&#034;_blank&#034; title=&#034;Add this post to Facebook&#034;&gt;&lt;img src=&#034;common/images/facebook.png&#034; alt=&#034;Add this post to Facebook&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://www.furl.net/storeIt.jsp?u=http://javabeans.asia/2009/03/08/hibernate_event_interceptor.html&amp;amp;t=Hibernate Event Interceptor&#034; target=&#034;_blank&#034; title=&#034;Add this post to Furl&#034;&gt;&lt;img src=&#034;common/images/furl.png&#034; alt=&#034;Add this post to Furl&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;https://favorites.live.com/quickadd.aspx?mkt=en-us&amp;amp;url=http://javabeans.asia/2009/03/08/hibernate_event_interceptor.html&amp;amp;title=Hibernate Event Interceptor&#034; target=&#034;_blank&#034; title=&#034;Add this post to Windows Live&#034;&gt;&lt;img src=&#034;common/images/windowslive.png&#034; alt=&#034;Add this post to Windows Live&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://bookmarks.yahoo.com/toolbar/savebm?opener=tb&amp;amp;u=http://javabeans.asia/2009/03/08/hibernate_event_interceptor.html&amp;amp;t=Hibernate Event Interceptor&#034; target=&#034;_blank&#034; title=&#034;Add this post to Yahoo!&#034;&gt;&lt;img src=&#034;common/images/yahoo.png&#034; alt=&#034;Add this post to Yahoo!&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;p&gt;&lt;b&gt;Related Posts&lt;/b&gt;&lt;br /&gt;&lt;a href=&#034;http://javabeans.asia/2009/09/02/vmware_and_melbourne_it_launch_cloud_service.html&#034; rel=&#034;bookmark&#034; title=&#034;VMware and Melbourne IT launch cloud service&#034;&gt;VMware and Melbourne IT launch cloud service&lt;/a&gt;&lt;br /&gt;&lt;a href=&#034;http://javabeans.asia/2008/09/14/hibernate_how_to_map_two_collections_of_the_same_type_in_the_same_entity.html&#034; rel=&#034;bookmark&#034; title=&#034;Hibernate - How to map two collections of the same type in the same entity&#034;&gt;Hibernate - How to map two collections of the same type in the same entity&lt;/a&gt;&lt;br /&gt;&lt;a href=&#034;http://javabeans.asia/2008/05/01/using_template_to_deploy_a_jboss_queue.html&#034; rel=&#034;bookmark&#034; title=&#034;Using template to deploy a JBoss queue&#034;&gt;Using template to deploy a JBoss queue&lt;/a&gt;&lt;br /&gt;&lt;a href=&#034;http://javabeans.asia/2008/05/06/bitwise_operation_in_hibernate_3.html&#034; rel=&#034;bookmark&#034; title=&#034;Bitwise operation in Hibernate 3&#034;&gt;Bitwise operation in Hibernate 3&lt;/a&gt;&lt;br /&gt;&lt;a href=&#034;http://javabeans.asia/2008/04/30/serialize_pojo_to_xml.html&#034; rel=&#034;bookmark&#034; title=&#034;Serialize POJO to XML&#034;&gt;Serialize POJO to XML&lt;/a&gt;&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;</description>
	<!--
    <description>
          Its quite common when you create an application, there is a need to create an audit trail on the application level where all entity insert, update and delete events are logged.   In this post, I would like to describe a simple approach that can help you to avoid littering with unnecessary statements in your ...&lt;p&gt;&lt;a href=&#034;http://javabeans.asia/2009/03/08/hibernate_event_interceptor.html&#034;&gt;Read more...&lt;/a&gt;&lt;/p&gt;&lt;div class=&#034;tags&#034;&gt;&lt;span&gt;Social Bookmarks : &lt;/span&gt;&amp;nbsp;&lt;a href=&#034;http://slashdot.org/bookmark.pl?url=http://javabeans.asia/2009/03/08/hibernate_event_interceptor.html&amp;amp;title=Hibernate Event Interceptor&#034; target=&#034;_blank&#034; title=&#034;Add this post to Slash Dot&#034;&gt;&lt;img src=&#034;common/images/slashdot.png&#034; alt=&#034;Add this post to Slashdot&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://digg.com/submit?url=http://javabeans.asia/2009/03/08/hibernate_event_interceptor.html&amp;amp;title=Hibernate Event Interceptor&#034; target=&#034;_blank&#034; title=&#034;Digg this post&#034;&gt;&lt;img src=&#034;common/images/digg.png&#034; alt=&#034;Add this post to Digg&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://reddit.com/submit?url=http://javabeans.asia/2009/03/08/hibernate_event_interceptor.html&amp;amp;title=Hibernate Event Interceptor&#034; target=&#034;_blank&#034; title=&#034;Add this post to Reddit&#034;&gt;&lt;img src=&#034;common/images/reddit.png&#034; alt=&#034;Add this post to Reddit&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://del.icio.us/post?url=http://javabeans.asia/2009/03/08/hibernate_event_interceptor.html&amp;amp;title=Hibernate Event Interceptor&#034; target=&#034;_blank&#034; title=&#034;Save this post to Del.icio.us&#034;&gt;&lt;img src=&#034;common/images/delicious.png&#034; alt=&#034;Add this post to Delicious&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://www.stumbleupon.com/submit?url=http://javabeans.asia/2009/03/08/hibernate_event_interceptor.html&amp;amp;title=Hibernate Event Interceptor&#034; target=&#034;_blank&#034; title=&#034;Stumble this post&#034;&gt;&lt;img src=&#034;common/images/stumbleupon.png&#034; alt=&#034;Add this post to Stumble it&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://www.google.com/bookmarks/mark?op=edit&amp;amp;bkmk=http://javabeans.asia/2009/03/08/hibernate_event_interceptor.html&amp;amp;title=Hibernate Event Interceptor&#034; target=&#034;_blank&#034; title=&#034;Add this post to Google&#034;&gt;&lt;img src=&#034;common/images/google.png&#034; alt=&#034;Add this post to Google&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://technorati.com/faves?add=http://javabeans.asia/2009/03/08/hibernate_event_interceptor.html&#034; target=&#034;_blank&#034; title=&#034;Add this post to Technorati&#034;&gt;&lt;img src=&#034;common/images/technorati.png&#034; alt=&#034;Add this post to Technorati&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://www.bloglines.com/sub/http://javabeans.asia/2009/03/08/hibernate_event_interceptor.html&#034; target=&#034;_blank&#034; title=&#034;Add this post to Bloglines&#034;&gt;&lt;img src=&#034;common/images/bloglines.png&#034; alt=&#034;Add this post to Bloglines&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://www.facebook.com/share.php?u=http://javabeans.asia/2009/03/08/hibernate_event_interceptor.html&#034; target=&#034;_blank&#034; title=&#034;Add this post to Facebook&#034;&gt;&lt;img src=&#034;common/images/facebook.png&#034; alt=&#034;Add this post to Facebook&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://www.furl.net/storeIt.jsp?u=http://javabeans.asia/2009/03/08/hibernate_event_interceptor.html&amp;amp;t=Hibernate Event Interceptor&#034; target=&#034;_blank&#034; title=&#034;Add this post to Furl&#034;&gt;&lt;img src=&#034;common/images/furl.png&#034; alt=&#034;Add this post to Furl&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;https://favorites.live.com/quickadd.aspx?mkt=en-us&amp;amp;url=http://javabeans.asia/2009/03/08/hibernate_event_interceptor.html&amp;amp;title=Hibernate Event Interceptor&#034; target=&#034;_blank&#034; title=&#034;Add this post to Windows Live&#034;&gt;&lt;img src=&#034;common/images/windowslive.png&#034; alt=&#034;Add this post to Windows Live&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://bookmarks.yahoo.com/toolbar/savebm?opener=tb&amp;amp;u=http://javabeans.asia/2009/03/08/hibernate_event_interceptor.html&amp;amp;t=Hibernate Event Interceptor&#034; target=&#034;_blank&#034; title=&#034;Add this post to Yahoo!&#034;&gt;&lt;img src=&#034;common/images/yahoo.png&#034; alt=&#034;Add this post to Yahoo!&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&lt;/div&gt;</description>
      
	-->
    <category>java</category>
    <category>hibernate</category>
    <category>xml</category>
    <comments>http://javabeans.asia/2009/03/08/hibernate_event_interceptor.html#comments</comments>
    <guid isPermaLink="true">http://javabeans.asia/2009/03/08/hibernate_event_interceptor.html</guid>
    <pubDate>Sun, 08 Mar 2009 05:42:00 GMT</pubDate>
  </item>
  <item>
    <title>Hibernate - How to map two collections of the same type in the same entity</title>
    <link>http://javabeans.asia/2008/09/14/hibernate_how_to_map_two_collections_of_the_same_type_in_the_same_entity.html</link>
	 <description>
        Recently during development, I encountered a situation where I had to map two collections in the same entity, having collections and the entity it self of the same type.&lt;br /&gt;
&lt;br /&gt;
I had persistent entity - Rule. Rule could have children rules: &amp;quot;&lt;em&gt;action&lt;/em&gt;&amp;quot; rules and &amp;quot;&lt;em&gt;else&lt;/em&gt;&amp;quot; rules. Children rules were also of type Rule. &lt;br /&gt;
&lt;br /&gt;
Basically it was a one-to-many relationship mapping of an entity to itself twice: &lt;br /&gt;
Entity Rule could have two different collections of the same object type - Rule. The collections represented &amp;quot;action&amp;quot; and &amp;quot;else&amp;quot; rules.&lt;br /&gt;
&lt;br /&gt;
The challenge that I faced was during XML generation of the persisted entity Rule:&lt;br /&gt;
I could successfully persist entity Rule with its children Rules to DB. But, when I was generating the XML, Hibernate was not able to differentiate between &amp;quot;action&amp;quot; and &amp;quot;else&amp;quot; rules and was adding every child Rule to each collection. This was causing the same entity to appear once in each collection:
&lt;pre class=&#034;xml:firstline[1]&#034; name=&#034;code&#034;&gt;&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot;?&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;Rule id=&amp;quot;1&amp;quot;&amp;gt;&lt;br /&gt;	&amp;lt;ruleType&amp;gt;-1&amp;lt;/ruleType&amp;gt;&lt;br /&gt;	&amp;lt;actionChildren&amp;gt;&lt;br /&gt;		&amp;lt;rule&amp;gt;1&amp;lt;/rule&amp;gt;&lt;br /&gt;		&amp;lt;rule&amp;gt;2&amp;lt;/rule&amp;gt;&lt;br /&gt;	&amp;lt;/actionChildren&amp;gt;&lt;br /&gt;	&amp;lt;elseChildren&amp;gt;&lt;br /&gt;		&amp;lt;rule&amp;gt;1&amp;lt;/rule&amp;gt;&lt;br /&gt;		&amp;lt;rule&amp;gt;2&amp;lt;/rule&amp;gt;&lt;br /&gt;	&amp;lt;/elseChildren&amp;gt;&lt;br /&gt;&amp;lt;/Rule&amp;gt;&lt;br /&gt;&lt;/pre&gt;
I needed to &amp;quot;tell&amp;quot; somehow to Hibernate which child entity Rule should be added to which collection. I am not sure if my solution is the best in this case, but I created a discriminator property inside entity Rule - &amp;quot;ruleType&amp;quot;. &lt;br /&gt;
&lt;br /&gt;
Respectively, in HBM file, in the mappings of one-to-many relationships, I specified by using SQL query, which rules should be added to the collection when XML is generated. The SQL query was inside &lt;em&gt;where&lt;/em&gt; attribute of &amp;lt;list&amp;gt; element.&lt;br /&gt;
&lt;br /&gt;
It done the trick for me - when I was adding a child rule to a parent entity, I was specifying&amp;nbsp; child rule type. Therefore, Hibernate was generating XML correctly by adding &amp;quot;action&amp;quot; rules and &amp;quot;else&amp;quot; rules to their respective collections.&lt;br /&gt;
&lt;br /&gt;
Here is entity Rule:
&lt;pre class=&#034;java:firstline[1]&#034; name=&#034;code&#034;&gt;package org.example.rules;&lt;br /&gt;&lt;br /&gt;import java.io.Serializable;&lt;br /&gt;import java.util.ArrayList;&lt;br /&gt;import java.util.List;&lt;br /&gt;&lt;br /&gt;public class Rule implements &lt;br /&gt;			Serializable {&lt;br /&gt;&lt;br /&gt;private static final long &lt;br /&gt;	serialVersionUID = -76784L;&lt;br /&gt;&lt;br /&gt;private int idx;&lt;br /&gt;private int ruleType = -1;&lt;br /&gt;private Rule parentRule = null;&lt;br /&gt;&lt;br /&gt;private List&amp;lt;Rule&amp;gt; actionChildren = &lt;br /&gt;		new ArrayList&amp;lt;Rule&amp;gt;();&lt;br /&gt;&lt;br /&gt;private List&amp;lt;Rule&amp;gt; elseChildren = &lt;br /&gt;		new ArrayList&amp;lt;Rule&amp;gt;();&lt;br /&gt;&lt;br /&gt;/**&lt;br /&gt; * Default constructor&lt;br /&gt; */&lt;br /&gt;public Rule() {&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;/**&lt;br /&gt; * @return the &#039;action&#039; children&lt;br /&gt; */&lt;br /&gt;public List&amp;lt;Rule&amp;gt; getActionChildren() {&lt;br /&gt;	return actionChildren;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;/**&lt;br /&gt; * @param children&lt;br /&gt; *            &#039;action&#039; children to set&lt;br /&gt; */&lt;br /&gt;public void setActionChildren(List&amp;lt;Rule&amp;gt; actionChildren) {&lt;br /&gt;	this.actionChildren = actionChildren;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;/**&lt;br /&gt; * @return the &#039;else&#039; children&lt;br /&gt; */&lt;br /&gt;public List&amp;lt;Rule&amp;gt; getElseChildren() {&lt;br /&gt;	return elseChildren;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;/**&lt;br /&gt; * @param children&lt;br /&gt; *            &#039;else&#039; children to set&lt;br /&gt; */&lt;br /&gt;public void setElseChildren(List&amp;lt;Rule&amp;gt; elseChildren) {&lt;br /&gt;	this.elseChildren = elseChildren;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;/**&lt;br /&gt; * Adds an &#039;action&#039; child to the current rule&lt;br /&gt; * &lt;br /&gt; * @param actionChild&lt;br /&gt; *            The rule to be added as a child&lt;br /&gt; */&lt;br /&gt;&lt;br /&gt;public void addActionChild(Rule actionChild) {&lt;br /&gt;	if (!this.actionChildren.contains(actionChild)) {&lt;br /&gt;		actionChild.setParentRule(this);&lt;br /&gt;		this.actionChildren.add(actionChild);&lt;br /&gt;	}&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;/**&lt;br /&gt; * Adds an &#039;else&#039; child to the current rule&lt;br /&gt; * &lt;br /&gt; * @param elseChild&lt;br /&gt; *            The rule to be added as a child&lt;br /&gt; */&lt;br /&gt;&lt;br /&gt;public void addElseChild(Rule elseChild) {&lt;br /&gt;	if (!this.elseChildren.contains(elseChild)) {&lt;br /&gt;		elseChild.setParentRule(this);&lt;br /&gt;		this.elseChildren.add(elseChild);&lt;br /&gt;	}&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;/**&lt;br /&gt; * @return the ruleType&lt;br /&gt; */&lt;br /&gt;public int getRuleType() {&lt;br /&gt;	return ruleType;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;/**&lt;br /&gt; * @param ruleType&lt;br /&gt; *            the ruleType to set&lt;br /&gt; */&lt;br /&gt;public void setRuleType(int ruleType) {&lt;br /&gt;	this.ruleType = ruleType;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;/**&lt;br /&gt; * @return collection index&lt;br /&gt; */&lt;br /&gt;public int getIdx() {&lt;br /&gt;	return idx;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;/**&lt;br /&gt; * Sets collection index&lt;br /&gt; * @param collection index&lt;br /&gt; */&lt;br /&gt;public int setIdx(int idx) {&lt;br /&gt;	this.idx = idx;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;/**&lt;br /&gt; * @return parent rule of the current rule&lt;br /&gt; */&lt;br /&gt;public Rule getParentRule() {&lt;br /&gt;	return parentRule;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;/**&lt;br /&gt; * @param ruleParent&lt;br /&gt; *            the ruleParent to set&lt;br /&gt; */&lt;br /&gt;public void setParentRule(Rule parentRule) {&lt;br /&gt;	this.parentRule = parentRule;&lt;br /&gt;}	&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;
Rule HBM file:
&lt;pre name=&#034;code&#034; class=&#034;xml:firstline[1]&#034;&gt;&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot;?&amp;gt;&lt;br /&gt;&amp;lt;!DOCTYPE hibernate-mapping PUBLIC&lt;br /&gt;&amp;quot;-//Hibernate/Hibernate Mapping DTD 3.0//EN&amp;quot;&lt;br /&gt;&amp;quot;http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd&amp;quot;&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;hibernate-mapping&amp;gt;&lt;br /&gt;&amp;lt;class name=&amp;quot;org.example.rules.Rule&amp;quot;&lt;br /&gt;	table=&amp;quot;org_example_rules_Rule&amp;quot; node=&amp;quot;Rule&amp;quot;&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;id name=&amp;quot;id&amp;quot; column=&amp;quot;id&amp;quot; node=&amp;quot;@id&amp;quot; &lt;br /&gt;			unsaved-value=&amp;quot;0&amp;quot;&amp;gt;&lt;br /&gt;	&amp;lt;generator class=&amp;quot;native&amp;quot; /&amp;gt;&lt;br /&gt;&amp;lt;/id&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;!--&lt;br /&gt;Used to help Hibernate to discriminate &lt;br /&gt;between children rules&lt;br /&gt;--&amp;gt;&lt;br /&gt;&amp;lt;property name=&amp;quot;ruleType&amp;quot; column=&amp;quot;ruleType&amp;quot; &lt;br /&gt;								node=&amp;quot;ruleType&amp;quot; /&amp;gt;&lt;br /&gt;&amp;lt;!-- &lt;br /&gt;Attribute &#039;where&#039; holds SQL query used to help Hibernate &lt;br /&gt;to discriminate between children rules of type &#039;action&#039; &lt;br /&gt;and children rules of type &#039;else&#039;. &lt;br /&gt;	&lt;br /&gt;Since two children rule lists in the current HBM are of &lt;br /&gt;the same type (org.example.rules.Rule), Hibernate needs &lt;br /&gt;a &#039;hint&#039; how to discriminate which rules belong to &lt;br /&gt;which list when XML is generated.&lt;br /&gt;	&lt;br /&gt;If ruleType equals to &#039;1&#039;, it means that the child &lt;br /&gt;rule is &#039;action&#039; rule.&lt;br /&gt;&lt;br /&gt;If ruleType equals to &#039;2&#039;, it means that the child &lt;br /&gt;rule is &#039;else&#039; rule.&lt;br /&gt;--&amp;gt;&lt;br /&gt;&amp;lt;list name=&amp;quot;actionChildren&amp;quot; embed-xml=&amp;quot;true&amp;quot; &lt;br /&gt;		where=&amp;quot;ruleType=1&amp;quot; cascade=&amp;quot;all&amp;quot;&amp;gt;&lt;br /&gt;&lt;br /&gt;	&amp;lt;key column=&amp;quot;parentrule_id&amp;quot; /&amp;gt;&lt;br /&gt;	&amp;lt;list-index column=&amp;quot;idx&amp;quot; base=&amp;quot;0&amp;quot; /&amp;gt;&lt;br /&gt;	&amp;lt;one-to-many class=&amp;quot;org.example.rules.Rule&amp;quot;&lt;br /&gt;		node=&amp;quot;rule&amp;quot; embed-xml=&amp;quot;false&amp;quot; /&amp;gt;&lt;br /&gt;&amp;lt;/list&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;!-- &lt;br /&gt;If ruleType equals to &#039;2&#039;, it means that the child &lt;br /&gt;rule is &#039;else&#039; rule.&lt;br /&gt;--&amp;gt;&lt;br /&gt;&amp;lt;list name=&amp;quot;elseChildren&amp;quot; embed-xml=&amp;quot;true&amp;quot; &lt;br /&gt;		where=&amp;quot;ruleType=2&amp;quot; cascade=&amp;quot;all&amp;quot;&amp;gt;&lt;br /&gt;&lt;br /&gt;	&amp;lt;key column=&amp;quot;parentrule_id&amp;quot; /&amp;gt;&lt;br /&gt;	&amp;lt;list-index column=&amp;quot;idx&amp;quot; base=&amp;quot;0&amp;quot; /&amp;gt;&lt;br /&gt;	&amp;lt;one-to-many class=&amp;quot;org.example.rules.Rule&amp;quot;&lt;br /&gt;		node=&amp;quot;rule&amp;quot; embed-xml=&amp;quot;false&amp;quot; /&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;/list&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;!--&lt;br /&gt;Read-only index column, represents position of &lt;br /&gt;the element in the list&lt;br /&gt;--&amp;gt;&lt;br /&gt;&amp;lt;property name=&amp;quot;idx&amp;quot; column=&amp;quot;idx&amp;quot; node=&amp;quot;idx&amp;quot; &lt;br /&gt;		update=&amp;quot;false&amp;quot; insert=&amp;quot;false&amp;quot; type=&amp;quot;int&amp;quot; /&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;!-- &lt;br /&gt;Embed XML must be equals to &#039;false&#039;, &lt;br /&gt;otherwise when XML is generated for &lt;br /&gt;children rules, parent XML will be &lt;br /&gt;generated recursively &lt;br /&gt;--&amp;gt;&lt;br /&gt;&amp;lt;many-to-one name=&amp;quot;parentRule&amp;quot; node=&amp;quot;parentRule&amp;quot;&lt;br /&gt;	column=&amp;quot;parentrule_id&amp;quot; class=&amp;quot;org.example.rules.Rule&amp;quot;&lt;br /&gt;	not-null=&amp;quot;false&amp;quot; insert=&amp;quot;false&amp;quot; update=&amp;quot;false&amp;quot; &lt;br /&gt;	embed-xml=&amp;quot;false&amp;quot; /&amp;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;
Generally, I would not advise to design persistent entities in this way, it can create problem later on. For example if there is a need to delete child entities. It can become a bit tricky, since entity has relationship to it self.&lt;br /&gt;
&lt;br /&gt;
Suggestions? Flames?&lt;div class=&#034;tags&#034;&gt;&lt;span&gt;Social Bookmarks : &lt;/span&gt;&amp;nbsp;&lt;a href=&#034;http://slashdot.org/bookmark.pl?url=http://javabeans.asia/2008/09/14/hibernate_how_to_map_two_collections_of_the_same_type_in_the_same_entity.html&amp;amp;title=Hibernate - How to map two collections of the same type in the same entity&#034; target=&#034;_blank&#034; title=&#034;Add this post to Slash Dot&#034;&gt;&lt;img src=&#034;common/images/slashdot.png&#034; alt=&#034;Add this post to Slashdot&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://digg.com/submit?url=http://javabeans.asia/2008/09/14/hibernate_how_to_map_two_collections_of_the_same_type_in_the_same_entity.html&amp;amp;title=Hibernate - How to map two collections of the same type in the same entity&#034; target=&#034;_blank&#034; title=&#034;Digg this post&#034;&gt;&lt;img src=&#034;common/images/digg.png&#034; alt=&#034;Add this post to Digg&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://reddit.com/submit?url=http://javabeans.asia/2008/09/14/hibernate_how_to_map_two_collections_of_the_same_type_in_the_same_entity.html&amp;amp;title=Hibernate - How to map two collections of the same type in the same entity&#034; target=&#034;_blank&#034; title=&#034;Add this post to Reddit&#034;&gt;&lt;img src=&#034;common/images/reddit.png&#034; alt=&#034;Add this post to Reddit&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://del.icio.us/post?url=http://javabeans.asia/2008/09/14/hibernate_how_to_map_two_collections_of_the_same_type_in_the_same_entity.html&amp;amp;title=Hibernate - How to map two collections of the same type in the same entity&#034; target=&#034;_blank&#034; title=&#034;Save this post to Del.icio.us&#034;&gt;&lt;img src=&#034;common/images/delicious.png&#034; alt=&#034;Add this post to Delicious&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://www.stumbleupon.com/submit?url=http://javabeans.asia/2008/09/14/hibernate_how_to_map_two_collections_of_the_same_type_in_the_same_entity.html&amp;amp;title=Hibernate - How to map two collections of the same type in the same entity&#034; target=&#034;_blank&#034; title=&#034;Stumble this post&#034;&gt;&lt;img src=&#034;common/images/stumbleupon.png&#034; alt=&#034;Add this post to Stumble it&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://www.google.com/bookmarks/mark?op=edit&amp;amp;bkmk=http://javabeans.asia/2008/09/14/hibernate_how_to_map_two_collections_of_the_same_type_in_the_same_entity.html&amp;amp;title=Hibernate - How to map two collections of the same type in the same entity&#034; target=&#034;_blank&#034; title=&#034;Add this post to Google&#034;&gt;&lt;img src=&#034;common/images/google.png&#034; alt=&#034;Add this post to Google&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://technorati.com/faves?add=http://javabeans.asia/2008/09/14/hibernate_how_to_map_two_collections_of_the_same_type_in_the_same_entity.html&#034; target=&#034;_blank&#034; title=&#034;Add this post to Technorati&#034;&gt;&lt;img src=&#034;common/images/technorati.png&#034; alt=&#034;Add this post to Technorati&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://www.bloglines.com/sub/http://javabeans.asia/2008/09/14/hibernate_how_to_map_two_collections_of_the_same_type_in_the_same_entity.html&#034; target=&#034;_blank&#034; title=&#034;Add this post to Bloglines&#034;&gt;&lt;img src=&#034;common/images/bloglines.png&#034; alt=&#034;Add this post to Bloglines&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://www.facebook.com/share.php?u=http://javabeans.asia/2008/09/14/hibernate_how_to_map_two_collections_of_the_same_type_in_the_same_entity.html&#034; target=&#034;_blank&#034; title=&#034;Add this post to Facebook&#034;&gt;&lt;img src=&#034;common/images/facebook.png&#034; alt=&#034;Add this post to Facebook&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://www.furl.net/storeIt.jsp?u=http://javabeans.asia/2008/09/14/hibernate_how_to_map_two_collections_of_the_same_type_in_the_same_entity.html&amp;amp;t=Hibernate - How to map two collections of the same type in the same entity&#034; target=&#034;_blank&#034; title=&#034;Add this post to Furl&#034;&gt;&lt;img src=&#034;common/images/furl.png&#034; alt=&#034;Add this post to Furl&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;https://favorites.live.com/quickadd.aspx?mkt=en-us&amp;amp;url=http://javabeans.asia/2008/09/14/hibernate_how_to_map_two_collections_of_the_same_type_in_the_same_entity.html&amp;amp;title=Hibernate - How to map two collections of the same type in the same entity&#034; target=&#034;_blank&#034; title=&#034;Add this post to Windows Live&#034;&gt;&lt;img src=&#034;common/images/windowslive.png&#034; alt=&#034;Add this post to Windows Live&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://bookmarks.yahoo.com/toolbar/savebm?opener=tb&amp;amp;u=http://javabeans.asia/2008/09/14/hibernate_how_to_map_two_collections_of_the_same_type_in_the_same_entity.html&amp;amp;t=Hibernate - How to map two collections of the same type in the same entity&#034; target=&#034;_blank&#034; title=&#034;Add this post to Yahoo!&#034;&gt;&lt;img src=&#034;common/images/yahoo.png&#034; alt=&#034;Add this post to Yahoo!&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;p&gt;&lt;b&gt;Related Posts&lt;/b&gt;&lt;br /&gt;&lt;a href=&#034;http://javabeans.asia/2009/04/05/brainteaser_broken_case_of_inheritance.html&#034; rel=&#034;bookmark&#034; title=&#034;Brainteaser: Broken case of inheritance&#034;&gt;Brainteaser: Broken case of inheritance&lt;/a&gt;&lt;br /&gt;&lt;a href=&#034;http://javabeans.asia/2009/04/18/brainteaser_overridable_methods.html&#034; rel=&#034;bookmark&#034; title=&#034;Brainteaser: Overridable methods &#034;&gt;Brainteaser: Overridable methods &lt;/a&gt;&lt;br /&gt;&lt;a href=&#034;http://javabeans.asia/2009/03/08/hibernate_event_interceptor.html&#034; rel=&#034;bookmark&#034; title=&#034;Hibernate Event Interceptor&#034;&gt;Hibernate Event Interceptor&lt;/a&gt;&lt;br /&gt;&lt;a href=&#034;http://javabeans.asia/2008/11/15/java_and_those_frameworks.html&#034; rel=&#034;bookmark&#034; title=&#034;Java and those frameworks&#034;&gt;Java and those frameworks&lt;/a&gt;&lt;br /&gt;&lt;a href=&#034;http://javabeans.asia/2008/10/12/how_to_set_securitymanager_and_java_security_policy_programmatically.html&#034; rel=&#034;bookmark&#034; title=&#034;How to set SecurityManager and Java security policy programmatically&#034;&gt;How to set SecurityManager and Java security policy programmatically&lt;/a&gt;&lt;br /&gt;&lt;a href=&#034;http://javabeans.asia/2008/10/13/hack_any_java_class_using_reflection_attack.html&#034; rel=&#034;bookmark&#034; title=&#034;Hack any Java class using reflection attack&#034;&gt;Hack any Java class using reflection attack&lt;/a&gt;&lt;br /&gt;&lt;a href=&#034;http://javabeans.asia/2008/10/19/brainteaser_broken_comparator.html&#034; rel=&#034;bookmark&#034; title=&#034;Brainteaser: Broken comparator&#034;&gt;Brainteaser: Broken comparator&lt;/a&gt;&lt;br /&gt;&lt;a href=&#034;http://javabeans.asia/2008/09/06/singleton_pattern_and_problem_with_double_checked_locking.html&#034; rel=&#034;bookmark&#034; title=&#034;Singleton pattern and problem with double checked locking &#034;&gt;Singleton pattern and problem with double checked locking &lt;/a&gt;&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;</description>
	<!--
    <description>
          Recently during development, I encountered a situation where I had to map two collections in the same entity, having collections and the entity it self of the same type.  I had persistent entity - Rule. Rule could have children rules: &amp;quot;action&amp;quot; rules and &amp;quot;else&amp;quot; rules. Children rules were also of ...&lt;p&gt;&lt;a href=&#034;http://javabeans.asia/2008/09/14/hibernate_how_to_map_two_collections_of_the_same_type_in_the_same_entity.html&#034;&gt;Read more...&lt;/a&gt;&lt;/p&gt;&lt;div class=&#034;tags&#034;&gt;&lt;span&gt;Social Bookmarks : &lt;/span&gt;&amp;nbsp;&lt;a href=&#034;http://slashdot.org/bookmark.pl?url=http://javabeans.asia/2008/09/14/hibernate_how_to_map_two_collections_of_the_same_type_in_the_same_entity.html&amp;amp;title=Hibernate - How to map two collections of the same type in the same entity&#034; target=&#034;_blank&#034; title=&#034;Add this post to Slash Dot&#034;&gt;&lt;img src=&#034;common/images/slashdot.png&#034; alt=&#034;Add this post to Slashdot&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://digg.com/submit?url=http://javabeans.asia/2008/09/14/hibernate_how_to_map_two_collections_of_the_same_type_in_the_same_entity.html&amp;amp;title=Hibernate - How to map two collections of the same type in the same entity&#034; target=&#034;_blank&#034; title=&#034;Digg this post&#034;&gt;&lt;img src=&#034;common/images/digg.png&#034; alt=&#034;Add this post to Digg&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://reddit.com/submit?url=http://javabeans.asia/2008/09/14/hibernate_how_to_map_two_collections_of_the_same_type_in_the_same_entity.html&amp;amp;title=Hibernate - How to map two collections of the same type in the same entity&#034; target=&#034;_blank&#034; title=&#034;Add this post to Reddit&#034;&gt;&lt;img src=&#034;common/images/reddit.png&#034; alt=&#034;Add this post to Reddit&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://del.icio.us/post?url=http://javabeans.asia/2008/09/14/hibernate_how_to_map_two_collections_of_the_same_type_in_the_same_entity.html&amp;amp;title=Hibernate - How to map two collections of the same type in the same entity&#034; target=&#034;_blank&#034; title=&#034;Save this post to Del.icio.us&#034;&gt;&lt;img src=&#034;common/images/delicious.png&#034; alt=&#034;Add this post to Delicious&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://www.stumbleupon.com/submit?url=http://javabeans.asia/2008/09/14/hibernate_how_to_map_two_collections_of_the_same_type_in_the_same_entity.html&amp;amp;title=Hibernate - How to map two collections of the same type in the same entity&#034; target=&#034;_blank&#034; title=&#034;Stumble this post&#034;&gt;&lt;img src=&#034;common/images/stumbleupon.png&#034; alt=&#034;Add this post to Stumble it&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://www.google.com/bookmarks/mark?op=edit&amp;amp;bkmk=http://javabeans.asia/2008/09/14/hibernate_how_to_map_two_collections_of_the_same_type_in_the_same_entity.html&amp;amp;title=Hibernate - How to map two collections of the same type in the same entity&#034; target=&#034;_blank&#034; title=&#034;Add this post to Google&#034;&gt;&lt;img src=&#034;common/images/google.png&#034; alt=&#034;Add this post to Google&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://technorati.com/faves?add=http://javabeans.asia/2008/09/14/hibernate_how_to_map_two_collections_of_the_same_type_in_the_same_entity.html&#034; target=&#034;_blank&#034; title=&#034;Add this post to Technorati&#034;&gt;&lt;img src=&#034;common/images/technorati.png&#034; alt=&#034;Add this post to Technorati&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://www.bloglines.com/sub/http://javabeans.asia/2008/09/14/hibernate_how_to_map_two_collections_of_the_same_type_in_the_same_entity.html&#034; target=&#034;_blank&#034; title=&#034;Add this post to Bloglines&#034;&gt;&lt;img src=&#034;common/images/bloglines.png&#034; alt=&#034;Add this post to Bloglines&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://www.facebook.com/share.php?u=http://javabeans.asia/2008/09/14/hibernate_how_to_map_two_collections_of_the_same_type_in_the_same_entity.html&#034; target=&#034;_blank&#034; title=&#034;Add this post to Facebook&#034;&gt;&lt;img src=&#034;common/images/facebook.png&#034; alt=&#034;Add this post to Facebook&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://www.furl.net/storeIt.jsp?u=http://javabeans.asia/2008/09/14/hibernate_how_to_map_two_collections_of_the_same_type_in_the_same_entity.html&amp;amp;t=Hibernate - How to map two collections of the same type in the same entity&#034; target=&#034;_blank&#034; title=&#034;Add this post to Furl&#034;&gt;&lt;img src=&#034;common/images/furl.png&#034; alt=&#034;Add this post to Furl&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;https://favorites.live.com/quickadd.aspx?mkt=en-us&amp;amp;url=http://javabeans.asia/2008/09/14/hibernate_how_to_map_two_collections_of_the_same_type_in_the_same_entity.html&amp;amp;title=Hibernate - How to map two collections of the same type in the same entity&#034; target=&#034;_blank&#034; title=&#034;Add this post to Windows Live&#034;&gt;&lt;img src=&#034;common/images/windowslive.png&#034; alt=&#034;Add this post to Windows Live&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://bookmarks.yahoo.com/toolbar/savebm?opener=tb&amp;amp;u=http://javabeans.asia/2008/09/14/hibernate_how_to_map_two_collections_of_the_same_type_in_the_same_entity.html&amp;amp;t=Hibernate - How to map two collections of the same type in the same entity&#034; target=&#034;_blank&#034; title=&#034;Add this post to Yahoo!&#034;&gt;&lt;img src=&#034;common/images/yahoo.png&#034; alt=&#034;Add this post to Yahoo!&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&lt;/div&gt;</description>
      
	-->
    <category>design patterns</category>
    <category>hibernate</category>
    <comments>http://javabeans.asia/2008/09/14/hibernate_how_to_map_two_collections_of_the_same_type_in_the_same_entity.html#comments</comments>
    <guid isPermaLink="true">http://javabeans.asia/2008/09/14/hibernate_how_to_map_two_collections_of_the_same_type_in_the_same_entity.html</guid>
    <pubDate>Sun, 14 Sep 2008 12:00:00 GMT</pubDate>
  </item>
  <item>
    <title>Bitwise operation in Hibernate 3</title>
    <link>http://javabeans.asia/2008/05/06/bitwise_operation_in_hibernate_3.html</link>
	 <description>
        Hi all...&lt;br /&gt;
i encountered a small problem in doing bitwise operations with hibernate. Until now, HIbernate 2 HQL parser has supported bitwise operations. Hibernate 3 for some reason does not support it. So if you want to work around it, you have to create a custom SQLfunction and add it to the dialect, that will map the bitwise operator.&lt;br /&gt;
&lt;br /&gt;
You have to create your own class, which will extend from &lt;em&gt;StandardSQLFunction &lt;/em&gt;class and will implement &lt;em&gt;SQLFunction &lt;/em&gt;interface. You have to override render() method from the interface mentioned before and provide your own implementation.&lt;br /&gt;
&lt;br /&gt;
In my example I am showing how to use ampersand symbol (&#039;&amp;amp;&#039;) for bitwise operation.&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;Important note&lt;/strong&gt;: &lt;span class=&#034;postbody&#034;&gt;&lt;br /&gt;
Hibernate team people have changed &lt;em&gt;SQLFunction&lt;/em&gt; interface when upgrading from version 3.0.2 to 3.0.3, so your custom implementation of bitwise operation in version 3.0.2 will not work in 3.0.3. &lt;/span&gt;&lt;span class=&#034;postbody&#034;&gt;So keep that in mind.&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;Update&lt;/strong&gt; (&lt;em&gt;13.Jan.2010&lt;/em&gt;):&lt;br /&gt;
According to one of the blog reader&#039;s this example has successfully worked under Hibernate v.3.2.6!&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;Implementation:&lt;/strong&gt; &lt;br /&gt;
I am&amp;nbsp; using Sysbase dialect, so i will create a class that extends this dialect with my own implementation:
&lt;pre name=&#034;code&#034; class=&#034;java:nocontrols:firstline[1]&#034;&gt;package com.project.test.dialect;&lt;br /&gt;&lt;br /&gt;import org.hibernate.Hibernate;&lt;br /&gt;&lt;br /&gt;public class SybaseDialect extends &lt;br /&gt;	org.hibernate.dialect.SybaseDialect{&lt;br /&gt;	 &lt;br /&gt;	public SybaseDialect() {&lt;br /&gt;	   super();&lt;br /&gt;	   registerFunction(&amp;quot;bitwise_and&amp;quot;, &lt;br /&gt;		new BitwiseAndFunction(&amp;quot;bitwise_and&amp;quot;, &lt;br /&gt;				Hibernate.INTEGER));&lt;br /&gt;	} &lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;
What it means basically that i am registering a function by the name of &lt;em&gt;bitwise_and&lt;/em&gt; the return type will be of type Integer.   &lt;br /&gt;
&lt;br /&gt;
Now, my custom class for SQLFunction like this:
&lt;pre name=&#034;code&#034; class=&#034;java:nocontrols:firstline[1]&#034;&gt;package com.project.test.dialect;&lt;br /&gt;&lt;br /&gt;import java.util.List;&lt;br /&gt;&lt;br /&gt;import org.hibernate.QueryException;&lt;br /&gt;import org.hibernate.dialect.function.SQLFunction;&lt;br /&gt;import org.hibernate.dialect.function.StandardSQLFunction;&lt;br /&gt;import org.hibernate.engine.SessionFactoryImplementor;&lt;br /&gt;import org.hibernate.type.Type;&lt;br /&gt;&lt;br /&gt;public class BitwiseAndFunction&lt;br /&gt;		extends StandardSQLFunction&lt;br /&gt;			 implements SQLFunction {&lt;br /&gt;&lt;br /&gt; public BitwiseAndFunction(String name) {&lt;br /&gt;		super(name);&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt; public BitwiseAndFunction(String name, Type type) {&lt;br /&gt;	super(name, type);&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt; public String render(List args,&lt;br /&gt;	SessionFactoryImplementor factory)&lt;br /&gt;			throws QueryException {&lt;br /&gt;   if (args.size() != 2) {&lt;br /&gt;      throw new IllegalArgumentException(&lt;br /&gt;	&amp;quot;the function must be passed 2 arguments&amp;quot;);&lt;br /&gt;   }&lt;br /&gt;   StringBuffer buffer = new&lt;br /&gt;	StringBuffer(args.get(0).toString());&lt;br /&gt;   buffer.append(&amp;quot; &amp;amp; &amp;quot;).append(args.get(1));&lt;br /&gt;   return buffer.toString();&lt;br /&gt; }&lt;br /&gt;}&lt;/pre&gt;
The method render() accepts two arguments, if less - exception will be thrown. Once arguments are passed to the method, it will return a String that will look something like this (assuming that the passed arguments were one (1) and two (2)):
&lt;pre class=&#034;codeSample&#034;&gt;1 &amp;amp; 2&lt;/pre&gt;
In my project, I am using named queries in my &lt;em&gt;hbm.xml&lt;/em&gt; files, so below you can see a part of my hbm.xml file where I use my bitwise function:
&lt;pre name=&#034;code&#034; class=&#034;xml:nocontrols:firstline[1]&#034;&gt;&amp;lt;query name=&amp;quot;UserPermissionsForEnttiy&amp;quot;&amp;gt;&lt;br /&gt;select object(ep) from EntityPermission ep where ep.userid =&lt;br /&gt;:userid and ep.entityid = :entityid and ep.classname =&lt;br /&gt;:classname and bitwise_and(ep.permission,:requiredpermission) &amp;gt; 0 &lt;br /&gt;&amp;lt;/query&amp;gt;&lt;/pre&gt;
Note the two arguments that i am passing to the &lt;em&gt;bitwise_and&lt;/em&gt; function. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Also not forget to update your persistence XML with your custom dialect class, this is how my &lt;em&gt;persistence.xml&lt;/em&gt; looks like:
&lt;pre name=&#034;code&#034; class=&#034;xml:nocontrols:firstline[1]&#034;&gt;&amp;lt;persistence&amp;gt;&lt;br /&gt;&amp;lt;persistence-unit name=&amp;quot;com.project.test.users&amp;quot;&amp;gt;&lt;br /&gt;&amp;lt;jta-data-source&amp;gt;java:/DefaultDS&amp;lt;/jta-data-source&amp;gt;&lt;br /&gt;   &amp;lt;properties&amp;gt;&lt;br /&gt;   &amp;lt;property name=&amp;quot;hibernate.dialect&amp;quot; &lt;br /&gt;	value=&amp;quot;com.project.test.dialect.SybaseDialect&amp;quot;/&amp;gt;&lt;br /&gt;   &amp;lt;property name=&amp;quot;hibernate.hbm2ddl.auto&amp;quot; &lt;br /&gt;	value=&amp;quot;update&amp;quot;/&amp;gt;&lt;br /&gt;   &amp;lt;property name=&amp;quot;hibernate.show_sql&amp;quot; &lt;br /&gt;	value=&amp;quot;true&amp;quot;/&amp;gt;&lt;br /&gt;	   .&lt;br /&gt;	   .&lt;br /&gt;	   .&lt;br /&gt;   &amp;lt;/properties&amp;gt;&lt;br /&gt;&amp;lt;/persistence-unit&amp;gt;&lt;br /&gt;&amp;lt;/persistence&amp;gt;&lt;/pre&gt;
Please note the &lt;em&gt;hibernate.dialect &lt;/em&gt;property. As a value i gave the canonical name of my custom &lt;em&gt;SysbaseDialect&lt;/em&gt; class.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Once you finished implementing your custom dialect classes, you can JAR them and put into the &lt;em&gt;lib&lt;/em&gt; directory of your JBoss instance where the rest of your Hibernate libraries are.&lt;br /&gt;
&lt;br /&gt;
Do not forget to restart your JBoss - it needs to load your newly added JAR, for you to be able to use it&amp;nbsp; ;)&lt;/span&gt;&lt;div class=&#034;tags&#034;&gt;&lt;span&gt;Social Bookmarks : &lt;/span&gt;&amp;nbsp;&lt;a href=&#034;http://slashdot.org/bookmark.pl?url=http://javabeans.asia/2008/05/06/bitwise_operation_in_hibernate_3.html&amp;amp;title=Bitwise operation in Hibernate 3&#034; target=&#034;_blank&#034; title=&#034;Add this post to Slash Dot&#034;&gt;&lt;img src=&#034;common/images/slashdot.png&#034; alt=&#034;Add this post to Slashdot&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://digg.com/submit?url=http://javabeans.asia/2008/05/06/bitwise_operation_in_hibernate_3.html&amp;amp;title=Bitwise operation in Hibernate 3&#034; target=&#034;_blank&#034; title=&#034;Digg this post&#034;&gt;&lt;img src=&#034;common/images/digg.png&#034; alt=&#034;Add this post to Digg&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://reddit.com/submit?url=http://javabeans.asia/2008/05/06/bitwise_operation_in_hibernate_3.html&amp;amp;title=Bitwise operation in Hibernate 3&#034; target=&#034;_blank&#034; title=&#034;Add this post to Reddit&#034;&gt;&lt;img src=&#034;common/images/reddit.png&#034; alt=&#034;Add this post to Reddit&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://del.icio.us/post?url=http://javabeans.asia/2008/05/06/bitwise_operation_in_hibernate_3.html&amp;amp;title=Bitwise operation in Hibernate 3&#034; target=&#034;_blank&#034; title=&#034;Save this post to Del.icio.us&#034;&gt;&lt;img src=&#034;common/images/delicious.png&#034; alt=&#034;Add this post to Delicious&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://www.stumbleupon.com/submit?url=http://javabeans.asia/2008/05/06/bitwise_operation_in_hibernate_3.html&amp;amp;title=Bitwise operation in Hibernate 3&#034; target=&#034;_blank&#034; title=&#034;Stumble this post&#034;&gt;&lt;img src=&#034;common/images/stumbleupon.png&#034; alt=&#034;Add this post to Stumble it&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://www.google.com/bookmarks/mark?op=edit&amp;amp;bkmk=http://javabeans.asia/2008/05/06/bitwise_operation_in_hibernate_3.html&amp;amp;title=Bitwise operation in Hibernate 3&#034; target=&#034;_blank&#034; title=&#034;Add this post to Google&#034;&gt;&lt;img src=&#034;common/images/google.png&#034; alt=&#034;Add this post to Google&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://technorati.com/faves?add=http://javabeans.asia/2008/05/06/bitwise_operation_in_hibernate_3.html&#034; target=&#034;_blank&#034; title=&#034;Add this post to Technorati&#034;&gt;&lt;img src=&#034;common/images/technorati.png&#034; alt=&#034;Add this post to Technorati&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://www.bloglines.com/sub/http://javabeans.asia/2008/05/06/bitwise_operation_in_hibernate_3.html&#034; target=&#034;_blank&#034; title=&#034;Add this post to Bloglines&#034;&gt;&lt;img src=&#034;common/images/bloglines.png&#034; alt=&#034;Add this post to Bloglines&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://www.facebook.com/share.php?u=http://javabeans.asia/2008/05/06/bitwise_operation_in_hibernate_3.html&#034; target=&#034;_blank&#034; title=&#034;Add this post to Facebook&#034;&gt;&lt;img src=&#034;common/images/facebook.png&#034; alt=&#034;Add this post to Facebook&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://www.furl.net/storeIt.jsp?u=http://javabeans.asia/2008/05/06/bitwise_operation_in_hibernate_3.html&amp;amp;t=Bitwise operation in Hibernate 3&#034; target=&#034;_blank&#034; title=&#034;Add this post to Furl&#034;&gt;&lt;img src=&#034;common/images/furl.png&#034; alt=&#034;Add this post to Furl&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;https://favorites.live.com/quickadd.aspx?mkt=en-us&amp;amp;url=http://javabeans.asia/2008/05/06/bitwise_operation_in_hibernate_3.html&amp;amp;title=Bitwise operation in Hibernate 3&#034; target=&#034;_blank&#034; title=&#034;Add this post to Windows Live&#034;&gt;&lt;img src=&#034;common/images/windowslive.png&#034; alt=&#034;Add this post to Windows Live&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://bookmarks.yahoo.com/toolbar/savebm?opener=tb&amp;amp;u=http://javabeans.asia/2008/05/06/bitwise_operation_in_hibernate_3.html&amp;amp;t=Bitwise operation in Hibernate 3&#034; target=&#034;_blank&#034; title=&#034;Add this post to Yahoo!&#034;&gt;&lt;img src=&#034;common/images/yahoo.png&#034; alt=&#034;Add this post to Yahoo!&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;p&gt;&lt;b&gt;Related Posts&lt;/b&gt;&lt;br /&gt;&lt;a href=&#034;http://javabeans.asia/2009/04/05/brainteaser_broken_case_of_inheritance.html&#034; rel=&#034;bookmark&#034; title=&#034;Brainteaser: Broken case of inheritance&#034;&gt;Brainteaser: Broken case of inheritance&lt;/a&gt;&lt;br /&gt;&lt;a href=&#034;http://javabeans.asia/2009/04/18/brainteaser_overridable_methods.html&#034; rel=&#034;bookmark&#034; title=&#034;Brainteaser: Overridable methods &#034;&gt;Brainteaser: Overridable methods &lt;/a&gt;&lt;br /&gt;&lt;a href=&#034;http://javabeans.asia/2009/03/08/hibernate_event_interceptor.html&#034; rel=&#034;bookmark&#034; title=&#034;Hibernate Event Interceptor&#034;&gt;Hibernate Event Interceptor&lt;/a&gt;&lt;br /&gt;&lt;a href=&#034;http://javabeans.asia/2008/10/01/brainteaser_arraylist_vs_treeset.html&#034; rel=&#034;bookmark&#034; title=&#034;Brainteaser: ArrayList VS TreeSet&#034;&gt;Brainteaser: ArrayList VS TreeSet&lt;/a&gt;&lt;br /&gt;&lt;a href=&#034;http://javabeans.asia/2008/10/12/how_to_set_securitymanager_and_java_security_policy_programmatically.html&#034; rel=&#034;bookmark&#034; title=&#034;How to set SecurityManager and Java security policy programmatically&#034;&gt;How to set SecurityManager and Java security policy programmatically&lt;/a&gt;&lt;br /&gt;&lt;a href=&#034;http://javabeans.asia/2008/10/13/hack_any_java_class_using_reflection_attack.html&#034; rel=&#034;bookmark&#034; title=&#034;Hack any Java class using reflection attack&#034;&gt;Hack any Java class using reflection attack&lt;/a&gt;&lt;br /&gt;&lt;a href=&#034;http://javabeans.asia/2008/10/19/brainteaser_broken_comparator.html&#034; rel=&#034;bookmark&#034; title=&#034;Brainteaser: Broken comparator&#034;&gt;Brainteaser: Broken comparator&lt;/a&gt;&lt;br /&gt;&lt;a href=&#034;http://javabeans.asia/2008/09/06/singleton_pattern_and_problem_with_double_checked_locking.html&#034; rel=&#034;bookmark&#034; title=&#034;Singleton pattern and problem with double checked locking &#034;&gt;Singleton pattern and problem with double checked locking &lt;/a&gt;&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;</description>
	<!--
    <description>
          Hi all... i encountered a small problem in doing bitwise operations with hibernate. Until now, HIbernate 2 HQL parser has supported bitwise operations. Hibernate 3 for some reason does not support it. So if you want to work around it, you have to create a custom SQLfunction and add it to the dialect, that will map ...&lt;p&gt;&lt;a href=&#034;http://javabeans.asia/2008/05/06/bitwise_operation_in_hibernate_3.html&#034;&gt;Read more...&lt;/a&gt;&lt;/p&gt;&lt;div class=&#034;tags&#034;&gt;&lt;span&gt;Social Bookmarks : &lt;/span&gt;&amp;nbsp;&lt;a href=&#034;http://slashdot.org/bookmark.pl?url=http://javabeans.asia/2008/05/06/bitwise_operation_in_hibernate_3.html&amp;amp;title=Bitwise operation in Hibernate 3&#034; target=&#034;_blank&#034; title=&#034;Add this post to Slash Dot&#034;&gt;&lt;img src=&#034;common/images/slashdot.png&#034; alt=&#034;Add this post to Slashdot&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://digg.com/submit?url=http://javabeans.asia/2008/05/06/bitwise_operation_in_hibernate_3.html&amp;amp;title=Bitwise operation in Hibernate 3&#034; target=&#034;_blank&#034; title=&#034;Digg this post&#034;&gt;&lt;img src=&#034;common/images/digg.png&#034; alt=&#034;Add this post to Digg&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://reddit.com/submit?url=http://javabeans.asia/2008/05/06/bitwise_operation_in_hibernate_3.html&amp;amp;title=Bitwise operation in Hibernate 3&#034; target=&#034;_blank&#034; title=&#034;Add this post to Reddit&#034;&gt;&lt;img src=&#034;common/images/reddit.png&#034; alt=&#034;Add this post to Reddit&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://del.icio.us/post?url=http://javabeans.asia/2008/05/06/bitwise_operation_in_hibernate_3.html&amp;amp;title=Bitwise operation in Hibernate 3&#034; target=&#034;_blank&#034; title=&#034;Save this post to Del.icio.us&#034;&gt;&lt;img src=&#034;common/images/delicious.png&#034; alt=&#034;Add this post to Delicious&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://www.stumbleupon.com/submit?url=http://javabeans.asia/2008/05/06/bitwise_operation_in_hibernate_3.html&amp;amp;title=Bitwise operation in Hibernate 3&#034; target=&#034;_blank&#034; title=&#034;Stumble this post&#034;&gt;&lt;img src=&#034;common/images/stumbleupon.png&#034; alt=&#034;Add this post to Stumble it&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://www.google.com/bookmarks/mark?op=edit&amp;amp;bkmk=http://javabeans.asia/2008/05/06/bitwise_operation_in_hibernate_3.html&amp;amp;title=Bitwise operation in Hibernate 3&#034; target=&#034;_blank&#034; title=&#034;Add this post to Google&#034;&gt;&lt;img src=&#034;common/images/google.png&#034; alt=&#034;Add this post to Google&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://technorati.com/faves?add=http://javabeans.asia/2008/05/06/bitwise_operation_in_hibernate_3.html&#034; target=&#034;_blank&#034; title=&#034;Add this post to Technorati&#034;&gt;&lt;img src=&#034;common/images/technorati.png&#034; alt=&#034;Add this post to Technorati&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://www.bloglines.com/sub/http://javabeans.asia/2008/05/06/bitwise_operation_in_hibernate_3.html&#034; target=&#034;_blank&#034; title=&#034;Add this post to Bloglines&#034;&gt;&lt;img src=&#034;common/images/bloglines.png&#034; alt=&#034;Add this post to Bloglines&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://www.facebook.com/share.php?u=http://javabeans.asia/2008/05/06/bitwise_operation_in_hibernate_3.html&#034; target=&#034;_blank&#034; title=&#034;Add this post to Facebook&#034;&gt;&lt;img src=&#034;common/images/facebook.png&#034; alt=&#034;Add this post to Facebook&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://www.furl.net/storeIt.jsp?u=http://javabeans.asia/2008/05/06/bitwise_operation_in_hibernate_3.html&amp;amp;t=Bitwise operation in Hibernate 3&#034; target=&#034;_blank&#034; title=&#034;Add this post to Furl&#034;&gt;&lt;img src=&#034;common/images/furl.png&#034; alt=&#034;Add this post to Furl&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;https://favorites.live.com/quickadd.aspx?mkt=en-us&amp;amp;url=http://javabeans.asia/2008/05/06/bitwise_operation_in_hibernate_3.html&amp;amp;title=Bitwise operation in Hibernate 3&#034; target=&#034;_blank&#034; title=&#034;Add this post to Windows Live&#034;&gt;&lt;img src=&#034;common/images/windowslive.png&#034; alt=&#034;Add this post to Windows Live&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://bookmarks.yahoo.com/toolbar/savebm?opener=tb&amp;amp;u=http://javabeans.asia/2008/05/06/bitwise_operation_in_hibernate_3.html&amp;amp;t=Bitwise operation in Hibernate 3&#034; target=&#034;_blank&#034; title=&#034;Add this post to Yahoo!&#034;&gt;&lt;img src=&#034;common/images/yahoo.png&#034; alt=&#034;Add this post to Yahoo!&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&lt;/div&gt;</description>
      
	-->
    <category>java</category>
    <category>hibernate</category>
    <comments>http://javabeans.asia/2008/05/06/bitwise_operation_in_hibernate_3.html#comments</comments>
    <guid isPermaLink="true">http://javabeans.asia/2008/05/06/bitwise_operation_in_hibernate_3.html</guid>
    <pubDate>Tue, 06 May 2008 12:40:43 GMT</pubDate>
  </item>
  </channel>
</rss>
