<?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-2358615510709278454</id><updated>2011-07-30T09:12:46.396-07:00</updated><category term='SmartCopy'/><category term='IntelliJ'/><title type='text'>CAFE BABE</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://cafe-babe.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2358615510709278454/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://cafe-babe.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Chandra</name><uri>http://www.blogger.com/profile/05546092352463213610</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>6</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-2358615510709278454.post-1351229514398262549</id><published>2009-12-25T13:59:00.000-08:00</published><updated>2009-12-25T14:00:54.485-08:00</updated><title type='text'>301 Moved Permanently!</title><content type='html'>We have moved! Please visit us at: &lt;a href="http://rubyorchard.wordpress.com/"&gt;http://rubyorchard.wordpress.com/&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2358615510709278454-1351229514398262549?l=cafe-babe.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cafe-babe.blogspot.com/feeds/1351229514398262549/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2358615510709278454&amp;postID=1351229514398262549' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2358615510709278454/posts/default/1351229514398262549'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2358615510709278454/posts/default/1351229514398262549'/><link rel='alternate' type='text/html' href='http://cafe-babe.blogspot.com/2009/12/301-moved-permanently.html' title='301 Moved Permanently!'/><author><name>Chandra</name><uri>http://www.blogger.com/profile/05546092352463213610</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-2358615510709278454.post-3143711863549305435</id><published>2008-03-09T10:51:00.000-07:00</published><updated>2008-03-09T12:24:40.818-07:00</updated><title type='text'>Oracle Hierarchical Query in Hibernate</title><content type='html'>When you need then there is no replacement of Oracle hierarchical queries. At the same time we would like Hibernate to do the hard work of mapping result set to entities. Here is an example of Hibernate Native Query which would fetch the organization chart from famous scott.emp table.&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;pre&gt;&lt;br /&gt;Session  s = (Session) em.getDelegate();&lt;br /&gt;String orgChartQuery = "select {emp.*} from EMP {emp} \n" +&lt;br /&gt;        "start with emp.mgr is null \n" +&lt;br /&gt;        "connect by prior emp.empno = emp.mgr\n" +&lt;br /&gt;        "order siblings by ename";&lt;br /&gt;@SuppressWarnings("unchecked")&lt;br /&gt;        List&lt;Employee&gt; list = s.createSQLQuery(orgChartQuery)&lt;br /&gt;        .addEntity("emp", Employee.class)&lt;br /&gt;        .list();&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Now suppose we want to render this in a tree control with breadcurms. We can use the following query.&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;pre&gt;&lt;br /&gt;Session  s = (Session) em.getDelegate();&lt;br /&gt;String orgChartQuery = "select sys_connect_by_path(emp.empno, '/') breadcrum,\n"+&lt;br /&gt;        "level, {emp.*} from EMP {emp} \n" +&lt;br /&gt;        "start with emp.mgr is null \n" +&lt;br /&gt;        "connect by prior emp.empno = emp.mgr\n" +&lt;br /&gt;        "order siblings by ename";&lt;br /&gt;@SuppressWarnings("unchecked")&lt;br /&gt;List&lt;Object[]&gt; list = s.createSQLQuery(orgChartQuery)&lt;br /&gt;        .addScalar("breadcrum", Hibernate.STRING)&lt;br /&gt;        .addScalar("level", Hibernate.INTEGER)&lt;br /&gt;        .addEntity("emp", Employee.class)&lt;br /&gt;        .list();&lt;br /&gt;for (Object[] objects : list) {&lt;br /&gt;    String breadcrum = (String) objects[0];&lt;br /&gt;    Integer level = (Integer) objects[1];&lt;br /&gt;    Employee emp = (Employee) objects[2];&lt;br /&gt;    System.out.println(breadcrum +"  "+ level + "   "+emp.getName() &lt;br /&gt;        + " "+emp.getDepartment().getName());&lt;br /&gt;}&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;Breadcrums willl give you path to the object from the root and level gives the 1 based level in the tree.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2358615510709278454-3143711863549305435?l=cafe-babe.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cafe-babe.blogspot.com/feeds/3143711863549305435/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2358615510709278454&amp;postID=3143711863549305435' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2358615510709278454/posts/default/3143711863549305435'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2358615510709278454/posts/default/3143711863549305435'/><link rel='alternate' type='text/html' href='http://cafe-babe.blogspot.com/2008/03/oracle-hierarchical-query-in-hibernate.html' title='Oracle Hierarchical Query in Hibernate'/><author><name>Chandra</name><uri>http://www.blogger.com/profile/05546092352463213610</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>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2358615510709278454.post-983187686854664965</id><published>2008-01-11T02:53:00.000-08:00</published><updated>2008-01-13T12:29:44.522-08:00</updated><title type='text'>Handling Date with Google Gears</title><content type='html'>Suppose you execute the following DML statement in Google Gears:&lt;br /&gt;&lt;pre&gt;&lt;code&gt;db.execute(&lt;br /&gt;"insert or replace into mytable "+&lt;br /&gt;"(id, modified_on) values (?, ?)",&lt;br /&gt;[null, new Date()]&lt;br /&gt;);&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;This seemingly works but you are in for a surprise because Date is stored as Date.toString(). SQLite ducktying brain can't infer that it's a date datum. If you ran select query you will get string back.&lt;br /&gt;&lt;pre&gt;&lt;code&gt;Sat Jan 12 2008 02:34:58 GMT-0800 »&lt;br /&gt;(Pacific Standard Time)&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;The downside of storing date as text that you can't use any SQLite date time functions in your queries. Due to manifest typing, SQLite happily stores text in a date column. We would like to do better. We would like to store JavaScript Date as native SQLite Date without any loss of information. SQLite itself stores date in Julian Day representation while JavaScript cannonical date representation is number of milliseconds since 1 January 1970 00:00:00 UTC. So, we need to convert JavaScript Date to either Julian Day or text as understood by SQLite. Considering the ease of implementation, efficiency and lossless representation, YYYY-MM-DDTHH:MM:SS.FFF date format seems to fit the bill. This is ISO8601 format. However after some digging in SQLite code, it turns out that if it SQLite also works even if we don't zero pad fields. So this simple JavaScript method with minor departure from ISO8601 format does the job well.&lt;br /&gt;&lt;pre&gt;&lt;code&gt;dateToSQLiteFormat = function(date) {&lt;br /&gt;  return date.getUTCFullYear()+&lt;br /&gt;         "-"+date.getUTCMonth() + 1+&lt;br /&gt;         "-"+date.getUTCDate()+&lt;br /&gt;         "T"+date.getUTCHours()+&lt;br /&gt;         ":"+date.getUTCMinutes()+&lt;br /&gt;         ":"+date.getUTCSeconds()+"."+&lt;br /&gt;         date.getUTCMilliseconds();&lt;br /&gt;};&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;So far so good. How about converting SQLite dates to JavaScript Date object. This function does that trick.&lt;br /&gt;&lt;pre&gt;&lt;code&gt;dateSqlFragment = function(column, alias) {&lt;br /&gt;  return " ((strftime('%s', "+column+") -&lt;br /&gt;         strftime('%S', "+column+"))*1000 +&lt;br /&gt;         strftime('%f', "+column+")*1000) "+&lt;br /&gt;         (alias "");&lt;br /&gt;};&lt;br /&gt;&lt;br /&gt;var rs = db.execute(&lt;br /&gt;"select id, "+dateSqlFragment("modified_on") +&lt;br /&gt;" from mytable");&lt;br /&gt;...&lt;br /&gt;Date date = new Date(rs.field(1));&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2358615510709278454-983187686854664965?l=cafe-babe.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cafe-babe.blogspot.com/feeds/983187686854664965/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2358615510709278454&amp;postID=983187686854664965' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2358615510709278454/posts/default/983187686854664965'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2358615510709278454/posts/default/983187686854664965'/><link rel='alternate' type='text/html' href='http://cafe-babe.blogspot.com/2008/01/handling-date-with-google-gears.html' title='Handling Date with Google Gears'/><author><name>Chandra</name><uri>http://www.blogger.com/profile/05546092352463213610</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>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2358615510709278454.post-1566231332761119438</id><published>2007-05-03T21:13:00.000-07:00</published><updated>2007-05-04T01:48:11.555-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='IntelliJ'/><category scheme='http://www.blogger.com/atom/ns#' term='SmartCopy'/><title type='text'>Smart Copy Plugin for IntelliJ</title><content type='html'>&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_0"&gt;&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_0"&gt;IntelliJ&lt;/span&gt;&lt;/span&gt; always seems to do The Right Thing. It comes with code-aware features such as &lt;a href="http://blogs.jetbrains.com/idea/2007/03/using-smart-line-joins/"&gt;Smart Line Joins&lt;/a&gt;, and &lt;a href="http://www.jetbrains.com/idea/docs/help/editing/otherediting.html#smartSplit"&gt;Smart Line Split&lt;/a&gt;. However, there is not &lt;strong&gt;Smart Copy&lt;/strong&gt; to complement &lt;a href="http://www.jetbrains.com/idea/docs/help/editing/otherediting.html#smartPaste"&gt;Smart Paste&lt;/a&gt;. Besides &lt;span class="blsp-spelling-corrected" id="SPELLING_ERROR_1"&gt;symmetry&lt;/span&gt;, there are good reasons to have Smart Copy. &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_1"&gt;Supppose&lt;/span&gt;, you have a &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_2"&gt;SQL&lt;/span&gt; query in Java Code and you want to run it in &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_3"&gt;SQLPlus&lt;/span&gt; to see an execution plan. Another example could be embedded XML as compile time constant. When you copy a query embedded in a Java class, perhaps you are interested in its value without without the quotes and plus characters clinging to the copied text.&lt;br /&gt;If you are a surprised user, you are not alone. &lt;a href="http://plugins.intellij.net/plugin/?id=1464"&gt;Smart Copy&lt;/a&gt; is a &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_5"&gt;plugin&lt;/span&gt; to copy the literal values. Smart Copy action maps to &lt;em&gt;&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_6"&gt;Ctrl&lt;/span&gt;+Alt+Shift+C&lt;/em&gt; by default. It copies the value of compile time constants and String literals to the system clipboard. It also copies the selected literals. Entire expression is copied if noting is selected. If it cannot do smart copy, it will fallback to regular copy action. Certainly a candidate for your &lt;em&gt;&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_7"&gt;Ctrl&lt;/span&gt;+C&lt;/em&gt; mapping.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2358615510709278454-1566231332761119438?l=cafe-babe.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cafe-babe.blogspot.com/feeds/1566231332761119438/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2358615510709278454&amp;postID=1566231332761119438' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2358615510709278454/posts/default/1566231332761119438'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2358615510709278454/posts/default/1566231332761119438'/><link rel='alternate' type='text/html' href='http://cafe-babe.blogspot.com/2007/05/smart-copy-plugin-for-intellij.html' title='Smart Copy Plugin for IntelliJ'/><author><name>Chandra</name><uri>http://www.blogger.com/profile/05546092352463213610</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>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2358615510709278454.post-7390904985032160077</id><published>2007-04-28T03:24:00.000-07:00</published><updated>2007-04-28T15:27:35.740-07:00</updated><title type='text'>Maven debug output</title><content type='html'>Imagine you are frustrated by one of the maven plugin and you want to turn the debug output on. Google debugging a maven plugin or maven debug output and you may still be out of luck. Here is the brute force way of doing it.&lt;br /&gt;Open MAVEN_HOME/core/plexus-container-default-1.0-alpha-9.jar and edit org/codehaus/plexus/plexus-bootstrap.xml to set threshold to debug.&lt;br /&gt;&lt;pre class="csharpcode"&gt;&lt;br /&gt;&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;component&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;role&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;org.codehaus.plexus.logging.LoggerManager&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;role&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;implementation&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;org.codehaus.plexus.logging.console.ConsoleLoggerManager&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;implementation&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;lifecycle-handler&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;basic&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;LIFECYCLE-HANDLER&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;configuration&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;threshold&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;debug&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;threshold&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;configuration&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;component&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2358615510709278454-7390904985032160077?l=cafe-babe.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cafe-babe.blogspot.com/feeds/7390904985032160077/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2358615510709278454&amp;postID=7390904985032160077' title='4 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2358615510709278454/posts/default/7390904985032160077'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2358615510709278454/posts/default/7390904985032160077'/><link rel='alternate' type='text/html' href='http://cafe-babe.blogspot.com/2007/04/maven-debug-output.html' title='Maven debug output'/><author><name>Chandra</name><uri>http://www.blogger.com/profile/05546092352463213610</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-2358615510709278454.post-8369570410026127719</id><published>2007-01-16T01:05:00.000-08:00</published><updated>2008-01-11T09:01:18.846-08:00</updated><title type='text'>java.util.Scanner oops!</title><content type='html'>Java 5 java.util.Scanner provides a better replacement for StringTokenizer. And, the hope was that we should be able to write,&lt;br /&gt;&lt;blockquote&gt;&lt;br /&gt;Scanner lines = new Scanner(new File("/etc/passwd"));&lt;br /&gt;for(String line : lines) {&lt;br /&gt;&lt;span style="font-size:0;"&gt;&lt;/span&gt;System.out.println(line);&lt;br /&gt;}&lt;br /&gt;&lt;/blockquote&gt;&lt;br /&gt;Unfortunately, this doesn't work because someone &lt;a href="http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4993740"&gt;mistyped&lt;/a&gt;, and it implements Iterator&lt;string&gt; instead of Iterable&lt;string&gt;.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2358615510709278454-8369570410026127719?l=cafe-babe.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cafe-babe.blogspot.com/feeds/8369570410026127719/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2358615510709278454&amp;postID=8369570410026127719' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2358615510709278454/posts/default/8369570410026127719'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2358615510709278454/posts/default/8369570410026127719'/><link rel='alternate' type='text/html' href='http://cafe-babe.blogspot.com/2007/01/javautilscanner-implements-iterator-why.html' title='java.util.Scanner oops!'/><author><name>Chandra</name><uri>http://www.blogger.com/profile/05546092352463213610</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>
