Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp
Hibernate version:
3.1
Mapping documents:
not there yet, configuration shown below
Code between sessionFactory.openSession() and session.close():
not there yet
Full stack trace of any exception that occurs:
shown below
Name and version of the database you are using:
MySQL 4.0.17
The generated SQL (show_sql=true):
not there yet
Debug level Hibernate log excerpt:
I am migrating a legacy app from hibernate 2.x to 3.1 with limited success. The app runs under tomcat 5.5 and uses Spring to drive hibernate. I know very little about Spring, so right now it's probably my biggest problem. I upgraded the app from spring 1.1.5 to 1.2.6 so that we could move it up to hibernate 3. I managed to do this, and all my tests still work, so I am partway there. I implemented the changes spelled out in the hibernate migration document, and now I am running into problems. I knew I should be using the old parser with this legacy code, so I updated the hibernate.cfg.xml file to look like this:
Code:
<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration
PUBLIC "-//Hibernate/Hibernate Configuration DTD//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="dialect">org.hibernate.dialect.MySQLDialect</property>
<property name="connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="connection.url">jdbc:mysql://localhost:3306/HIBRN8_HQL_SMPL</property>
<property name="connection.username">admin</property>
<property name="connection.password">admin</property>
<property name="show_sql">true</property>
<property name="connection.pool.size">1</property>
<property name="statement_cache.size">25</property>
<property name="jdbc.fetch_size">50</property>
<property name="jdbc.batch_size">30</property>
<!-- Fusion: added following to use classic query translator factory -->
<property name="hibernate.query.factory_class">
org.hibernate.hql.classic.ClassicQueryTranslatorFactory
</property>
<!-- Mapping files -->
<mapping resource="com/perfretail/hibernate/hql/sample/Orders-Sample.hbm.xml"/>
</session-factory>
</hibernate-configuration>
This did not affect the stack trace given below, so then I found out that Spring was controlling hibernate now, and I assumed the hibernate.cfg.xml file was something left over from the pre-spring days, or maybe Spring uses this too. So I found applicationContext-hibernate.xml file, and added the factory_class to the hibernateProperties section, resulting in this. BTW people on the spring forum are stumped, and say this Spring configuration is correct, anyway.
Code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
<beans>
<!-- ========================= GENERAL DEFINITIONS ========================= -->
<!-- Message source for this context, loaded from localized "messages_xx" files -->
<bean id="messageSource" class="org.springframework.context.support.ResourceBundleMessageSource">
<property name="basename"><value>messages</value></property>
</bean>
<!-- Local mySQL DataSource that works in any environment -->
<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName"><value>com.mysql.jdbc.Driver</value></property>
<property name="url"><value>jdbc:mysql://localhost:3306/K2V01_TEST</value></property>
<property name="username"><value>admin</value></property>
<property name="password"><value></value></property>
</bean>
<!-- Hibernate SessionFactory for mySQL -->
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource"><ref local="dataSource"/></property>
<property name="mappingResources">
<list>
<value>com/perfretail/k2v1/envoys/sales/SalesRecord.hbm.xml</value>
<value>com/perfretail/k2v1/envoys/receipts/ReceiptItemRecord.hbm.xml</value>
<value>com/perfretail/k2v1/trackers/catalogs/SiteSetupCatalog.hbm.xml</value>
<value>com/perfretail/k2v1/trackers/catalogs/Catalog.hbm.xml</value>
<value>com/perfretail/k2v1/envoys/setup/SiteSetupBlock.hbm.xml</value>
</list>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
<!-- Fusion: added this to use old parser in H3 -->
<prop key="hibernate.query.factory_class">org.hibernate.hql.classic.ClassicQueryTranslatorFactory</prop>
</props>
</property>
<!-- Fusion: added this to use old parser in H3
<property name="hibernate.query.factory_class">
<value>org.hibernate.hql.classic.ClassicQueryTranslatorFactory</value>
</property> -->
</bean>
<!-- ========================= Start of PERSISTENCE DEFINITIONS ========================= -->
<!-- SalesRecord primary business object: Hibernate implementation -->
<bean id="salesTarget" class="com.perfretail.k2v1.envoys.sales.SalesRecordDaoHibr">
<property name="sessionFactory"><ref local="sessionFactory"/></property>
</bean>
<!-- ReceiptItemRecord primary business object: Hibernate implementation -->
<bean id="receiptTarget" class="com.perfretail.k2v1.envoys.receipts.ReceiptItemRecordDaoHibr">
<property name="sessionFactory"><ref local="sessionFactory"/></property>
</bean>
<!-- SiteSetupRecord primary business object: Hibernate implementation -->
<bean id="setupTarget" class="com.perfretail.k2v1.trackers.catalogs.SiteSetupCatalogItemDaoHibr">
<property name="sessionFactory"><ref local="sessionFactory"/></property>
</bean>
<!-- SiteSetupBlock primary business object: Hibernate implementation -->
<bean id="setupBlockTarget" class="com.perfretail.k2v1.envoys.setup.SiteSetupBlockDaoHibr">
<property name="sessionFactory"><ref local="sessionFactory"/></property>
</bean>
<!-- Catalog primary business object: Hibernate implementation -->
<bean id="catalogTarget" class="com.perfretail.k2v1.trackers.catalogs.CatalogItemDaoHibr">
<property name="sessionFactory"><ref local="sessionFactory"/></property>
</bean>
<!-- ========================= End of PERSISTENCE DEFINITIONS ========================= -->
</beans>
So when I start tomcat, this is the stack trace that gets logged:
(please ignore the ehcache problem, it always uses the default config file, even before the upgrades, and it works fine that way)
Code:
2006-02-01 10:16:51,655 INFO [com.perfretail.k2v1.tahiti.DirectorConfig] - <in setMtPropertiesMap>
2006-02-01 10:16:53,233 WARN [com.perfretail.k2v1.utils.SystemDate] - <systemdate.properties not found in C:\WINDOWS\system32>
2006-02-01 10:16:53,608 WARN [net.sf.ehcache.config.Configurator] - <No configuration found. Configuring ehcache from ehcache-failsafe.xml found in the classpath: jar:file:/C:/etc/bin/Tomcat%205.5/webapps/k2v02/WEB-INF/lib/ehcache-1.1.jar!/ehcache-failsafe.xml>
2006-02-01 10:16:55,827 ERROR [org.hibernate.hql.PARSER] - <line 2:95: expecting CLOSE, found '('>
2006-02-01 10:16:55,858 ERROR [org.hibernate.hql.PARSER] - <line 2:95: expecting CLOSE, found '('>
2006-02-01 10:16:55,905 ERROR [org.hibernate.hql.PARSER] - <line 2:95: expecting CLOSE, found '('>
2006-02-01 10:16:55,952 ERROR [org.hibernate.hql.PARSER] - <line 19:14: unexpected token: LIMIT>
2006-02-01 10:16:55,952 WARN [org.hibernate.hql.ast.HqlParser] - <processEqualityExpression() : No expression to process!>
2006-02-01 10:16:55,952 ERROR [org.hibernate.hql.PARSER] - <line 2:83: expecting CLOSE, found '('>
2006-02-01 10:16:55,952 ERROR [org.hibernate.hql.PARSER] - <line 2:83: expecting CLOSE, found '('>
2006-02-01 10:16:55,952 ERROR [org.hibernate.hql.PARSER] - <line 7:14: unexpected token: LIMIT>
2006-02-01 10:16:55,952 WARN [org.hibernate.hql.ast.HqlParser] - <processEqualityExpression() : No expression to process!>
2006-02-01 10:16:55,968 ERROR [org.hibernate.hql.PARSER] - <line 2:83: expecting CLOSE, found '('>
2006-02-01 10:16:55,968 ERROR [org.hibernate.hql.PARSER] - <line 2:95: expecting CLOSE, found '('>
2006-02-01 10:16:55,983 ERROR [org.hibernate.hql.PARSER] - <line 2:83: expecting CLOSE, found '('>
2006-02-01 10:16:55,999 ERROR [org.hibernate.impl.SessionFactoryImpl] - <Error in named query: com.perfretail.k2v1.trackers.registerops.operatorsForSelectSites>
org.hibernate.hql.ast.QuerySyntaxException: expecting CLOSE, found '(' near line 2, column 83 [
select distinct item.siteUuid, item.operatorId, count(distinct to_days(from_unixtime(item.timeStamp / 1000)))
from com.perfretail.k2v1.trackers.registerops.RegisterOpsItem as item
where item.chainUuid = :chainUuid and
item.siteUuid in (:siteUuids) and
item.status = :status and
item.timeStamp >= :start and
item.timeStamp < :end
group by item.siteUuid, item.operatorId]
at org.hibernate.hql.ast.ErrorCounter.throwQueryException(ErrorCounter.java:59)
at org.hibernate.hql.ast.QueryTranslatorImpl.parse(QueryTranslatorImpl.java:244)
at org.hibernate.hql.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:155)
at org.hibernate.hql.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:105)
at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:74)
at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:53)
at org.hibernate.engine.query.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:71)
at org.hibernate.impl.SessionFactoryImpl.checkNamedQueries(SessionFactoryImpl.java:363)
at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:327)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1154)
at org.springframework.orm.hibernate3.LocalSessionFactoryBean.newSessionFactory(LocalSessionFactoryBean.java:800)
at org.springframework.orm.hibernate3.LocalSessionFactoryBean.afterPropertiesSet(LocalSessionFactoryBean.java:726)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1059)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:363)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:226)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:147)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:176)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:105)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1013)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:824)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:345)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:226)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:147)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:176)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:105)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1013)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:824)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:345)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:226)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:147)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeansOfType(DefaultListableBeanFactory.java:203)
at org.springframework.context.support.AbstractApplicationContext.getBeansOfType(AbstractApplicationContext.java:614)
at org.springframework.context.support.AbstractApplicationContext.registerListeners(AbstractApplicationContext.java:496)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:317)
at org.springframework.web.context.support.AbstractRefreshableWebApplicationContext.refresh(AbstractRefreshableWebApplicationContext.java:134)
at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:246)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:184)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:49)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3669)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4104)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:759)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:739)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:524)
at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:894)
at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:857)
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:475)
at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1102)
at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:311)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1020)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:718)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1012)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:442)
at org.apache.catalina.core.StandardService.start(StandardService.java:450)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:683)
at org.apache.catalina.startup.Catalina.start(Catalina.java:537)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:271)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:409)
Caused by: line 2:83: expecting CLOSE, found '('
at antlr.Parser.match(Parser.java:211)
at org.hibernate.hql.antlr.HqlBaseParser.aggregate(HqlBaseParser.java:4385)
at org.hibernate.hql.antlr.HqlBaseParser.identPrimary(HqlBaseParser.java:4036)
at org.hibernate.hql.antlr.HqlBaseParser.primaryExpression(HqlBaseParser.java:861)
at org.hibernate.hql.antlr.HqlBaseParser.atom(HqlBaseParser.java:3422)
at org.hibernate.hql.antlr.HqlBaseParser.unaryExpression(HqlBaseParser.java:3200)
at org.hibernate.hql.antlr.HqlBaseParser.multiplyExpression(HqlBaseParser.java:3082)
Can anyone help with this???