Hibernate 4.1Final alternative for Hibernate.STRING

JavaHibernate

Java Problem Overview


I was using Hibernate 3.6 where I have a code like this:

list =getSession().createSQLQuery(queryString)
	    .addScalar("UNAME",Hibernate.STRING)
	    .addScalar("COM",Hibernate.STRING)
	    .addScalar("COM_DATE",Hibernate.DATE) 
        .setString("id", Id).list();

now I change the jar from 3.6 to 4.1Final

it seems like the addScalar method is askying for Type in stead of Hibernate.STRING I couldn't find any example hot to resolve this. if there is anyone that who know please help me thank you.

Java Solutions


Solution 1 - Java

Type fields in org.hibernate.Hibernate are deprecated (and actually removed) as result of HHH-5196

Now different Hibernate types can be found from javadocs for Type. In your case following should work:

    .addScalar("UNAME", StringType.INSTANCE)
    .addScalar("COM", StringType.INSTANCE)
    .addScalar("COM_DATE", DateType.INSTANCE) 

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionkefetView Question on Stackoverflow
Solution 1 - JavaMikko MaunuView Answer on Stackoverflow