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

<channel>
	<title>Java, Programming, Struts2, jQuery, Linux and more &#187; hibernate</title>
	<atom:link href="http://www.jgeppert.com/category/java/hibernate/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.jgeppert.com</link>
	<description>Johannes Geppert</description>
	<lastBuildDate>Thu, 09 Feb 2012 16:38:30 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=</generator>
		<item>
		<title>New Showcase for the jqGrid feature in Struts2 jQuery Plugin is available</title>
		<link>http://www.jgeppert.com/2010/01/new-showcase-for-the-jqgrid-feature-in-struts2-jquery-plugin-is-available/</link>
		<comments>http://www.jgeppert.com/2010/01/new-showcase-for-the-jqgrid-feature-in-struts2-jquery-plugin-is-available/#comments</comments>
		<pubDate>Tue, 26 Jan 2010 09:02:08 +0000</pubDate>
		<dc:creator>jogep</dc:creator>
				<category><![CDATA[hibernate]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[Struts jQuery Plugin]]></category>
		<category><![CDATA[struts2]]></category>
		<category><![CDATA[jqgrid]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[showcase]]></category>

		<guid isPermaLink="false">http://www.jgeppert.com/?p=351</guid>
		<description><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://www.jgeppert.com/2010/01/new-showcase-for-the-jqgrid-feature-in-struts2-jquery-plugin-is-available/' addthis:title='New Showcase for the jqGrid feature in Struts2 jQuery Plugin is available '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_counter addthis_pill_style"></a></div>Since today the new Showcase is available. The new Showcase is specially for the jqGrid based Grid Feature. <div class="addthis_toolbox addthis_default_style addthis_32x32_style" addthis:url='http://www.jgeppert.com/2010/01/new-showcase-for-the-jqgrid-feature-in-struts2-jquery-plugin-is-available/' addthis:title='New Showcase for the jqGrid feature in Struts2 jQuery Plugin is available ' ><a class="addthis_button_preferred_1"></a><a class="addthis_button_preferred_2"></a><a class="addthis_button_preferred_3"></a><a class="addthis_button_preferred_4"></a><a class="addthis_button_compact"></a></div>]]></description>
			<content:encoded><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://www.jgeppert.com/2010/01/new-showcase-for-the-jqgrid-feature-in-struts2-jquery-plugin-is-available/' addthis:title='New Showcase for the jqGrid feature in Struts2 jQuery Plugin is available '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_counter addthis_pill_style"></a></div>Since today  the new Showcase is available. The new Showcase is specially for the <a href="http://www.trirand.com/blog/">jqGrid</a> based Grid Feature.

The Showcase is provided with the <a href="http://code.google.com/p/full-hibernate-plugin-for-struts2/">Full Hibernate Plugin for Struts2</a> and shows how easy it is to create a AJAX based paging table in Struts2<a href="http://www.trirand.com/blog/"></a> that is  searchable, sortable and editable. Also it shows how to implement a Grid with an Subgrid.

The Showcase based on <a href="http://struts.apache.org">Struts2</a> 2.1.8.1, <a href="http://code.google.com/p/full-hibernate-plugin-for-struts2/">Full Hibernate Plugin</a> 2.1.3 GA and <a href="http://code.google.com/p/struts2-jquery/">Struts2 jQuery Plugin</a> 1.8.2.

Per default the Showcase is <strong>read-only</strong> to see how to edit, add and delete items, download the showcase and following the instructions.

Visit Showcase: <a href="http://www.weinfreund.de/struts2-jquery-grid-showcase/">http://www.weinfreund.de/struts2-jquery-grid-showcase/</a>
Download Showcase: <a href="http://code.google.com/p/struts2-jquery/downloads/list">http://code.google.com/p/struts2-jquery/downloads/list</a><div class="addthis_toolbox addthis_default_style addthis_32x32_style" addthis:url='http://www.jgeppert.com/2010/01/new-showcase-for-the-jqgrid-feature-in-struts2-jquery-plugin-is-available/' addthis:title='New Showcase for the jqGrid feature in Struts2 jQuery Plugin is available ' ><a class="addthis_button_preferred_1"></a><a class="addthis_button_preferred_2"></a><a class="addthis_button_preferred_3"></a><a class="addthis_button_preferred_4"></a><a class="addthis_button_compact"></a></div>]]></content:encoded>
			<wfw:commentRss>http://www.jgeppert.com/2010/01/new-showcase-for-the-jqgrid-feature-in-struts2-jquery-plugin-is-available/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>In Hibernate mit OneToMany Beziehungen arbeiten</title>
		<link>http://www.jgeppert.com/2008/07/in-hibernate-mit-onetomany-beziehungen-arbeiten/</link>
		<comments>http://www.jgeppert.com/2008/07/in-hibernate-mit-onetomany-beziehungen-arbeiten/#comments</comments>
		<pubDate>Mon, 28 Jul 2008 09:01:40 +0000</pubDate>
		<dc:creator>jogep</dc:creator>
				<category><![CDATA[hibernate]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[spring]]></category>
		<category><![CDATA[annotions]]></category>
		<category><![CDATA[count]]></category>
		<category><![CDATA[hql]]></category>
		<category><![CDATA[jpa]]></category>
		<category><![CDATA[persistence]]></category>
		<category><![CDATA[set]]></category>
		<category><![CDATA[size]]></category>

		<guid isPermaLink="false">http://www.jgeppert.com/?p=134</guid>
		<description><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://www.jgeppert.com/2008/07/in-hibernate-mit-onetomany-beziehungen-arbeiten/' addthis:title='In Hibernate mit OneToMany Beziehungen arbeiten '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_counter addthis_pill_style"></a></div>Bei einer Java Anwendung die mit Hibernate oder JPA als Persistence Framework arbeitet, kann es vorkommen das man alle Objekte mit HQL ermitteln will deren OneToMany Beziehungen eine bestimmte Größe haben oder mehr als null Elemente beinhalten. Eine Beispiel Definition unserer Klassen könnte in etwa so aussehen. MyObject: @Entity @Table&#40;name = &#34;my_object&#34;, schema = &#34;public&#34;&#41; [...]<div class="addthis_toolbox addthis_default_style addthis_32x32_style" addthis:url='http://www.jgeppert.com/2008/07/in-hibernate-mit-onetomany-beziehungen-arbeiten/' addthis:title='In Hibernate mit OneToMany Beziehungen arbeiten ' ><a class="addthis_button_preferred_1"></a><a class="addthis_button_preferred_2"></a><a class="addthis_button_preferred_3"></a><a class="addthis_button_preferred_4"></a><a class="addthis_button_compact"></a></div>]]></description>
			<content:encoded><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://www.jgeppert.com/2008/07/in-hibernate-mit-onetomany-beziehungen-arbeiten/' addthis:title='In Hibernate mit OneToMany Beziehungen arbeiten '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_counter addthis_pill_style"></a></div>Bei einer Java Anwendung die mit Hibernate oder JPA als Persistence Framework arbeitet, kann es vorkommen das man alle Objekte mit HQL ermitteln will deren OneToMany Beziehungen eine bestimmte Größe haben oder mehr als null Elemente beinhalten.

Eine Beispiel Definition unserer Klassen könnte in etwa so aussehen.
MyObject:


<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;">@<span style="color: #003399;">Entity</span>
@Table<span style="color: #009900;">&#40;</span>name <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;my_object&quot;</span>, schema <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;public&quot;</span><span style="color: #009900;">&#41;</span>
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> MyObject <span style="color: #000000; font-weight: bold;">implements</span> java.<span style="color: #006633;">io</span>.<span style="color: #003399;">Serializable</span>
<span style="color: #009900;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">private</span> Set<span style="color: #339933;">&lt;</span>mysubobject<span style="color: #339933;">&gt;</span>  subObjects <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> HashSet<span style="color: #339933;">&lt;/</span>mysubobject<span style="color: #339933;">&gt;&lt;</span>mysubobject<span style="color: #339933;">&gt;</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
  @OneToMany<span style="color: #009900;">&#40;</span>cascade <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span> CascadeType.<span style="color: #006633;">ALL</span> <span style="color: #009900;">&#125;</span>, fetch <span style="color: #339933;">=</span> FetchType.<span style="color: #006633;">LAZY</span>, mappedBy <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;myobject&quot;</span><span style="color: #009900;">&#41;</span>
  <span style="color: #000000; font-weight: bold;">public</span> Set<span style="color: #339933;">&lt;/</span>mysubobject<span style="color: #339933;">&gt;&lt;</span>mysubobject<span style="color: #339933;">&gt;</span> getSubObjects<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
  <span style="color: #009900;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">subObjects</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #339933;">&lt;/</span>mysubobject<span style="color: #339933;">&gt;</span></pre></div></div>



MySubObject:


<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;">@<span style="color: #003399;">Entity</span>
@Table<span style="color: #009900;">&#40;</span>name <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;my_sub_object&quot;</span>, schema <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;public&quot;</span><span style="color: #009900;">&#41;</span>
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> MySubObject <span style="color: #000000; font-weight: bold;">implements</span> java.<span style="color: #006633;">io</span>.<span style="color: #003399;">Serializable</span>
<span style="color: #009900;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">private</span> MyObject myObject<span style="color: #339933;">;</span>
&nbsp;
  @ManyToOne<span style="color: #009900;">&#40;</span>cascade <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span><span style="color: #009900;">&#125;</span>, fetch <span style="color: #339933;">=</span> FetchType.<span style="color: #006633;">LAZY</span><span style="color: #009900;">&#41;</span>
  @JoinColumn<span style="color: #009900;">&#40;</span>name <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;myobject&quot;</span>, unique <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span>
  <span style="color: #000000; font-weight: bold;">public</span> MyObject getMyObject<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
  <span style="color: #009900;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">myObject</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>



Nach dem wir unsere Klassen mit Annotations oder auch XML definiert haben können wir jetzt in unserem DAO Objekt mit folgenden HQL Befehl alle Objekte von der Datenbank anfordern die mindestens ein Element im Set subObjects haben.


<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">public</span> List<span style="color: #339933;">&lt;</span>myobject<span style="color: #339933;">&gt;</span> findAllWithElements<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">try</span>
  <span style="color: #009900;">&#123;</span>
    <span style="color: #003399;">String</span> queryString <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;select model from MyObject model where size(subObjects ) &gt; 0&quot;</span><span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">return</span> getHibernateTemplate<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">find</span><span style="color: #009900;">&#40;</span>queryString<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
  <span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #009900;">&#40;</span><span style="color: #003399;">RuntimeException</span> re<span style="color: #009900;">&#41;</span>
  <span style="color: #009900;">&#123;</span>
    log.<span style="color: #006633;">error</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;find all with elements failed&quot;</span>, re<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">throw</span> re<span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #339933;">&lt;/</span>myobject<span style="color: #339933;">&gt;</span></pre></div></div>


<div class="addthis_toolbox addthis_default_style addthis_32x32_style" addthis:url='http://www.jgeppert.com/2008/07/in-hibernate-mit-onetomany-beziehungen-arbeiten/' addthis:title='In Hibernate mit OneToMany Beziehungen arbeiten ' ><a class="addthis_button_preferred_1"></a><a class="addthis_button_preferred_2"></a><a class="addthis_button_preferred_3"></a><a class="addthis_button_preferred_4"></a><a class="addthis_button_compact"></a></div>]]></content:encoded>
			<wfw:commentRss>http://www.jgeppert.com/2008/07/in-hibernate-mit-onetomany-beziehungen-arbeiten/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

