[英]Why is this code throwing a ClassCastException in netbeans while its runing fine in eclipse
//Runtime Exception Runtime exception occurs when following code is called in netbeans. //运行时异常当在netbeans中调用以下代码时,将发生运行时异常。 works fine in eclipse.
在日食中工作正常。
public List<Ticket> findOpenTickets() {
Session session = null;
try {
session = getSession();
Criteria criteria = session.createCriteria(getReferenceClass());
criteria.add(Restrictions.eq(Ticket.PROP_CLOSED, Boolean.FALSE));
List list = criteria.list();
return list;
} finally {
closeSession(session);
}
}
exception stack trace is 异常堆栈跟踪为
java.lang.ClassCastException: java.lang.Boolean cannot be cast to java.lang.Short
at org.apache.derby.client.net.NetStatementRequest.buildFDODTA(Unknown Source)
at org.apache.derby.client.net.NetStatementRequest.buildSQLDTAcommandData(Unknown Source)
at org.apache.derby.client.net.NetStatementRequest.writeOpenQuery(Unknown Source)
at org.apache.derby.client.net.NetPreparedStatement.writeOpenQuery_(Unknown Source)
at org.apache.derby.client.am.PreparedStatement.writeOpenQuery(Unknown Source)
at org.apache.derby.client.am.PreparedStatement.flowExecute(Unknown Source)
at org.apache.derby.client.am.PreparedStatement.executeQueryX(Unknown Source)
at org.apache.derby.client.am.PreparedStatement.executeQuery(Unknown Source)
at org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:186)
at org.hibernate.loader.Loader.getResultSet(Loader.java:1787)
at org.hibernate.loader.Loader.doQuery(Loader.java:674)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:236)
at org.hibernate.loader.Loader.doList(Loader.java:2213)
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2104)
at org.hibernate.loader.Loader.list(Loader.java:2099)
at org.hibernate.loader.criteria.CriteriaLoader.list(CriteriaLoader.java:94)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1569)
at org.hibernate.impl.CriteriaImpl.list(CriteriaImpl.java:283)
at com.model.dao.TicketDAO.findOpenTickets(TicketDAO.java:154)
at com.util.TicketActiveDateSetterTask.run(TicketActiveDateSetterTask.java:29)
at com.main.Application.initDatabase(Application.java:160)
at com.main.Application.start(Application.java:91)
at com.main.Main.main(Main.java:12)
I am unable to solve this exception. 我无法解决此异常。 Because everything seems to be fine, same code is running fine in eclipse but producing runtime exception.
因为一切似乎都很好,所以相同的代码在eclipse中运行良好,但会产生运行时异常。
check if your hibernate.dialect is proper or not?? 检查您的hibernate.dialect是否正确? It must be of your DB..
它必须是您的数据库的。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.