<?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>Unnecessary Thoughts</title>
	<atom:link href="http://blog.sigmaprojects.org/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.sigmaprojects.org</link>
	<description>Trying to stop over engineering</description>
	<lastBuildDate>Sun, 12 Feb 2012 05:33:17 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>ImageInfo</title>
		<link>http://blog.sigmaprojects.org/imageinfo/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=imageinfo</link>
		<comments>http://blog.sigmaprojects.org/imageinfo/#comments</comments>
		<pubDate>Sun, 12 Feb 2012 05:33:17 +0000</pubDate>
		<dc:creator>Don Quist</dc:creator>
				<category><![CDATA[ColdFusion]]></category>
		<category><![CDATA[Hibernate]]></category>

		<guid isPermaLink="false">http://blog.sigmaprojects.org/?p=83</guid>
		<description><![CDATA[2 Super basic entities for image info, width, height, size, color model and such, over at https://github.com/sigmaprojects/cf-imageinfo. Below is is a simple demo &#8211; 1: Get the file info 2: get the image info 3: Blend 4: Throw 5: Done]]></description>
			<content:encoded><![CDATA[<p>2 Super basic entities for image info, width, height, size, color model and such, over at <a title="https://github.com/sigmaprojects/cf-imageinfo" href="https://github.com/sigmaprojects/cf-imageinfo" target="_blank">https://github.com/sigmaprojects/cf-imageinfo</a>.<br />
Below is is a simple demo &#8211;<br />
1: Get the file info<br />
2: get the image info<br />
3: Blend<br />
4: Throw<br />
5: Done</p>
<pre class="brush: coldfusion; title: ; notranslate">
var fileInfo = GetFileInfo( imageFilePath );
var imgInfo = ImageInfo(imageRead(imageFilePath));&lt;/code&gt;

var allData = {};
structAppend(allData,fileInfo,true);
structAppend(allData,imgInfo,true);

var ImageInfo = new model.imageinfo(
   argumentCollection=allData
);

EntitySave(ImageInfo);
</pre>
]]></content:encoded>
			<wfw:commentRss>http://blog.sigmaprojects.org/imageinfo/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Example Flickr API with oAuth in ColdFusion</title>
		<link>http://blog.sigmaprojects.org/example-flickr-api-with-oauth-in-coldfusion/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=example-flickr-api-with-oauth-in-coldfusion</link>
		<comments>http://blog.sigmaprojects.org/example-flickr-api-with-oauth-in-coldfusion/#comments</comments>
		<pubDate>Sat, 03 Dec 2011 04:45:22 +0000</pubDate>
		<dc:creator>Don Quist</dc:creator>
				<category><![CDATA[ColdFusion]]></category>

		<guid isPermaLink="false">http://blog.sigmaprojects.org/?p=74</guid>
		<description><![CDATA[Just thought I would share how I implemented a (for now) a very simple Flickr API in ColdFusion, using the oAuth library from http://oauth.riaforge.org/. If you have ever worked oAuth before, you know it can be somewhat frustrating at first, &#8230;<p class="read-more"><a href="http://blog.sigmaprojects.org/example-flickr-api-with-oauth-in-coldfusion/">Read more &#187;</a></p>]]></description>
			<content:encoded><![CDATA[<p>Just thought I would share how I implemented a (for now) a very simple Flickr API in ColdFusion, using the oAuth library from <a href="http://oauth.riaforge.org/" target="_blank">http://oauth.riaforge.org/</a>.<span id="more-74"></span></p>
<p>If you have ever worked oAuth before, you know it can be somewhat frustrating at first, even if you know the &#8216;oAuth dance&#8217;.  You can look at the steps over <a href="http://www.flickr.com/services/api/auth.oauth.html" target="_blank">here</a>.  Below is how I see it happening from the consumer point of view (my basic understanding)&#8230;<br />
1) Hey Flickr, I&#8217;m going to need you to ask a user to authorize my app. [ Get Request Tokens ]<br />
2) Hi User, Flickr needs to make sure this is okay with you, go talk to them.  [ Send User to Flickr ]<br />
3) User is sent to Flickr and authorizes my app.<br />
4) Welcome back User [ get Verifier key ]<br />
5) Hey Flickr, that was easy, can I exchange these Request Tokens and Verifier key for Access Tokens for this user?  [ Get Access Tokens ]</p>
<p>Sounds simple, until you get into the nitty gritty of signatures, timestamps, parameters, and whatever the heck a nonce is.  Thankfully the oAuth library from <a href="http://oauth.riaforge.org/" target="_blank">Harry Klein</a> makes most of this super simple.</p>
<p>Below are two events in my Coldbox handler, and attached is the FlickrService that gets called.</p>
<p>When the Confirm event is called, it will store the http referrer where the request came from in the session, so we can send the user back there once we&#8217;ve been authorized by the user and flickr.  Then it calls the FlickrService to setup some request tokens and store them in the session as well.  Lastly it asks the FlickrService to construct the Flickr Authorize URL and redirects the user there.</p>
<p>Once the user authorizes and Flickr sends them back to me, we tell the FlickrService to make a call to Flickr to exchange the Request Tokens for Access Tokens using the stored session variables and the oauth_verifier key that came back along with the user.  Once we have the Access Tokens, we just store them in the user model for future use.  Once that&#8217;s done, send the user back to the page where they came from to begin with. (The referrer stored in the session earlier)<br />
[The Redirect event being the callback URL configured in the Flickr App settings]</p>
<pre class="brush: coldfusion; title: ; notranslate">
public void function confirm(Required Event) {
var rc = Event.getCollection();
var prc = Event.getCollection( private=true );
var referrer = &quot;http://#cgi.server_name##cgi.path_info#&quot;;
SessionStorage.setVar('flickr_referrer', referrer );

var tokens = FlickrService.getRequestTokens();

SessionStorage.setVar('flickr_client_token', tokens.oauth_token );
SessionStorage.setVar('flickr_client_token_secret', tokens.oauth_token_secret );

var sAuthURL = FlickrService.getFlickrAuthorizeURL( tokens.oauth_token, tokens.oauth_token_secret );

location(sAuthURL,false);

Event.noRender();
}

public void function Redirect(Required Event) {
var rc = Event.getCollection();
var prc = Event.getCollection( private=true );
var referrer = SessionStorage.getVar('flickr_referrer','');
SessionStorage.deleteVar('flickr_referrer');

var Tokens = FlickrService.getAccessTokens( rc.oauth_verifier, SessionStorage.getVar('flickr_client_token'), SessionStorage.getVar('flickr_client_token_secret') );

FlickrService.linkFlickrAccount( prc.current_user, tokens.user_nsid, tokens.username, tokens.oauth_token, tokens.oauth_token_secret );

if(len(trim(referrer))) {
location(referrer, false);
} else {
setNextEvent('General.index');
}
Event.noRender();
}
</pre>
<p>Here is the <a href="http://blog.sigmaprojects.org/wp-content/uploads/2011/12/flickr.txt" target="_blank">FlickrService component</a>.  Though in my example we&#8217;re passing a User object around, you can easily change this to a struct, strings, whatever you may prefer.  The basic idea is to always pass the users Access Tokens, and some other minor things like the users Flickr user id (nsid).</p>
<p>Questions / Comments are welcome.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.sigmaprojects.org/example-flickr-api-with-oauth-in-coldfusion/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Migration to WordPress Complete</title>
		<link>http://blog.sigmaprojects.org/migration-to-wordpress-complete/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=migration-to-wordpress-complete</link>
		<comments>http://blog.sigmaprojects.org/migration-to-wordpress-complete/#comments</comments>
		<pubDate>Sat, 19 Nov 2011 06:58:00 +0000</pubDate>
		<dc:creator>Don Quist</dc:creator>
				<category><![CDATA[Projects]]></category>

		<guid isPermaLink="false">http://wordpress.sigmaprojects.org/?p=54</guid>
		<description><![CDATA[Just migrated my blog to wordpress &#8211; actually using the &#8216;WordPress Appliance&#8217; from http://www.turnkeylinux.org/wordpress.  Didn&#8217;t come without a hiccup or two, especially when I tried to migrate the database to another server and change the table prefix. Now I just &#8230;<p class="read-more"><a href="http://blog.sigmaprojects.org/migration-to-wordpress-complete/">Read more &#187;</a></p>]]></description>
			<content:encoded><![CDATA[<p>Just migrated my blog to wordpress &#8211; actually using the &#8216;WordPress Appliance&#8217; from <a title="Turnkey Linux" href="http://www.turnkeylinux.org/wordpress" target="_blank">http://www.turnkeylinux.org/wordpress</a>.  Didn&#8217;t come without a hiccup or two, especially when I tried to migrate the database to another server and change the table prefix.</p>
<p>Now I just have to rinse &amp; repeat for the other blogs we host.  Sorry MangoBlog &#8211; Just not enough of a theme selection.. and really, that&#8217;s the only reason.</p>
<p>*Edit*<br />
Sorry to Ray and everyone that reads <a href="http://www.coldfusionbloggers.org/">http://www.coldfusionbloggers.org/</a>.  It seems a few of my entries got reposted.</p>
<p>On a side-note, here&#8217;s my url rewrite rules to act like MangoBlog (just added two).  The Permalink setting is just /%postname%.</p>
<pre class="brush: plain; title: ; notranslate">
RewriteEngine On
RewriteBase /
RewriteRule ^feeds/rss.cfm$ /feed/ [NC,L,R]
RewriteRule ^index\.php$ - [L]
RewriteRule ^post\.cfm$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</pre>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.sigmaprojects.org/migration-to-wordpress-complete/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Natural Language Date Parser updated</title>
		<link>http://blog.sigmaprojects.org/natural-language-date-parser-updated/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=natural-language-date-parser-updated</link>
		<comments>http://blog.sigmaprojects.org/natural-language-date-parser-updated/#comments</comments>
		<pubDate>Mon, 14 Nov 2011 06:53:29 +0000</pubDate>
		<dc:creator>Don Quist</dc:creator>
				<category><![CDATA[ColdFusion]]></category>
		<category><![CDATA[Projects]]></category>

		<guid isPermaLink="false">http://wordpress.sigmaprojects.org/?p=52</guid>
		<description><![CDATA[Just wanted to note a small update to CF-NLDate https://github.com/sigmaprojects/CF-NLDate. Added support for strings like &#8220;last march&#8221;, &#8220;a few days ago&#8221;, &#8220;a couple weeks ago&#8221;, etc. *Edit* Also, included a test.cfm page showing example strings.]]></description>
			<content:encoded><![CDATA[<p>Just wanted to note a small update to CF-NLDate <a href="https://github.com/sigmaprojects/CF-NLDate" target="_blank">https://github.com/sigmaprojects/CF-NLDate</a>.</p>
<p>Added support for strings like &#8220;last march&#8221;, &#8220;a few days ago&#8221;, &#8220;a couple weeks ago&#8221;, etc.</p>
<p><strong>*Edit*<br />
</strong>Also, included a test.cfm page showing example strings.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.sigmaprojects.org/natural-language-date-parser-updated/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Natural Language Date Parser</title>
		<link>http://blog.sigmaprojects.org/natural-language-date-parser/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=natural-language-date-parser</link>
		<comments>http://blog.sigmaprojects.org/natural-language-date-parser/#comments</comments>
		<pubDate>Fri, 11 Nov 2011 06:52:54 +0000</pubDate>
		<dc:creator>Don Quist</dc:creator>
				<category><![CDATA[ColdFusion]]></category>
		<category><![CDATA[Projects]]></category>

		<guid isPermaLink="false">http://wordpress.sigmaprojects.org/?p=50</guid>
		<description><![CDATA[Came across a situation where I needed to parse strings as dates, string likes &#8220;yesterday&#8221; &#8220;last week&#8221; and so on. First thought was to find an existing CF method for this, didn&#8217;t exist.  Next was to find a Java class&#8230; &#8230;<p class="read-more"><a href="http://blog.sigmaprojects.org/natural-language-date-parser/">Read more &#187;</a></p>]]></description>
			<content:encoded><![CDATA[<p>Came across a situation where I needed to parse strings as dates, string likes &#8220;yesterday&#8221; &#8220;last week&#8221; and so on.</p>
<p>First thought was to find an existing CF method for this, didn&#8217;t exist.  Next was to find a Java class&#8230; a couple exist, <a href="http://natty.joestelmach.com/" target="_blank">Natty</a> which seems awesome, but relies too heavily on ANTLR, then there&#8217;s <a href="https://github.com/samtingleff/jchronic" target="_blank">JChronic</a>.  Both seemed great, but a little overkill.  Next was to find a JS version, but then I remembered how annoying it was to run server-side javascript using Rhino.</p>
<p>So, I took an hour or two to write this up: <a href="https://github.com/sigmaprojects/CF-NLDate" target="_blank">https://github.com/sigmaprojects/CF-NLDate</a></p>
<p>At the moment, it&#8217;ll accept things like &#8220;(Number or Text) (Day,Week,Month,Quarter,Year) ago&#8221; [3 days ago], &#8220;last week&#8221; &#8220;last month&#8221; &#8220;yesterday&#8221; and a few more ways.  Very simple, still needs expanding for &#8220;a couple weeks ago&#8221; / &#8220;a week ago&#8221; etc, but for now it works great on simple things, it needs a lil work to make it more versatile.</p>
<p>Enjoy.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.sigmaprojects.org/natural-language-date-parser/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Our server has finally been built.</title>
		<link>http://blog.sigmaprojects.org/our-server-has-finally-been-built/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=our-server-has-finally-been-built</link>
		<comments>http://blog.sigmaprojects.org/our-server-has-finally-been-built/#comments</comments>
		<pubDate>Wed, 19 Oct 2011 06:52:24 +0000</pubDate>
		<dc:creator>Don Quist</dc:creator>
				<category><![CDATA[Projects]]></category>

		<guid isPermaLink="false">http://wordpress.sigmaprojects.org/?p=48</guid>
		<description><![CDATA[It took a long time, it came with a few hiccups, it also came with a couple injuries.  But it&#8217;s finally finished, our new VM host.]]></description>
			<content:encoded><![CDATA[<p>It took a long time, it came with a few hiccups, it also came with a couple injuries.  But it&#8217;s finally finished, our new <a href="http://sigmaprojects.org/projects/view/New-Server-Build">VM host</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.sigmaprojects.org/our-server-has-finally-been-built/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>BaseORMService &#8211; Hibernate Criteria for &#8220;property not in&#8221;</title>
		<link>http://blog.sigmaprojects.org/baseormservice-hibernate-criteria-for-property-not-in/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=baseormservice-hibernate-criteria-for-property-not-in</link>
		<comments>http://blog.sigmaprojects.org/baseormservice-hibernate-criteria-for-property-not-in/#comments</comments>
		<pubDate>Sat, 15 Oct 2011 06:50:38 +0000</pubDate>
		<dc:creator>Don Quist</dc:creator>
				<category><![CDATA[ColdBox]]></category>
		<category><![CDATA[ColdFusion]]></category>
		<category><![CDATA[Hibernate]]></category>

		<guid isPermaLink="false">http://wordpress.sigmaprojects.org/?p=46</guid>
		<description><![CDATA[Just a little note for anyone else interested. To filter properties that are *not* in an array (i.e. don&#8217;t select from entity if foo is in bar) this is how its done in hibernate: And because ColdBox&#8217;s BaseORMService just proxies &#8230;<p class="read-more"><a href="http://blog.sigmaprojects.org/baseormservice-hibernate-criteria-for-property-not-in/">Read more &#187;</a></p>]]></description>
			<content:encoded><![CDATA[<p>Just a little note for anyone else interested.   To filter properties that are *not* in an array (i.e. don&#8217;t select from entity if foo is in bar) this is how its done in hibernate:</p>
<pre class="brush: coldfusion; title: ; notranslate">
criteria.add(
  Restrictions.not(
    Restrictions.in(&quot;id&quot;, new long[] {2, 3})
  )
);
</pre>
<p>And because ColdBox&#8217;s BaseORMService just proxies out to the hibernate Restrictions class, it&#8217;s easily accomplished in CB: (Showing as-is for my purposes)</p>
<pre class="brush: coldfusion; title: ; notranslate">
ArrayAppend(
    Criteria,
    Restrictions.not(
        Restrictions.in('user_id', JavaCast(&quot;java.lang.Integer[]&quot;, blocked_users ) )
    )
);
</pre>
<p>Just be careful to check that your filter is not an empty array, otherwise Hibernate will complain about &#8216;()&#8217; being bad sql grammar.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.sigmaprojects.org/baseormservice-hibernate-criteria-for-property-not-in/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Talk Bubbles in CSS</title>
		<link>http://blog.sigmaprojects.org/talk-bubbles-in-css/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=talk-bubbles-in-css</link>
		<comments>http://blog.sigmaprojects.org/talk-bubbles-in-css/#comments</comments>
		<pubDate>Sat, 24 Sep 2011 06:47:30 +0000</pubDate>
		<dc:creator>Don Quist</dc:creator>
				<category><![CDATA[ColdBox]]></category>
		<category><![CDATA[ColdFusion]]></category>

		<guid isPermaLink="false">http://wordpress.sigmaprojects.org/?p=43</guid>
		<description><![CDATA[Had to come up with some sort of chat / talk bubbles for messages back &#38; forth.  This isn&#8217;t a new idea, I&#8217;ve seen this style around quite a bit but never paid much attention to it.   My most recent &#8230;<p class="read-more"><a href="http://blog.sigmaprojects.org/talk-bubbles-in-css/">Read more &#187;</a></p>]]></description>
			<content:encoded><![CDATA[<p>Had to come up with some sort of chat / talk bubbles for messages back &amp; forth.  This isn&#8217;t a new idea, I&#8217;ve seen this style around quite a bit but never paid much attention to it.   My most recent exposure was from Backyard Monsters, a game on facebook that uses it for its messaging layout.  I figured it could be done in pure CSS without too much trouble if it hasn&#8217;t already.  With a quick search I found two, but they were both slightly lacking&#8230;</p>
<p>First was a post from <a href="http://nicolasgallagher.com/pure-css-speech-bubbles/" target="_blank">Nicolas Gallagher</a>, which gave me a great start.  Showing how to overlay two side borders, a larger, dark backdrop then a slightly smaller light overlay for the triangle.  But these had huge borders, and when they were shrunk down they became pixelated and looked different in the different browsers FF / IE / Safari / Chrome.</p>
<p>The second was from a great resource, <a href="http://css-tricks.com/examples/ShapesOfCSS/" target="_blank">The Shapes of CSS</a>.  This was a slimmed down version, but lacked any kind of separate border color.</p>
<p>After smashing both together and some fiddling around, I was able to come up with this solution which looks great in Firefox, Safari, <em>and </em>Internet Explorer.. Unfortunately Chrome completely freaked out when it came to the border style &#8216;dashed&#8217; (for reasons completely unknown, check my <a href="http://jsfiddle.net/XMPzJ/2/" target="_blank">jsfiddle in Chrome</a> to check it out, includes a &#8216;workaround&#8217;).</p>
<p>Here&#8217;s a screen shot of the finished result, though I really hope it looks the same no matter what.   The css source is below and <a href="http://jsfiddle.net/a2xtz/" target="_blank">over here</a>.</p>
<p><img src="/wp-content/uploads/2011/11/talkbubble.png" alt="" width="471" height="134" /></p>
<pre class="brush: css; title: ; notranslate">
.talkbubble {
    margin: 1em 0 1.4em;
    padding: 15px;
    min-height:20px;
    background: #fff;
    position: relative;
    border: 1px solid #333333;
    -moz-border-radius:    5px;
    -webkit-border-radius: 5px;
    border-radius:         5px;
    box-shadow: 2px 2px 3px #888;
}
.talkbubble.left {
    margin-left: 76px;
}
.talkbubble.left:before {
    content:&quot;&quot;;
    position:absolute;
    right: 100%;
    top: 10px;
    width: 0px;
    height: 0px;
    border-top: 14px inset transparent;
    border-right: 20px dashed #333333;
    border-bottom: 14px inset transparent;
}
.talkbubble.left:after {
    content:&quot;&quot;;
    position:absolute;
    right: 100%;
    top: 11px;
    width: 0px;
    height: 0px;
    border-top: 13px inset transparent;
    border-right: 19px dashed #fff;
    border-bottom: 13px inset transparent;
}

.talkbubble.right {
    margin-right: 76px;
    text-align:right;
}
.talkbubble.right:before {
    content:&quot;&quot;;
    position:absolute;
    left: 100%;
    top: 10px;
    width: 0px;
    height: 0px;
    border-top: 14px inset transparent;
    border-left: 20px dashed #333333;
    border-bottom: 14px inset transparent;
}
.talkbubble.right:after {
    content:&quot;&quot;;
    position:absolute;
    left: 100%;
    top: 11px;
    width: 0px;
    height: 0px;
    border-top: 13px inset transparent;
    border-left: 19px dashed #fff;
    border-bottom: 13px inset transparent;
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://blog.sigmaprojects.org/talk-bubbles-in-css/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>New Server Build</title>
		<link>http://blog.sigmaprojects.org/new-server-build/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=new-server-build</link>
		<comments>http://blog.sigmaprojects.org/new-server-build/#comments</comments>
		<pubDate>Mon, 19 Sep 2011 06:47:11 +0000</pubDate>
		<dc:creator>Don Quist</dc:creator>
				<category><![CDATA[Projects]]></category>

		<guid isPermaLink="false">http://wordpress.sigmaprojects.org/?p=41</guid>
		<description><![CDATA[We finally decided on a parts list and ordered everything for our new small server http://www.sigmaprojects.org/projects/view/New-Server-Build.]]></description>
			<content:encoded><![CDATA[<p>We finally decided on a parts list and ordered everything for our new small server <a href="http://www.sigmaprojects.org/projects/view/New-Server-Build" target="_self">http://www.sigmaprojects.org/projects/view/New-Server-Build</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.sigmaprojects.org/new-server-build/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Hibernate Criteria Queries are your friend</title>
		<link>http://blog.sigmaprojects.org/hibernate-criteria-queries-are-your-friend/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=hibernate-criteria-queries-are-your-friend</link>
		<comments>http://blog.sigmaprojects.org/hibernate-criteria-queries-are-your-friend/#comments</comments>
		<pubDate>Fri, 16 Sep 2011 06:45:38 +0000</pubDate>
		<dc:creator>Don Quist</dc:creator>
				<category><![CDATA[ColdBox]]></category>
		<category><![CDATA[ColdFusion]]></category>
		<category><![CDATA[Hibernate]]></category>

		<guid isPermaLink="false">http://wordpress.sigmaprojects.org/?p=39</guid>
		<description><![CDATA[I was working on a project where I needed to do a search feature, I then remembered seeing this in the ColdBox docs&#8230; Wasn&#8217;t sure exactly what it was, but it looked cool, so I gave it a try, and &#8230;<p class="read-more"><a href="http://blog.sigmaprojects.org/hibernate-criteria-queries-are-your-friend/">Read more &#187;</a></p>]]></description>
			<content:encoded><![CDATA[<p>I was working on a project where I needed to do a search feature, I then remembered seeing <a href="http://wiki.coldbox.org/wiki/Extras:BaseORMService.cfm#criteriaQuery" target="_blank">this</a> in the ColdBox docs&#8230; Wasn&#8217;t sure exactly what it was, but it looked cool, so I gave it a try, and wow is it powerful.</p>
<p>Normally, I would write out some long SQL/HQL with joins, sub selects, counts anything to further expand a search and at the same time keeping performance high while interweaving if statements inside of the query itself.  But with a <a href="http://docs.jboss.org/hibernate/core/3.5/reference/en/html/querycriteria.html" target="_blank">Hibernate Criteria Query</a> it was a breeze, and the end result <strong>looks clean</strong> and it&#8217;s <em>easy to read </em>(Aside from having to sometimes JavaCast some variables).</p>
<p>If your using ColdBox, Luis has made it very easy to use this by proxying out the native classes while providing the projections, paging, sorting &amp; all that good stuff.  You should really give these a try, but please check out the latest dev version of the BaseORMService thats updated to support criteria of associated objects.</p>
<p>Otherwise, you can still do this in CF just by starting on these two.</p>
<p>Restrictions = CreateObject(&#8220;java&#8221;,&#8221;org.hibernate.criterion.Restrictions&#8221;);<br />
Criteria = ORMGetSession().createCriteria( &#8216;some_entity_name&#8217; );</p>
<p>Luis was kind enough to provide some example code, shown below.</p>
<pre class="brush: coldfusion; title: ; notranslate">
/**
* entry search returns struct with keys [entries,count]
*/
struct function search(search=&quot;&quot;,isPublished,category,author,max=0,offset=0){
    var results = {};
    // get Hibernate Restrictions class
    var restrictions = getRestrictions();
    // criteria queries
    var criteria = [];
    // isPublished filter
    if( structKeyExists(arguments,&quot;isPublished&quot;) AND arguments.isPublished NEQ &quot;any&quot;){
        arrayAppend(criteria, restrictions.eq(&quot;isPublished&quot;,javaCast(&quot;boolean&quot;,arguments.isPublished)) );
    }

    // Author Filter
    if( structKeyExists(arguments,&quot;author&quot;) AND arguments.author NEQ &quot;all&quot;){
        arrayAppend(criteria, restrictions.eq(&quot;author.authorID&quot;,javaCast(&quot;int&quot;,arguments.author)) );
    }

    // Search Criteria
    if( len(arguments.search) ){
        // like disjunctions
        var orCriteria = [];
        arrayAppend(orCriteria,restrictions.like(&quot;title&quot;,&quot;%#arguments.search#%&quot;));
        arrayAppend(orCriteria,restrictions.like(&quot;content&quot;,&quot;%#arguments.search#%&quot;));
        // append disjunction to main criteria
        arrayAppend( criteria, restrictions.disjunction( orCriteria ) );
    }

    // Category Filter
    if( structKeyExists(arguments,&quot;category&quot;) AND arguments.category NEQ &quot;all&quot;){
        // Uncategorized?
        if( arguments.category eq &quot;none&quot; ){
            arrayAppend(criteria, restrictions.isEmpty(&quot;categories&quot;) );
        }
        // With categories
        else {
            // create association criteria, by passing a simple value the method will inflate.
            arrayAppend(criteria, &quot;categories&quot;);
            // add the association criteria to the main search
            arrayAppend(criteria, restrictions.in(&quot;categories.categoryID&quot;,JavaCast(&quot;java.lang.Integer[]&quot;,[arguments.category])));
        }
    }

    // run criteria query and projections count
    results.entries = criteriaQuery(criteria=criteria,offset=arguments.offset,max=arguments.max,sortOrder=&quot;publishedDate DESC&quot;,asQuery=false);
    results.count = criteriaCount(criteria=criteria);
    return results;
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://blog.sigmaprojects.org/hibernate-criteria-queries-are-your-friend/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

