• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

String to Date Convertion in HQL

 
siraj baig
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HI
I have a bean with property type java.util.Date. The corresponding
column in databse is varchar.i have written hql query like:
String hqlquery = select to_char(u.date) as date from com.User u;
My Intention is: To convert the varchar type to date type.

But it is giving exception:

Exception in thread "main" java.lang.IllegalStateException: No data type for nod
e: org.hibernate.hql.ast.tree.MethodNode
\-[METHOD_CALL] MethodNode: '('
+-[METHOD_NAME] IdentNode: 'to_date' {originalText=to_date}
\-[EXPR_LIST] SqlNode: 'exprList'

Thanks
siraj.
 
sankar singh
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hI
Could you please store it in String, then assign to Persistent Entity

or example

String strTmp="Keep your Date String from DB";

Date dtTmp = new SimpleDateFormat("MM-dd-yyyy").parse(strTmp);

Assign this to your entity

Regards,
Sankar. S
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic