Solr vs Hibernate Search

May 7, 2011

0

We are looking to implement indexing in our site and evaluated SolrJ (The java client library to access Lucene) and Hibernate Search (that also uses Lucene). Hibernate was very a tempting option given we already use Hibernate as the ORM. It just seems so elegant and simple. Also Hibenate takes care of updation to the […]

Posted in: Hibernate, Solr

Projection and aggregate functions in Hibernate

April 18, 2011

1

I needed to aggregate columns (Sum, Count etc.) and display results in a JSP (thru Struts) … with the same convenience as regular attributes for a persistent class. String queryString = “select product.productName as productName, count(billQuantity) as countBillQuantity, sum(billAmount) as totalBillAmount from bill group by product.productName”; Query queryObject = getSession().createQuery(queryString); queryObject.setResultTransformer(Transformers.aliasToBean(QueryResultSummary.class)); QueryResultSummary is a class […]

Posted in: Hibernate

XStream … ArrayIndexOutOfBoundsException

March 29, 2011

1

Spent a frustrating unproductive day trying to narrow down an XStream XML writer error that just says ” java.lang.ArrayIndexOutOfBoundsException: -1″ with no clues. It’s just a dumb mistake of missing writer.endNode  not matching writer.startNode Wouldn’t this be common error that deserved better messaging ??

Posted in: XStream

Hibernate TransactionException: Transaction not successfully started

November 13, 2010

0

If you got this cryptic error … among other issues … this could because you had one transaction embedded inside another. MethodA(){ …. objectDAO.getSession().beginTransaction(); objectDAO.save(objectInstance); MethodB(); objectDAO.getSession().getTransaction().commit() …. } MethodB(){ …. anotherObjectDAO.getSession().beginTransaction();//<===Begining a transaction inside another transaction … REMOVE THIS anotherObjectDAO.save(anotherObjectInstance); anotherObjectDAO.getSession().getTransaction().commit()//<===Begining a transaction inside another transaction … REMOVE THIS …. } You may have […]

Posted in: Hibernate

Struts Datetimepicker control not working

October 21, 2010

1

Struts Datetimepicker doesn’t work. PERIOD. It is bulky, slow, buggy and doesn’t work in Firefox. Just switch to jQueryUI Datepicker … it works like a breeze. Step 1 – Download and add the links to the jQuery templates and scripts <link type=”text/css” href=”./css/ui-lightness/jquery-ui-1.8.5.custom.css” rel=”stylesheet” /> <script type=”text/javascript” src=”./js/jquery-1.4.2.min.js”></script> <script type=”text/javascript” src=”./js/jquery-ui-1.8.5.custom.min.js”></script> Step 2 – Add […]

Posted in: jQuery, Struts2

Unknown Faceted Project Problem (Java Version Mismatch)

September 25, 2010

1

If you upgraded or downgraded the Java Compiler version in Eclipse … you may see Unknown Faceted Project Problem (Java Version Mismatch) You need to take a look at Project Properties > Project Facets … and this must match the Java compiler compliance level. Refer to this link for more details ….

Posted in: Eclipse IDE

Hibernate mySQL connection lost overnight

September 19, 2010

0

Using tomcat + mySQL + Hibernate … Your application works fine … then you wake up in the morning and try to use it … it crashes. You restart Tomcat … it works fine again. There are a lot of posts on the internet about this 8 hour problem To fix it … 1. Change […]

Posted in: Hibernate