Wednesday, June 20, 2012

Hibernate : A workaround for avoiding explicitly setting DTO object properties from entity object

Using HQL query

Query query = sessionFactory.
getCurrentSession().createQuery("select custType.customerTypeId as customerTypeId, custType.customerTypeName as customerTypeName from CustomerType custType");

List<CustomerTypeData> customerTypeDataList =  query.setResultTransformer(Transformers.aliasToBean(CustomerTypeData.class)).list();       

 
 
 
Using Criteria

List<CustomerTypeData> customerTypeDataList  = sessionFactory.getCurrentSession()
                .createCriteria(CustomerType.class)
                .setProjection(
                        Projections.projectionList().add(
                                Projections.property("customerTypeId"),
                                "customerTypeId").add(Projections.property("customerTypeName"),
                                "customerTypeName"))
                .setResultTransformer(
                        Transformers.aliasToBean(CustomerTypeData.class)).list();

Spring MVC:Handling multiple submit buttons in a single form

Specify the parameter name in the name attribute. 


<input type = "submit" name = "update" value = "Update" />
<input type = "submit" name = "delete" value = "Delete" />

Include the "params" attribute, with the corresponding parameter name as value, in the annotation for request mapping



@RequestMapping(..., params = "update")
public ModelAndView updateCustomer(...) { ... }

@RequestMapping(..., params = "delete")
public ModelAndView deleteCustomer(...) { ... }


Saturday, June 16, 2012

JavaHL : Installation in Ubuntu and eclipse configuration


Execute the command

sudo apt-get install libsvn-java Add given below line in ~eclipse/eclipse.ini file VMARGS="-Djava.library.path=/usr/lib/jni'
Restart eclipse.  Note: For Ubuntu  12.04, the "path "is "/usr/lib/i386-linux-gnu/jni"