Select one column from a row in hibernate

Posted by ComfortablyNumb on Stack Overflow See other posts from Stack Overflow or by ComfortablyNumb
Published on 2011-02-11T12:59:25Z Indexed on 2012/09/24 21:38 UTC
Read the original article Hit count: 159

Filed under:
|

I am trying to do a simple query to get a unique result back in hibernate here is my code.

public String getName(Integer id) {
     Session session = getSessionFactory().openSession();
     String name = (String)session.createSQLQuery("SELECT name FROM users WHERE user_id = :userId").setParameter("userId", id).uniqueResult();
     return name;
}

The name that is being returned is stored as HTML text that includes html syntacx language. I think this is what is causing the problem but it doesnt make sense I just want to return it as a string.

It is only happening on this one field name, I can get every other field in the row but this one it gives me the error.

I am getting an exception. The exception I am getting is

No Dialect mapping for JDBC type: -1; nested exception is org.hibernate.HibernateException

How do you query for a specific column on a row in hibernate?

© Stack Overflow or respective owner

Related posts about mysql

Related posts about hibernate