Session session=null;
  session = HibernateSessionFactory.getSession(); 
  Query q=session.createQuery("select * from pro_single where pro_id="+proid+"and user_id="+userid+"");出现下列错误;
org.hibernate.hql.ast.QuerySyntaxException: unexpected token: * near line 1, column 8 [select * from pro_single where pro_id=pro_1and user_id=user_2]

解决方案 »

  1.   

    ...
    createQuery中放的是HQL语句
    用createSQLQuery试试
      

  2.   

    你这是用hql语句吧。
    那你得知道。你是对类操作。
    “select * from pro_single where pro_id="+proid+"and user_id="+userid+""); 
    改为
    from pro_single where pro_id="+proid+"and user_id="+userid+""); 
    注意。pro_single为类名,不是表名。
    而且后面的字段也是类里的属性,注意大小写。
      

  3.   

    我用了createSQLQuery  提示org.hibernate.exception.SQLGrammarException: could not execute query
    public class ProSingle implements java.io.Serializable { // Fields
    private UserLogin userLogin;   是另个表userid
    private ProAll proAll;           proid}
    我查询的方式对吗?