Trying to write a query to get a user by email address. I have the following and am getting the error below:
Hibernate version: 3.2.3
<?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 schema="DBO_FSOL">
<class name="com.futuresoldiers.struts.form.TempRegistrationForm" table="USERNAME">
<id name="tempUserId" type="long" column="USERNAME_ID">
<generator class="com.futuresoldiers.dao.hibernate.TriggerAssignedIdentityGenerator"/>
</id>
<property name="emailAddress" type="string" column="EMAIL_TX"/>
<property name="firstName" type="string" column="FIRST_NAME_TX"/>
<property name="lastName" type="string" column="LAST_NAME_TX"/>
<property name="status" type="string" column="STATUS_CD"/>
<property name="dateOfBirth" type="date" column="DOB_DT"/>
<property name="createdByUser" type="string" column="CREATE_BY"/>
<property name="modifiedByUser" type="string" column="MOD_BY"/>
<join table="ADDRESS">
<key>
<column name="USERNAME_ID" not-null="true"/>
</key>
<property name="address1" type="string" column="ADDRESS1_TX"/>
<property name="address2" type="string" column="ADDRESS2_TX"/>
<property name="city" type="string" column="CITY_TX"/>
<property name="state" type="string" column="STATE_CD"/>
<property name="zipCode" type="string" column="ZIP_CD"/>
<property name="createdByAddress" type="string" column="CREATE_BY"/>
<property name="modifiedByAddress" type="string" column="MOD_BY"/>
</join>
</class>
</hibernate-mapping>
CODE
temp = (TempRegistrationForm) session.createQuery("select\n" + "UN.USERNAME_ID,UN.EMAIL_TX,UN.FIRST_NAME_TX,UN.LAST_NAME_TX,\n" + "UN.STATUS_CD,UN.DOB_DT,AD.ADDRESS1_TX,AD.ADDRESS2_TX,\n" +
"AD.CITY_TX,AD.STATE_CD,AD.ZIP_CD\n" +
"from\n" +
"DBO_FSOL.USERNAME UN,\n" +
"DBO_FSOL.ADDRESS AD\n" +
"where UN.USERNAME_ID=AD.USERNAME_ID\n" +
"and UN.USERNAME_ID=" + emailAddress)
.uniqueResult();
ERROR
stdout: - building session factory
[12/Jun/2007:15:46:48] info ( 1113): CORE3282: stdout: - Not binding factory to JNDI, no JNDI name configured
[12/Jun/2007:15:46:49] info ( 1113): CORE3282: stdout: - Unhandled Exception thrown: class java.lang.NullPointerException
[12/Jun/2007:15:46:49] warning ( 1113): CORE3283: stderr: org.hibernate.hql.ast.QuerySyntaxException: DBO_FSOL.USERNAME is not mapped [select
[12/Jun/2007:15:46:49] warning ( 1113): CORE3283: stderr: UN.USERNAME_ID,UN.EMAIL_TX,UN.FIRST_NAME_TX,UN.LAST_NAME_TX,
[12/Jun/2007:15:46:49] warning ( 1113): CORE3283: stderr: UN.STATUS_CD,UN.DOB_DT,AD.ADDRESS1_TX,AD.ADDRESS2_TX,
[12/Jun/2007:15:46:49] warning ( 1113): CORE3283: stderr: AD.CITY_TX,AD.STATE_CD,AD.ZIP_CD
[12/Jun/2007:15:46:49] warning ( 1113): CORE3283: stderr: from
[12/Jun/2007:15:46:49] warning ( 1113): CORE3283: stderr: DBO_FSOL.USERNAME UN,
[12/Jun/2007:15:46:49] warning ( 1113): CORE3283: stderr: DBO_FSOL.ADDRESS AD
[12/Jun/2007:15:46:49] warning ( 1113): CORE3283: stderr: where UN.USERNAME_ID=AD.USERNAME_ID
[12/Jun/2007:15:46:49] warning ( 1113): CORE3283: stderr: and UN.USERNAME_ID=brian.beech]
[12/Jun/2007:15:46:49] warning ( 1113): CORE3283: stderr: at org.hibernate.hql.ast.util.SessionFactoryHelper.requireClassPersister(SessionFactoryHelper.java:158)
[12/Jun/2007:15:46:49] warning ( 1113): CORE3283: stderr: at org.hibernate.hql.ast.tree.FromElementFactory.addFromElement(FromElementFactory.java:87)
[12/Jun/2007:15:46:49] warning ( 1113): CORE3283: stderr: at org.hibernate.hql.ast.tree.FromClause.addFromElement(FromClause.java:70)
[12/Jun/2007:15:46:49] warning ( 1113): CORE3283: stderr: at org.hibernate.hql.ast.HqlSqlWalker.createFromElement(HqlSqlWalker.java:255)
[12/Jun/2007:15:46:49] warning ( 1113): CORE3283: stderr: at org.hibernate.hql.antlr.HqlSqlBaseWalker.fromElement(HqlSqlBaseWalker.java:3056)
[12/Jun/2007:15:46:49] warning ( 1113): CORE3283: stderr: at org.hibernate.hql.antlr.HqlSqlBaseWalker.fromEl
|