-->
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.  [ 1 post ] 
Author Message
 Post subject: QuerySyntaxException unexpected token - hibernate mapping
PostPosted: Thu Jan 19, 2012 3:37 pm 
Newbie

Joined: Wed Aug 24, 2011 5:19 pm
Posts: 4
I am seeing a weird behavior with my hibernate queries and alias name in the hibernate query. Below is what i am trying to do..

<hibernate-mapping>

<class name="com.sample.domain.person.Person" table="person" schema="person">

<id name="id" type="long" column="id">
<generator class="sequence">
<param name="sequence">person_seq</param>
<param name="schema">person</param>
</generator>
</id>
<property name="name" column="name" type="string"/>

</class>
<query name="getPersonByName">
<![CDATA[
SELECT person FROM Person AS person WHERE person.name = :name
]]>
</query>

</hibernate-mapping>


And I have a unit test to test this query..when run the unit test , i am getting below exception..any idea why its happening. But It works fine if i use any alias name other than the "person"..

[2012-01-19 11:20:39,590] [main] ERROR org.hibernate.impl.SessionFactoryImpl:422 Error in named query: getPersonByName
org.hibernate.hql.ast.QuerySyntaxException: unexpected token: person near line 3, column 13 [

SELECT person FROM com.sample.domain.person.Person AS person WHERE person.name = :name

]


Any ideas? Is it because, the alias name is same as schema or class etc? or because my package and schema are defined in "class" element instead of hibernate mapping..

Thank you


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

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.