Hey guys. I'm deploying Hibernate 3.2.1 within an ear folder in a JBoss 3.2 installation. This works well, except I've run into a problem I can't figure out. I have a hot deployed service that uses the following code to truncate a table prior to loading data:
public void clearData(Logger pLog) { Session session = CommonHibernateUtil.currentSession(); String hql = "delete from HibernateBean"; Query query = session.createQuery(hql); int rowCount = query.executeUpdate(); pLog.info("Truncating table: " + String.valueOf(rowCount) + " rows deleted."); CommonHibernateUtil.closeSession(); } This works beautifully upon initial deployment, but if I redeploy without rebooting the server, I get the following error: java.lang.ClassCastException at org.hibernate.hql.ast.HqlLexer.makeToken(HqlLexer.java:39) at org.hibernate.hql.antlr.HqlBaseLexer.mIDENT(HqlBaseLexer.java:580) at org.hibernate.hql.antlr.HqlBaseLexer.nextToken(HqlBaseLexer.java:264) at antlr.TokenBuffer.fill(TokenBuffer.java:69) at antlr.TokenBuffer.LA(TokenBuffer.java:80) at antlr.LLkParser.LA(LLkParser.java:52) at org.hibernate.hql.antlr.HqlBaseParser.statement(HqlBaseParser.java:139) at org.hibernate.hql.ast.QueryTranslatorImpl.parse(QueryTranslatorImpl.java:248) at org.hibernate.hql.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:157) at org.hibernate.hql.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:111) at org.hibernate.engine.query.HQLQueryPlan.(HQLQueryPlan.java:77) at org.hibernate.engine.query.HQLQueryPlan.(HQLQueryPlan.java:56) at org.hibernate.engine.query.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:72) at org.hibernate.impl.AbstractSessionImpl.getHQLQueryPlan(AbstractSessionImpl.java:133) at org.hibernate.impl.AbstractSessionImpl.createQuery(AbstractSessionImpl.java:112) at org.hibernate.impl.SessionImpl.createQuery(SessionImpl.java:1623) at com.tamalesoftware.reporting.etl.tradehistory.TradeHistoryHibernateBeanFacade.clearData(Unknown Source) at com.tamalesoftware.reporting.etl.tradehistory.TradeHistoryLoader.truncateTable(Unknown Source) at com.tamalesoftware.reporting.etl.tradehistory.TradeHistoryLoader.preLoadActions(Unknown Source) at com.tamalesoftware.reporting.etl.tradehistory.TradeHistoryLoader.startLoader(Unknown Source) at com.tamalesoftware.reporting.etl.tradehistory.TradeHistoryLoader.(Unknown Source) at com.tamalesoftware.reporting.etl.loaders.TradeHistoryScheduler.perform(Unknown Source) at org.jboss.varia.scheduler.Scheduler$Listener.handleNotification(Scheduler.java:1236) at org.jboss.mx.server.NotificationListenerProxy.handleNotification(NotificationListenerProxy.java:71) at javax.management.NotificationBroadcasterSupport.sendNotification(NotificationBroadcasterSupport.java:84) at javax.management.timer.Timer.sendNotifications(Timer.java:441) at javax.management.timer.Timer.access$000(Timer.java:31) at javax.management.timer.Timer$RegisteredNotification.doRun(Timer.java:612) at org.jboss.mx.util.SchedulableRunnable.run(SchedulableRunnable.java:164) at org.jboss.mx.util.ThreadPool$Worker.run(ThreadPool.java:225) I have played with this for hours; I focused on the hql caching in hibernate as JBoss class cast exceptions usually occur when an object isn't released from memory when undeployed. Even turning off Hibernate query cache and adding a '.setCacheable(false)' to the end of the createQuery() statement does not solve the problem. I have commented code out, and by process of elimination I have determined that the 'Query query = session.createQuery(hql);' is what causes the problem- even with an empty string for 'hql'. If I use a direct sql truncate statement rather than an hql statement (far less desirable), everything works correctly. Anyone have any suggestions? Thanks. View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3989521#3989521 Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3989521 _______________________________________________ jboss-user mailing list jboss-user@lists.jboss.org https://lists.jboss.org/mailman/listinfo/jboss-user