最近我想把原先的service改成泛型来学习学习 这是我改写后的代码
代码是 服务层 至于aware层 我就不贴出来了 每每执行action的时候 偶尔就会报出来一个这样的错误
流已关闭
[code]
public class EricService<T> extends HibernateDaoSupport implements EricAware<T>{
public EricService(){
super();
}
public Object load(Class classType, Serializable id)throws ServicesException {
Object object = this.getHibernateTemplate().load(classType, id);
return object;
}
public void insert(T t) throws ServicesException {
this.getHibernateTemplate().save(t);
}
public void delete(T t) throws ServicesException {
this.getHibernateTemplate().delete(t);
}
public void update(T t) throws ServicesException {
this.getHibernateTemplate().update(t);
}
public List query(String fromClause) throws ServicesException {
List list = this.getHibernateTemplate().find(fromClause);
return list;
}
}
[/code]
这样做以后 的确让我少写了很多代码 在每个接口处都不需要实现这基本的方法了 可是最容易出现 流已被关闭 的问题 当我们有时执行一个action时 就有可能出现这个错误
[code]
15:04:49,437 ERROR [http-8562-Processor25] JDBCExceptionReporter:58 - 流已被关闭
15:04:49,468 ERROR [http-8562-Processor25] JDBCExceptionReporter:58 - 流已被关闭
15:04:49,515 ERROR [http-8562-Processor25] ServletDispatcher:281 - Could not execute action
org.springframework.jdbc.UncategorizedSQLException: Hibernate operation: could not load: [com.eric.object.news#503]; uncategorized SQLException for SQL []; SQL state [null]; error code [17027]; 流已被关闭; nested exception is java.sql.SQLException: 流已被关闭
java.sql.SQLException: 流已被关闭
[/code]
不知道是否有人遇到过同样的问题 可以交流下吗 我现在尝试着如果解决不了 还是改回到原先的service
代码是 服务层 至于aware层 我就不贴出来了 每每执行action的时候 偶尔就会报出来一个这样的错误
流已关闭
[code]
public class EricService<T> extends HibernateDaoSupport implements EricAware<T>{
public EricService(){
super();
}
public Object load(Class classType, Serializable id)throws ServicesException {
Object object = this.getHibernateTemplate().load(classType, id);
return object;
}
public void insert(T t) throws ServicesException {
this.getHibernateTemplate().save(t);
}
public void delete(T t) throws ServicesException {
this.getHibernateTemplate().delete(t);
}
public void update(T t) throws ServicesException {
this.getHibernateTemplate().update(t);
}
public List query(String fromClause) throws ServicesException {
List list = this.getHibernateTemplate().find(fromClause);
return list;
}
}
[/code]
这样做以后 的确让我少写了很多代码 在每个接口处都不需要实现这基本的方法了 可是最容易出现 流已被关闭 的问题 当我们有时执行一个action时 就有可能出现这个错误
[code]
15:04:49,437 ERROR [http-8562-Processor25] JDBCExceptionReporter:58 - 流已被关闭
15:04:49,468 ERROR [http-8562-Processor25] JDBCExceptionReporter:58 - 流已被关闭
15:04:49,515 ERROR [http-8562-Processor25] ServletDispatcher:281 - Could not execute action
org.springframework.jdbc.UncategorizedSQLException: Hibernate operation: could not load: [com.eric.object.news#503]; uncategorized SQLException for SQL []; SQL state [null]; error code [17027]; 流已被关闭; nested exception is java.sql.SQLException: 流已被关闭
java.sql.SQLException: 流已被关闭
[/code]
不知道是否有人遇到过同样的问题 可以交流下吗 我现在尝试着如果解决不了 还是改回到原先的service