<?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>Blog::Log &#187; java</title>
	<atom:link href="http://www.stpe.se/tag/java/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.stpe.se</link>
	<description>Not a blog, more a log.</description>
	<lastBuildDate>Wed, 02 Jun 2010 13:01:58 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Hibernate Annotations examples and reference</title>
		<link>http://www.stpe.se/2008/07/hibernate-annotations-examples-and-reference/</link>
		<comments>http://www.stpe.se/2008/07/hibernate-annotations-examples-and-reference/#comments</comments>
		<pubDate>Tue, 22 Jul 2008 18:08:00 +0000</pubDate>
		<dc:creator>stefan</dc:creator>
				<category><![CDATA[coding]]></category>
		<category><![CDATA[hibernate]]></category>
		<category><![CDATA[java]]></category>

		<guid isPermaLink="false">http://www.stpe.se/?p=46</guid>
		<description><![CDATA[Found a really great reference with examples of Hibernate association mappings using annotations. http://tadtech.blogspot.com/2007/09/hibernate-association-mappings-in.html]]></description>
			<content:encoded><![CDATA[<p>Found a really great reference with examples of Hibernate association mappings using annotations.</p>
<p><a href="http://tadtech.blogspot.com/2007/09/hibernate-association-mappings-in.html">http://tadtech.blogspot.com/2007/09/hibernate-association-mappings-in.html</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.stpe.se/2008/07/hibernate-annotations-examples-and-reference/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Hibernate HQL like query using named parameters</title>
		<link>http://www.stpe.se/2008/07/hibernate-hql-like-query-named-parameters/</link>
		<comments>http://www.stpe.se/2008/07/hibernate-hql-like-query-named-parameters/#comments</comments>
		<pubDate>Thu, 03 Jul 2008 09:03:42 +0000</pubDate>
		<dc:creator>stefan</dc:creator>
				<category><![CDATA[coding]]></category>
		<category><![CDATA[hibernate]]></category>
		<category><![CDATA[hql]]></category>
		<category><![CDATA[java]]></category>

		<guid isPermaLink="false">http://www.stpe.se/?p=23</guid>
		<description><![CDATA[Using the LIKE condition with a &#8220;%&#8221; sign for pattern matching in a HQL query with named parameters required some tweaking. This did not work: String query = &#34;from user u where u.name like %:name%&#34; getHibernateTemplate().findByNamedParam(query, &#34;name&#34;, str); It resulted in a org.hibernate.QueryException: unexpected char: &#8216;%&#8217; error. Next I tried using single quotes: String query [...]]]></description>
			<content:encoded><![CDATA[<p>Using the LIKE condition with a &#8220;%&#8221; sign for pattern matching in a HQL query with named parameters required some tweaking.</p>
<p>This did not work:</p>
<pre class="brush: java;">
String query = &quot;from user u where u.name like %:name%&quot;

getHibernateTemplate().findByNamedParam(query, &quot;name&quot;, str);
</pre>
<p>It resulted in a <em>org.hibernate.QueryException: unexpected char: &#8216;%&#8217;</em> error.</p>
<p>Next I tried using single quotes:</p>
<pre class="brush: java;">
String query = &quot;from user u where u.name like '%:name%'&quot;

getHibernateTemplate().findByNamedParam(query, &quot;name&quot;, str);
</pre>
<p>Didn&#8217;t work either, an <em>org.hibernate.QueryParameterException: could not locate named parameter</em>.</p>
<p>What actually worked was putting the &#8220;%&#8221; signs in the parameter:</p>
<pre class="brush: java;">
String query = &quot;from user u where u.name like :name&quot;

getHibernateTemplate().findByNamedParam(query, &quot;name&quot;, '%' + str + '%');
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.stpe.se/2008/07/hibernate-hql-like-query-named-parameters/feed/</wfw:commentRss>
		<slash:comments>29</slash:comments>
		</item>
		<item>
		<title>I18n workaround for Spring form:options tag</title>
		<link>http://www.stpe.se/2008/07/i18n-workaround-for-spring-formoptions-tag/</link>
		<comments>http://www.stpe.se/2008/07/i18n-workaround-for-spring-formoptions-tag/#comments</comments>
		<pubDate>Tue, 01 Jul 2008 04:53:28 +0000</pubDate>
		<dc:creator>stefan</dc:creator>
				<category><![CDATA[coding]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[spring]]></category>

		<guid isPermaLink="false">http://www.stpe.se/?p=22</guid>
		<description><![CDATA[Spring Framework provides the convenient form:options tag to render a list of &#60;option&#62; tags for a form &#60;select&#62;. Here is an example: &#60;form:select id=&#34;status&#34; path=&#34;status&#34; cssClass=&#34;text large&#34; cssErrorClass=&#34;text large error&#34; &#62; &#60;form:options items=&#34;${statusList}&#34; itemValue=&#34;id&#34; itemLabel=&#34;label&#34;&#62;&#60;/form:options&#62; &#60;/form:select&#62; It does iteratate through statusList and will output each item as an option with the value statusList[i].id and the [...]]]></description>
			<content:encoded><![CDATA[<p>Spring Framework provides the convenient <a href="http://static.springframework.org/spring/docs/2.5.x/reference/spring-form.tld.html#spring-form.tld.options">form:options</a> tag to render a list of &lt;option&gt; tags for a form &lt;select&gt;. Here is an example:</p>
<pre class="brush: java;">
&lt;form:select id=&quot;status&quot; path=&quot;status&quot; cssClass=&quot;text large&quot; cssErrorClass=&quot;text large error&quot; &gt;
    &lt;form:options items=&quot;${statusList}&quot; itemValue=&quot;id&quot; itemLabel=&quot;label&quot;&gt;&lt;/form:options&gt;
&lt;/form:select&gt;
</pre>
<p>It does iteratate through <strong>statusList</strong> and will output each item as an option with the value <strong>statusList[i].id</strong> and the text <strong>statusList[i].label</strong> and automatically make the option corresponding to <strong>status</strong> selected.</p>
<p>Unfortunately form:options does not support i18n (internationalization), which make it in some cases rather worthless. I18n support is <a href="http://jira.springframework.org/browse/SPR-2659">currently scheduled</a> for inclusion in 3.0 M1.</p>
<p>To support internationalization we have to do a workaround that is somewhat more clunky:</p>
<pre class="brush: java;">
&lt;select id=&quot;status&quot; name=&quot;status&quot; class=&quot;text large&quot;&gt;
  &lt;c:set var=&quot;currentStatus&quot;&gt;${currentStatus}&lt;/c:set&gt;
  &lt;c:forEach var=&quot;status&quot; items=&quot;${statusList}&quot;&gt;
    &lt;c:choose&gt;
      &lt;c:when test=&quot;${status == currentStatus}&quot;&gt;
        &lt;option value=&quot;${status.id}&quot; selected&gt;&lt;fmt:message key=&quot;status.${status.label}&quot;/&gt;&lt;/option&gt;
      &lt;/c:when&gt;
      &lt;c:otherwise&gt;
        &lt;option value=&quot;${status.id}&quot;&gt;&lt;fmt:message key=&quot;status.${status.label} quot;/&gt;&lt;/option&gt;
      &lt;/c:otherwise&gt;
    &lt;/c:choose&gt;
  &lt;/c:forEach&gt;
&lt;/select&gt;
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.stpe.se/2008/07/i18n-workaround-for-spring-formoptions-tag/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
