简体   繁体   English

为什么这段代码在Netbeans中抛出ClassCastException而在Eclipse中运行良好

[英]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.

相关问题 为什么这段代码抛出classCastException - Why this piece of code is throwing classCastException 为什么此代码抛出ClassCastException以及如何避免它 - Why is this code throwing a ClassCastException and how to avoid it 为什么这个代码在java Spring MVC中抛出ClassCastException - Why this Code is throwing ClassCastException in java Spring MVC 在非Eclipse中通过NetBeans中的Java代码发送邮件时出现异常 - exception while sending mail through java code in netbeans while not in eclipse Applet Code在Eclipse环境中运行良好,但在浏览器中运行不佳 - Applet Code runing well in eclipse environement but not in the browser 为什么这段代码在我的系统上能正常工作,并在HackersRank中抛出EmptyStackException - Why this code is working fine on my system and throwing EmptyStackException in HackersRank 为什么Eclipse在尝试转换applet时会返回错误,而NetBeans却没有? - Why Eclipse returns an error when trying to convert an applet, while NetBeans not? 在Eclipse中一切正常的情况下,无法在cmd中运行Java代码 - Running a Java code in cmd is not working while everything is fine in Eclipse 为什么代码不响应并保持运行? - why the code does not respond and keep runing? 代码从eclipse构建良好,但抛出Jenkins的编译时错误 - Code builds fine from eclipse but throwing compile time errors from Jenkins
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM