Java 使用Hibernate查找数据,但它会发出警报;结果集关闭后不允许操作";
这是一个例外:Java 使用Hibernate查找数据,但它会发出警报;结果集关闭后不允许操作";,java,mysql,hibernate,Java,Mysql,Hibernate,这是一个例外: org.springframework.jdbc.UncategorizedSQLException: Hibernate operation: could not execute query; uncategorized SQLException for SQL ... Caused by: java.sql.SQLException: Operation not allowed after ResultSet closed 代码如下: 只有函数“getByReportDat
org.springframework.jdbc.UncategorizedSQLException: Hibernate operation: could not execute query; uncategorized SQLException for SQL ...
Caused by: java.sql.SQLException: Operation not allowed after ResultSet closed
代码如下:
只有函数“getByReportDate”是我自己写的,其他的都是hibernate生成的。我用同样的方法操作了另一个java模型,它成功了。但是到了一个,它失败了
//DAO
public static final String REPTIME = "reportTime";
public List getByReportDate(Object recOrgName) {
return findByProperty(REPTIME, recOrgName);
}
public List findByProperty(String propertyName, Object value) {
log.debug("finding TblEntPaytaxList instance with property: " + propertyName
+ ", value: " + value);
try {
String queryString = "from TblEntPaytaxList as model where model."
+ propertyName + "= ?";
return getHibernateTemplate().find(queryString, value);
} catch (RuntimeException re) {
log.error("find by property name failed", re);
throw re;
}
}
//Object
public class TblEntPaytaxList implements java.io.Serializable {
...
private String econType;
private Date reportTime;
private double money;
...
EntityManager已关闭会话。打开会话。那么在哪里打开会话?使用hibernate打开会话。您需要仔细阅读以下内容:公共列表getByReportDate(Object recOrgName){session session=this.getSession();return findByProperty(REPTIME,recOrgName);}