Beginner |
|
Joined: Fri Jan 07, 2005 2:47 pm Posts: 45
|
Hibernate version:
Hibernate2
Mapping documents:
none
Code between sessionFactory.openSession() and session.close():
Full stack trace of any exception that occurs:
Name and version of the database you are using:
The generated SQL (show_sql=true):
done
Debug level Hibernate log excerpt:
MY QUESTION:
This is my User.hbm.xml file. I need to get the user information using the username as the criteria. Since the username is a property of the Password class how do I write the native SQL show below to an HQL???
When I tried the following HQL
(List finds = session.find("from User user where user.username = username");
query.setString("username", username);
I got an error saying that the username is not a property of the User class. Can you help????
Native SQL:
Select *
from x_requestors
where x_requestors.username = 'username'
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping
PUBLIC "-//Hibernate/Hibernate Mapping DTD//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">
<hibernate-mapping
package="SAP.BusinessObjects"
default-cascade="save-update">
<class name="User" table="X_REQUESTORS">
<id name="userid"
column= "REQ_ID"
type="java.lang.String"
length="20">
<generator class="SAP.DAOObjects.SeqGeneratorUser"/>
</id>
<property name="lastname"
type="java.lang.String"
length="50"
not-null="true"
column="LAST_NAME"
update="true"
insert="true"/>
<property name="firstname"
type="java.lang.String"
length="50"
not-null="true"
column="FIRST_NAME"
update="true"
insert="true"/>
<component name="pswd" class="Password">
<property name="password"
type="java.lang.String"
length="100"
not-null="false"
column="PSWD"
update="true"
insert="true"/>
<property name="username"
type="java.lang.String"
length="10"
not-null="false"
column="USERNAME"
update="true"
insert="true"/>
</component>
<component name="address" class="Address">
<property name="email"
type="java.lang.String"
length="25"
column="EMAIL"/>
</component>
<many-to-one name="site"
class="Site"
cascade="all"
column= "PRIM_LOC" />
</class>
</hibernate-mapping>
|
|