Sunday, 18 August 2013

getting the error while setting the time format

getting the error while setting the time format

I am using the native sql query in Hibernate with the help of
AliasToBeanResultTransformer ... as shown below
List uy = (List) session.createSQLQuery("SELECT distinct u.name,
cast('NNN' as VARCHAR2(6)) as BOA_Type, u.updated_by, u.updateddate FROM
took u where u.FLAG='N' order by
u.name").addScalar("name",Hibernate.STRING).addScalar("Access_Type",Hibernate.STRING).addScalar("updated_by",Hibernate.STRING).addScalar("updateddate",Hibernate.TIMESTAMP).setResultTransformer(new
AliasToBeanResultTransformer(took.class)).list();
Now the issue is with addScalar("updateddate",Hibernate.TIMESTAMP) as on
inspecting I have found that all the objects in the list is having this
value
2011-01-03 10:10:55.591
but I want that value for this attribute shoulld be in this format ..
20110817 17:12 // (SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd
HH:mm");)
Now please advise how can I set in this format itself in the query so that
later I don't have to make changes any where else in the code explicitly
and my pojo has this property of time stamp please advise

No comments:

Post a Comment