Hello all.
I've had queries working in my hibernate projects before when I used it about 6 months ago. For some reason now I'm always getting the same exception regardless which (of the 2) classes I try to query on now. I'm hoping somebody will have some insight to point me in the right direction.
I can successfully load() an object, even update() an object, but I cannot run a query. I have hibernate2.jar installed in my jboss default app's lib folder (and its dependencies as far as i can tell).
Here is the code that executes the query...
Code:
Query q = session.createQuery("select u from Users as u where u.userName = 'somename'");
q.setMaxResults(10);
for (Iterator it = q.iterate(); it.hasNext();)
{
UserTO user = (UserTO) it.next();
}
Here is the exception that is thrown...
Message : 16:14:10,015 INFO [STDOUT] unexpected token: as [select u from Users as u where u.userName = 'somename']
If you need the rest of the stack trace let me know (it's long so I don't want to clutter this message).
Here is a snip from my mapping file...
Code:
<hibernate-mapping>
<class name="qnext.bo.database.to.UserTO" table="users" dynamic-update="true" lazy="true">
<id column="UID" name="UID" type="java.lang.Long">
<generator class="native"/>
</id>
<property column="username" length="50" name="userName" type="java.lang.String"/>
<property column="password" length="50" name="password" type="java.lang.String"/>
<property column="detectedip" length="15" name="detectedIP" type="java.lang.String"/>
<property column="ip" length="15" name="reportedIP" type="java.lang.String"/>
<property column="PROXY" length="1" name="proxy" type="java.lang.String"/>
<property column="proxylist" length="16277215" name="proxyList" type="java.lang.String"/>
<property column="PRIVATEID" length="11" name="privateID" type="java.lang.Integer"/>
<property column="SESSIONID" length="11" name="sessionID" type="java.lang.Integer"/>
I hope you can see what I'm doing wrong. I'm going batty! I may end up getting the source code to hibernate to solve this, but this seems like overkill to me.
Thanks,
Mal.