-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Hibernate unexpected token
PostPosted: Thu Jul 02, 2009 9:37 am 
Newbie

Joined: Tue Jun 30, 2009 10:13 am
Posts: 6
Good morning,

I am new to Hibernate and am trying to follow a couple of examples (Spring docs and examples apps) to replace my JDBC calls (which work) with Hibernate with not my luck.

I am getting an "unexpected token" error when call my DAO and am having no luck in tracking down the issue (having searched the Internet already for an answer).

ENV:
Tomcat
Spring
Sybase
Hibernate
Spring Security
JDK 1.5
RichFaces
JSF 1.2


Please help!!!

Thanks in advance.

Whatty

-------------------------
UserTypeDAOImpl
-------------------------
/**
* A Hibernate DAO implementation for UserType objects
*/
public class UserTypeDAOImpl extends HibernateDaoSupport implements IUserTypeDAO {

/**
* Retrieve a list of UserType objects from the database.
*
* @param objectConstructor A domain object constructor of the generic type UserType.
*
* @return a list of UserTypes.
*
* @throws DataAccessException An exception is thrown if some error occurs accessing the data.
*/
public List getUserTypes() throws DataAccessException {
return this.getHibernateTemplate().find("getUserTypes");
}

}

-------------------------
applicationContext.xml
-------------------------

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">

<!--
Application context.
-->

<beans>

<bean id="passwordPolicy" class="com.purefacts.security.policies.NoPasswordPolicy" />

<bean id="userService" class="com.purefacts.service.implementation.UserServiceImpl">
<property name="passwordPolicy">
<ref bean="passwordPolicy"/>
</property>
</bean>

<bean id="userTypeService" class="com.purefacts.service.implementation.UserTypeServiceImpl">
<property name="userTypeDAO" ref="userTypeDAO" />
</bean>

<bean id="hibernateDataSource" class="org.apache.commons.dbcp.BasicDataSource">
<property name="driverClassName" value="com.sybase.jdbc3.jdbc.SybDriver" />
<property name="url" value="jdbc:sybase:Tds:BEHEMOTH:5000/PureFees" />
<property name="username" value="sa" />
<property name="password" value="password" />
</bean>

<bean id="hibernateSessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource" ref="hibernateDataSource" />
<property name="mappingResources">
<list>
<value>UserType.hbm.xml</value>
</list>
</property>
</bean>

<bean id="userTypeDAO" class="com.purefacts.db.hibernate.implementation.UserTypeDAOImpl">
<property name="sessionFactory" ref="hibernateSessionFactory" />
</bean>

</beans>

-------------------------
UserType.hbm.xml
-------------------------
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE sqlMap PUBLIC "-//iBATIS.com//DTD SQL Map 2.0//EN" "http://www.ibatis.com/dtd/sql-map-2.dtd">

<sqlMap namespace="UserType">

<cacheModel id="oneDayUserType" type="MEMORY">
<flushInterval hours="24" />
<property name="reference-type" value="WEAK" />
</cacheModel>

<resultMap id="result" class="com.purefacts.domain.implementation.UserTypeImpl">
<result property="id" column="ID" columnIndex="1" />
<result property="securityToken" column="SecurityToken" columnIndex="2" />
<result property="token" column="Token" columnIndex="3" />
<result property="active" column="Active" columnIndex="4" />
<result property="createdDate" column="CreatedDate" columnIndex="5" />
<result property="createdBy" column="CreatedBy" columnIndex="6" />
<result property="modifiedDate" column="ModifiedDate" columnIndex="7" />
<result property="modifiedBy" column="ModifiedBy" columnIndex="8" />
</resultMap>

<select id="getUserTypes" resultMap="result">
SELECT DISTINCT ownUserType.ID, ownUserType.SecurityToken, ownUserType.Token, ownUserType.Active, ownUserType.CreatedDate, ownUserType.CreatedBy, ownUserType.ModifiedDate, ownUserType.ModifiedBy FROM ownUserType where ownUserType.Active = '1'
</select>

</sqlMap>

-------------------------
Stack Trace
-------------------------

2009-07-02 09:24:57,285 DEBUG org.springframework.orm.hibernate3.SessionFactoryUtils doGetSession - Opening Hibernate Session
2009-07-02 09:24:57,332 DEBUG org.hibernate.impl.SessionImpl <init> - opened session at timestamp: 12465410972
2009-07-02 09:24:57,332 TRACE org.hibernate.engine.query.QueryPlanCache getHQLQueryPlan - unable to locate HQL query plan in cache; generating (getUserTypes)
2009-07-02 09:24:57,410 DEBUG org.hibernate.hql.ast.QueryTranslatorImpl parse - parse() - HQL: getUserTypes
2009-07-02 09:24:57,410 ERROR org.hibernate.hql.PARSER reportError - line 1:1: unexpected token: getUserTypes
2009-07-02 09:24:57,410 DEBUG org.hibernate.hql.ast.ErrorCounter reportError - line 1:1: unexpected token: getUserTypes
line 1:1: unexpected token: getUserTypes
at org.hibernate.hql.antlr.HqlBaseParser.statement(HqlBaseParser.java:171)
at org.hibernate.hql.ast.QueryTranslatorImpl.parse(QueryTranslatorImpl.java:274)
at org.hibernate.hql.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:182)
at org.hibernate.hql.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:136)
at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:101)
at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:80)
at org.hibernate.engine.query.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:94)
at org.hibernate.impl.AbstractSessionImpl.getHQLQueryPlan(AbstractSessionImpl.java:156)
at org.hibernate.impl.AbstractSessionImpl.createQuery(AbstractSessionImpl.java:135)
at org.hibernate.impl.SessionImpl.createQuery(SessionImpl.java:1651)
at org.springframework.orm.hibernate3.HibernateTemplate$30.doInHibernate(HibernateTemplate.java:923)
at org.springframework.orm.hibernate3.HibernateTemplate.doExecute(HibernateTemplate.java:419)
at org.springframework.orm.hibernate3.HibernateTemplate.executeWithNativeSession(HibernateTemplate.java:374)
at org.springframework.orm.hibernate3.HibernateTemplate.find(HibernateTemplate.java:921)
at org.springframework.orm.hibernate3.HibernateTemplate.find(HibernateTemplate.java:913)
at com.purefacts.db.hibernate.implementation.UserTypeDAOImpl.getUserTypes(UserTypeDAOImpl.java:58)
at com.purefacts.service.implementation.UserTypeServiceImpl.getHibernateUserTypes(UserTypeServiceImpl.java:68)
at com.purefacts.ui.web.action.administration.reference.UserTypeAction.getUserTypes(UserTypeAction.java:169)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at javax.el.BeanELResolver.getValue(BeanELResolver.java:292)
at javax.el.CompositeELResolver.getValue(CompositeELResolver.java:143)
at com.sun.faces.el.FacesCompositeELResolver.getValue(FacesCompositeELResolver.java:72)
at com.sun.el.parser.AstValue.getValue(Unknown Source)
at com.sun.el.ValueExpressionImpl.getValue(Unknown Source)
at com.sun.facelets.el.TagValueExpression.getValue(TagValueExpression.java:71)
at javax.faces.component.UIData.getValue(UIData.java:609)
at org.ajax4jsf.component.UIDataAdaptor.getValue(UIDataAdaptor.java:1624)
at org.ajax4jsf.component.SequenceDataAdaptor.getDataModel(SequenceDataAdaptor.java:65)
at org.richfaces.component.UIExtendedDataTable.resetDataModel(UIExtendedDataTable.java:390)
at org.ajax4jsf.component.UIDataAdaptor.beforeRenderResponse(UIDataAdaptor.java:1633)
at org.richfaces.component.UIExtendedDataTable.beforeRenderResponse(UIExtendedDataTable.java:412)
at org.ajax4jsf.component.RenderPhaseUIDataAdaptorVisitor.beforeComponent(RenderPhaseUIDataAdaptorVisitor.java:44)
at org.richfaces.event.RenderPhaseComponentListener.processComponents(RenderPhaseComponentListener.java:47)
at org.richfaces.event.RenderPhaseComponentListener.processComponents(RenderPhaseComponentListener.java:55)
at org.richfaces.event.RenderPhaseComponentListener.processComponents(RenderPhaseComponentListener.java:55)
at org.richfaces.event.RenderPhaseComponentListener.processComponents(RenderPhaseComponentListener.java:55)
at org.richfaces.event.RenderPhaseComponentListener.processComponents(RenderPhaseComponentListener.java:55)
at org.richfaces.event.RenderPhaseComponentListener.processComponents(RenderPhaseComponentListener.java:55)
at org.richfaces.event.RenderPhaseComponentListener.processComponents(RenderPhaseComponentListener.java:55)
at org.richfaces.event.RenderPhaseComponentListener.processComponents(RenderPhaseComponentListener.java:55)
at org.richfaces.event.RenderPhaseComponentListener.processComponents(RenderPhaseComponentListener.java:55)
at org.richfaces.event.RenderPhaseComponentListener.processComponents(RenderPhaseComponentListener.java:55)
at org.richfaces.event.RenderPhaseComponentListener.processComponents(RenderPhaseComponentListener.java:55)
at org.richfaces.event.RenderPhaseComponentListener.processComponents(RenderPhaseComponentListener.java:55)
at org.richfaces.event.RenderPhaseComponentListener.processComponents(RenderPhaseComponentListener.java:55)
at org.richfaces.event.RenderPhaseComponentListener.processComponents(RenderPhaseComponentListener.java:55)
at org.richfaces.event.RenderPhaseComponentListener.beforePhase(RenderPhaseComponentListener.java:71)
at org.ajax4jsf.component.AjaxViewRoot.processPhaseListeners(AjaxViewRoot.java:185)
at org.ajax4jsf.component.AjaxViewRoot.encodeBegin(AjaxViewRoot.java:502)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:928)
at com.sun.facelets.FaceletViewHandler.renderView(FaceletViewHandler.java:571)
at org.ajax4jsf.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:100)
at org.ajax4jsf.application.AjaxViewHandler.renderView(AjaxViewHandler.java:176)
at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:110)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:100)
at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:266)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
at org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:178)
at org.ajax4jsf.webapp.BaseFilter.handleRequest(BaseFilter.java:290)
at org.ajax4jsf.webapp.BaseFilter.processUploadsAndHandleRequest(BaseFilter.java:368)
at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:495)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:215)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
at org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:378)
at org.springframework.security.intercept.web.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:109)
at org.springframework.security.intercept.web.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:83)
at org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:390)
at org.springframework.security.ui.SessionFixationProtectionFilter.doFilterHttp(SessionFixationProtectionFilter.java:67)
at org.springframework.security.ui.SpringSecurityFilter.doFilter(SpringSecurityFilter.java:53)
at org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:390)
at org.springframework.security.ui.ExceptionTranslationFilter.doFilterHttp(ExceptionTranslationFilter.java:101)
at org.springframework.security.ui.SpringSecurityFilter.doFilter(SpringSecurityFilter.java:53)
at org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:390)
at org.springframework.security.providers.anonymous.AnonymousProcessingFilter.doFilterHttp(AnonymousProcessingFilter.java:105)
at org.springframework.security.ui.SpringSecurityFilter.doFilter(SpringSecurityFilter.java:53)
at org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:390)
at org.springframework.security.ui.rememberme.RememberMeProcessingFilter.doFilterHttp(RememberMeProcessingFilter.java:116)
at org.springframework.security.ui.SpringSecurityFilter.doFilter(SpringSecurityFilter.java:53)
at org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:390)
at org.springframework.security.wrapper.SecurityContextHolderAwareRequestFilter.doFilterHttp(SecurityContextHolderAwareRequestFilter.java:91)
at org.springframework.security.ui.SpringSecurityFilter.doFilter(SpringSecurityFilter.java:53)
at org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:390)
at org.springframework.security.ui.basicauth.BasicProcessingFilter.doFilterHttp(BasicProcessingFilter.java:174)
at org.springframework.security.ui.SpringSecurityFilter.doFilter(SpringSecurityFilter.java:53)
at org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:390)
at org.springframework.security.ui.AbstractProcessingFilter.doFilterHttp(AbstractProcessingFilter.java:277)
at org.springframework.security.ui.SpringSecurityFilter.doFilter(SpringSecurityFilter.java:53)
at org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:390)
at org.springframework.security.ui.logout.LogoutFilter.doFilterHttp(LogoutFilter.java:89)
at org.springframework.security.ui.SpringSecurityFilter.doFilter(SpringSecurityFilter.java:53)
at org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:390)
at org.springframework.security.context.HttpSessionContextIntegrationFilter.doFilterHttp(HttpSessionContextIntegrationFilter.java:235)
at org.springframework.security.ui.SpringSecurityFilter.doFilter(SpringSecurityFilter.java:53)
at org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:390)
at org.springframework.security.util.FilterChainProxy.doFilter(FilterChainProxy.java:175)
at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:236)
at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:167)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:215)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:210)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:174)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:108)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:151)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:870)
at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:665)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:528)
at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:81)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:685)
at java.lang.Thread.run(Thread.java:619)
2009-07-02 09:24:57,410 DEBUG org.springframework.orm.hibernate3.SessionFactoryUtils closeSession - Closing Hibernate Session
2009-07-02 09:24:57,410 TRACE org.hibernate.impl.SessionImpl close - closing session
2009-07-02 09:24:57,426 TRACE org.hibernate.jdbc.ConnectionManager cleanup - connection already null in cleanup : no action


Top
 Profile  
 
 Post subject: Re: Hibernate unexpected token
PostPosted: Thu Jul 02, 2009 10:40 am 
Newbie

Joined: Tue Jun 30, 2009 10:13 am
Posts: 6
Please ignore.

I was mixing up two different examples from the Spring documentation and was trying to use the iBatis framework, when I went to the base Hibernate and provide the correct mapping (see below), things started falling into place PDQ.



-------------------------
UserType.hbm.xml
-------------------------

<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">

<hibernate-mapping package="com.purefacts.domain.implementation">

<class name="UserTypeImpl" table="ownUserType">

<id name="id" column="ID">
<generator class="native"/>
</id>
<property name="securityToken" column="SecurityToken" />
<property name="token" column="Token" />
<property name="active" column="Active" />
<property name="creationDate" column="CreatedDate" />
<property name="modificationDate" column="ModifiedDate" />

</class>

</hibernate-mapping>


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.