<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-7039725816042948040</id><updated>2011-07-28T09:02:22.872-07:00</updated><category term='setLenient'/><category term='Struts Multi-Select boxes losing data on submit'/><category term='SimpleDateFormat'/><category term='Setting CSS property from javascript'/><category term='Java'/><category term='Windows v Linux'/><category term='Hibernate Criteria'/><category term='invalid date format'/><category term='ResourceBundles'/><title type='text'>Lessons Learnt</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://ch-express.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7039725816042948040/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://ch-express.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Sweet Memories</name><uri>http://www.blogger.com/profile/00667010106915302808</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>7</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-7039725816042948040.post-4663363458254455119</id><published>2008-06-29T10:45:00.000-07:00</published><updated>2008-06-29T11:31:38.086-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Hibernate Criteria'/><title type='text'>Hibernate Criteria sqlRestriction alias variable limitation</title><content type='html'>The API Documenataion of Hibernate's Criteria API's sqlRestriction method, defines as follows:&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color:#cc0000;"&gt;/** &lt;/span&gt;&lt;br /&gt;&lt;span style="color:#cc0000;"&gt;* Apply a constraint expressed in SQL, with the given JDBC &lt;/span&gt;&lt;br /&gt;&lt;span style="color:#cc0000;"&gt;* parameter. Any occurrences of &lt;tt&gt;{alias}&lt;/tt&gt; will be replaced &lt;/span&gt;&lt;br /&gt;&lt;span style="color:#cc0000;"&gt;* by the table alias. */&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Make note of the &lt;span style="color:#cc0000;"&gt;{alias}&lt;/span&gt; placeholder in the above comments.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;The catch is the only &lt;span style="color:#cc0000;"&gt;{alias}&lt;/span&gt; this method understands is the alias name of the root table on which the Criteria call is constructed. If more than one table is joined in the Criteria query either using the createCriteria or the createAlias method, the alias of these &lt;em&gt;'joined'&lt;/em&gt; tables are not understood by the Criteria API.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;In order to get over this problem in our project, we had to look at the SQL generated by the Criteria object, figure out the alias name generated by hibernate and then code that in the SQL that is passed in as an argument to the &lt;em&gt;&lt;span style="color:#cc0000;"&gt;sqlRestriction&lt;/span&gt;&lt;/em&gt; method.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;For example in the below snippet,&lt;br /&gt;&lt;br /&gt;&lt;span style="color:#cc0000;"&gt;Criteria c = session.createCriteria(BaseTable.class, "base");&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#cc0000;"&gt;c.createAlias(SecondTable.class, "second", CriteriaSpecification.LEFT_JOIN);&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#cc0000;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;sqlRestriction method can interpret only "base" as the alias.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7039725816042948040-4663363458254455119?l=ch-express.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ch-express.blogspot.com/feeds/4663363458254455119/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7039725816042948040&amp;postID=4663363458254455119' title='4 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7039725816042948040/posts/default/4663363458254455119'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7039725816042948040/posts/default/4663363458254455119'/><link rel='alternate' type='text/html' href='http://ch-express.blogspot.com/2008/06/hibernate-criteria-sqlrestriction-alias.html' title='Hibernate Criteria sqlRestriction alias variable limitation'/><author><name>Sweet Memories</name><uri>http://www.blogger.com/profile/00667010106915302808</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>4</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7039725816042948040.post-3660683859423926604</id><published>2008-06-27T12:55:00.000-07:00</published><updated>2008-06-27T12:59:28.695-07:00</updated><title type='text'>Hibernate's Formula</title><content type='html'>In a reporting application we were building, we had a need to display different text descriptions based on the value in a column.&lt;br /&gt;&lt;br /&gt;The resultset we were expecting to get back was so large that it was not an option to loop through the result set and set the description programmatically.&lt;br /&gt;&lt;br /&gt;We were using &lt;strong&gt;&lt;em&gt;Hibernate's Criteria API&lt;/em&gt;&lt;/strong&gt; for generating the report queries. What we ended up doing is writing a &lt;strong&gt;&lt;em&gt;FORMULA&lt;/em&gt;&lt;/strong&gt; with a CASE statement in the hibernate mapping files that would return the description we wanted based on the code.&lt;br /&gt;&lt;br /&gt;&lt;span style="color:#000066;"&gt;&amp;lt;property name="&lt;span style="color:#cc0000;"&gt;errorReason&lt;/span&gt;" type="&lt;span style="color:#cc0000;"&gt;string&lt;/span&gt;" &lt;/span&gt;&lt;br /&gt;&lt;span style="color:#000066;"&gt;              formula="&lt;/span&gt;&lt;span style="color:#cc0000;"&gt;CASE WHEN err_status = -1 THEN 'INACTIVE' &lt;/span&gt;&lt;br /&gt;&lt;span style="color:#cc0000;"&gt;                                           WHEN err_status = 1 THEN 'NOT FOUND' &lt;/span&gt;&lt;br /&gt;&lt;span style="color:#cc0000;"&gt;                                           WHEN err_status = 2 THEN 'DUPLICATE' &lt;/span&gt;&lt;br /&gt;&lt;span style="color:#cc0000;"&gt;                                           WHEN err_status = 3 THEN 'DUPLICATE (ACTIVE)' &lt;/span&gt;&lt;br /&gt;&lt;span style="color:#cc0000;"&gt;                                           WHEN err_status = 4 THEN 'DUPLICATE (INACTIVE)' &lt;/span&gt;&lt;br /&gt;&lt;span style="color:#000066;"&gt;&lt;span style="color:#cc0000;"&gt;                                           ELSE ' 'END&lt;/span&gt;" /&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;When we are creating the Criteria Query, if we just add the name of the property 'errorReason', this CASE statement will be tagged along behind the scenes with the query and we will get the description we need.In the above example based on the err_status different descriptions are returned.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7039725816042948040-3660683859423926604?l=ch-express.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ch-express.blogspot.com/feeds/3660683859423926604/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7039725816042948040&amp;postID=3660683859423926604' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7039725816042948040/posts/default/3660683859423926604'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7039725816042948040/posts/default/3660683859423926604'/><link rel='alternate' type='text/html' href='http://ch-express.blogspot.com/2008/06/hibernates-formula.html' title='Hibernate&apos;s Formula'/><author><name>Sweet Memories</name><uri>http://www.blogger.com/profile/00667010106915302808</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7039725816042948040.post-5925958527923667928</id><published>2008-03-17T08:50:00.001-07:00</published><updated>2008-03-17T08:50:53.824-07:00</updated><title type='text'>JasperException: The absolute uri: http://java.sun.com/jstl/core_rt cannot be resolved in either web.xml or the jar files deployed with this applicati</title><content type='html'>Make sure the correct version of jstl.jar and standard.jar in WEB-INF/lib&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7039725816042948040-5925958527923667928?l=ch-express.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ch-express.blogspot.com/feeds/5925958527923667928/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7039725816042948040&amp;postID=5925958527923667928' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7039725816042948040/posts/default/5925958527923667928'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7039725816042948040/posts/default/5925958527923667928'/><link rel='alternate' type='text/html' href='http://ch-express.blogspot.com/2008/03/jasperexception-absolute-uri.html' title='JasperException: The absolute uri: http://java.sun.com/jstl/core_rt cannot be resolved in either web.xml or the jar files deployed with this applicati'/><author><name>Sweet Memories</name><uri>http://www.blogger.com/profile/00667010106915302808</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7039725816042948040.post-2607942270734783998</id><published>2008-03-01T10:18:00.001-08:00</published><updated>2008-03-01T10:23:44.457-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Struts Multi-Select boxes losing data on submit'/><title type='text'>Struts Multi-Select Form Wipes out Data</title><content type='html'>I had a multiple select box in a form into which users could add/remove some attributes. On submitting the system was supposed to update the database with additions/removals done by the user.&lt;br /&gt;&lt;br /&gt;But every time i submitted the form, all the records in the specific table was getting deleted. After spending a considerable amount of time scratching my head, i tried to set the focus on that field prior to submitting the form and then it worked.&lt;br /&gt;&lt;br /&gt;   var options = document.getElementById("selectedKeys").options;  &lt;br /&gt;   for (var i = 0; i &lt; options.length; i++) {   &lt;br /&gt;         options[i].selected = true;  &lt;br /&gt;   }  &lt;br /&gt;   form.submit();&lt;br /&gt;&lt;br /&gt;I am not sure if it is anything to do with Struts forms, or HTML in general.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7039725816042948040-2607942270734783998?l=ch-express.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ch-express.blogspot.com/feeds/2607942270734783998/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7039725816042948040&amp;postID=2607942270734783998' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7039725816042948040/posts/default/2607942270734783998'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7039725816042948040/posts/default/2607942270734783998'/><link rel='alternate' type='text/html' href='http://ch-express.blogspot.com/2008/03/struts-multi-select-form-wipes-out-data.html' title='Struts Multi-Select Form Wipes out Data'/><author><name>Sweet Memories</name><uri>http://www.blogger.com/profile/00667010106915302808</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7039725816042948040.post-2469197515047184807</id><published>2008-03-01T10:14:00.000-08:00</published><updated>2008-03-01T10:17:13.220-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Setting CSS property from javascript'/><title type='text'>Setting css property in JavaScript calls</title><content type='html'>I wanted to dynamically set color for some of the options in a drop down list. I tried the following call:&lt;br /&gt;&lt;strong&gt;&lt;em&gt;document.getElementById("selectedKeys").options[i].style = 'color:red';&lt;/em&gt;&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;This did not work, at least in IE.&lt;br /&gt;&lt;br /&gt;For this to work, i had to do something like this:&lt;br /&gt;&lt;strong&gt;&lt;em&gt;document.getElementById("selectedKeys").options[i].style.color = 'red';&lt;/em&gt;&lt;/strong&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7039725816042948040-2469197515047184807?l=ch-express.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ch-express.blogspot.com/feeds/2469197515047184807/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7039725816042948040&amp;postID=2469197515047184807' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7039725816042948040/posts/default/2469197515047184807'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7039725816042948040/posts/default/2469197515047184807'/><link rel='alternate' type='text/html' href='http://ch-express.blogspot.com/2008/03/setting-css-property-in-javascript.html' title='Setting css property in JavaScript calls'/><author><name>Sweet Memories</name><uri>http://www.blogger.com/profile/00667010106915302808</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7039725816042948040.post-5397973029341899060</id><published>2008-03-01T10:05:00.000-08:00</published><updated>2008-03-01T10:11:27.572-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='SimpleDateFormat'/><category scheme='http://www.blogger.com/atom/ns#' term='setLenient'/><category scheme='http://www.blogger.com/atom/ns#' term='invalid date format'/><title type='text'>SimpleDateFormat is lenient</title><content type='html'>Today i discovered something about &lt;strong&gt;&lt;em&gt;SimpleDateFormat&lt;/em&gt;&lt;/strong&gt;, a Java Date Formatter API.&lt;br /&gt;&lt;br /&gt;I used a statement like,&lt;br /&gt;&lt;strong&gt;&lt;em&gt;DateFormat df = new SimpleDateFormat("MM/dd/yyyy");&lt;/em&gt;&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;In my unit test i wanted a failing test when i pass in a String "13/01/2008". The method&lt;br /&gt;&lt;strong&gt;&lt;em&gt;df.parse()&lt;/em&gt;&lt;/strong&gt;&lt;br /&gt;has a ParseException in its throws clause. I was hoping that, that exception will be thrown when this invalid date was passed in..&lt;br /&gt;&lt;br /&gt;Instead it parsed it as January 1 2009.&lt;br /&gt;&lt;br /&gt;When i did some digging around, i realised that there was a method called &lt;strong&gt;&lt;em&gt;setLenient&lt;/em&gt;&lt;/strong&gt;.&lt;br /&gt;&lt;br /&gt;Once i made a call &lt;strong&gt;&lt;em&gt;df.setLenient(false)&lt;/em&gt;&lt;/strong&gt;, prior to the parse call, it threw the ParseException when invalid date was passed in..&lt;br /&gt;&lt;br /&gt;I found it a little weird and would have expected &lt;strong&gt;&lt;em&gt;setLenient&lt;/em&gt;&lt;/strong&gt; to be set to &lt;strong&gt;&lt;em&gt;false&lt;/em&gt;&lt;/strong&gt; by default.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7039725816042948040-5397973029341899060?l=ch-express.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ch-express.blogspot.com/feeds/5397973029341899060/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7039725816042948040&amp;postID=5397973029341899060' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7039725816042948040/posts/default/5397973029341899060'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7039725816042948040/posts/default/5397973029341899060'/><link rel='alternate' type='text/html' href='http://ch-express.blogspot.com/2008/03/simpledateformat-is-lenient.html' title='SimpleDateFormat is lenient'/><author><name>Sweet Memories</name><uri>http://www.blogger.com/profile/00667010106915302808</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7039725816042948040.post-3451968798013541956</id><published>2008-02-22T07:30:00.000-08:00</published><updated>2008-02-22T07:38:39.046-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Windows v Linux'/><category scheme='http://www.blogger.com/atom/ns#' term='Java'/><category scheme='http://www.blogger.com/atom/ns#' term='ResourceBundles'/><title type='text'>ResourceBundles in Windows</title><content type='html'>I was tasked with supporting a new system ( a real pile of junk). I was given URLs to all the environments in which the system runs and was given a demo. So far so good.&lt;br /&gt;&lt;br /&gt;I tried downloading on to my local machine, set up my IntelliJ editor, and when i ran my first report (It is a Java based reporting app), i got an error which i have seen a number of times but still could not figure out what it could be..&lt;br /&gt;&lt;br /&gt;&lt;em&gt;&lt;span style="color:#6666cc;"&gt;Error - java.util.MissingResourceException: Can't find bundle for base name com\xxxxx\xx\xxxxxxxxxxxxxxxxx\reportProcessing\ReportProcessing, locale en_US&lt;/span&gt;&lt;/em&gt;&lt;br /&gt;&lt;br /&gt;It is the same code which worked in all the Linux machines and it broke in the following line:&lt;br /&gt;&lt;em&gt;&lt;span style="color:#ff6666;"&gt;return ResourceBundle.getBundle("com\xxxxxxxxx\xxxx\xxxxxxxxxxxxxxxxx\reportProcessing\ReportProcessing");&lt;/span&gt;&lt;/em&gt;&lt;br /&gt;&lt;br /&gt;The properties file was in the same folder as the class file but it could not pick up.. I tried replacing \ with /, then \ with //. Then removed the package name and just gave the properties file name.. Nothing worked...&lt;br /&gt;&lt;br /&gt;Then tried the following line, after reading a lot of forums and it worked...&lt;br /&gt;&lt;em&gt;&lt;span style="color:#ff0000;"&gt;return ResourceBundle.getBundle("com.xxxx.xx.yyyyyyyyyyy.reportProcessing.ReportProcessing");&lt;/span&gt;&lt;/em&gt;&lt;br /&gt;&lt;br /&gt;Wanted to blog this hack for resourcebundles.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7039725816042948040-3451968798013541956?l=ch-express.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ch-express.blogspot.com/feeds/3451968798013541956/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7039725816042948040&amp;postID=3451968798013541956' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7039725816042948040/posts/default/3451968798013541956'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7039725816042948040/posts/default/3451968798013541956'/><link rel='alternate' type='text/html' href='http://ch-express.blogspot.com/2008/02/resourcebundles-in-windows.html' title='ResourceBundles in Windows'/><author><name>Sweet Memories</name><uri>http://www.blogger.com/profile/00667010106915302808</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry></feed>
