Hibernate hql返回对象

时间:2012-03-22 02:08:37

标签: java spring hibernate hql

在Hibernate HQL中,我想从HQL返回一个Object,

public class HqlReturnObject  implements  Serializable{ 
    String domain;
    String id;
    Object obj;

    public HqlReturnObject() {
        //super();
    }

    public HqlReturnObject(String domain, String id, Object obj) {      
        this.domain = domain;
        this.id = id;
        this.obj = obj;
    }
    ......
}

String hql = "select new HqlReturnObject('order',salesOrderId,  document) from  ... ";  
this.getHibernateTemplate().find(hql); 

错误是

java.lang.NullPointerException
    at org.hibernate.util.ReflectHelper.getConstructor(ReflectHelper.java:172)
    at org.hibernate.hql.ast.tree.ConstructorNode.resolveConstructor(ConstructorNode.java:114)
    at org.hibernate.hql.ast.tree.ConstructorNode.prepare(ConstructorNode.java:88)

但是我在HqlReturnObject中定义了一个构造函数。

由于

0 个答案:

没有答案