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
|