Select one column from a row in hibernate
- by ComfortablyNumb
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?