-->
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.  [ 5 posts ] 
Author Message
 Post subject: problem with hibernate dao method
PostPosted: Thu Jan 22, 2009 5:21 pm 
Newbie

Joined: Thu Jan 22, 2009 5:10 pm
Posts: 3
Hi
I dont know why the results variable return null!!!!!
please help me.
thank you

hibernate 3.1

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<!--
Mapping file autogenerated by MyEclipse Persistence Tools
-->
<hibernate-mapping>
<class name="com.university.dto.EmployeesDTO" table="EMPLOYEES" schema="AMEDA">
<id name="employeeId" type="java.lang.Long">
<column name="EMPLOYEE_ID" precision="22" scale="0" />
<generator class="sequence">
<param name="sequence">EMPLOYEE_SEQUENCE</param>
</generator>
</id>
<property name="employeeFirstName" type="java.lang.String">
<column name="EMPLOYEE_FIRST_NAME" length="200" />
</property>
<property name="employeeLastName" type="java.lang.String">
<column name="EMPLOYEE_LAST_NAME" length="200" />
</property>
<property name="employeeDob" type="java.util.Date">
<column name="EMPLOYEE_DOB" length="7" />
</property>
<property name="employeeUsername" type="java.lang.String">
<column name="EMPLOYEE_USERNAME" length="50" not-null="true" unique="true" />
</property>
<property name="employeePassword" type="java.lang.String">
<column name="EMPLOYEE_PASSWORD" length="32" not-null="true" />
</property>
<property name="employeeIsAdmin" type="java.lang.Long">
<column name="EMPLOYEE_IS_ADMIN" precision="38" scale="0" />
</property>
<set name="departmentses" inverse="true" fetch="select">
<key>
<column name="EMPLOYEE_ID_FK" precision="22" scale="0" />
</key>
<one-to-many class="com.university.dto.DepartmentsDTO" />
</set>
</class>
</hibernate-mapping>




public List findByExample(EmployeesDTO instance) {
log.debug("finding EmployeesDTO instance by example");
try {
List results = getSession().createCriteria(
"com.university.dto.EmployeesDTO").add(Example.create(instance))
.list();
log.debug("find by example successful, result size: "
+ results.size());
return results;
} catch (RuntimeException re) {
log.error("find by example failed", re);
throw re;
}
}


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 22, 2009 6:57 pm 
Regular
Regular

Joined: Tue Dec 30, 2008 8:14 pm
Posts: 50
Example would try to match all value-typed properties of User, excluding the identifier. If you have id, firstName and lastName in the User, and set only id, the result would be null - assuming id is the identifier.

---
Please rate


Top
 Profile  
 
 Post subject: problem with hibernate dao method
PostPosted: Fri Jan 23, 2009 4:38 am 
Newbie

Joined: Thu Jan 22, 2009 5:10 pm
Posts: 3
thank you linHib for your responce.
I fill username,password,and choose admin with value 1 and press submit.
the id identifier is sequence but results return null.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 23, 2009 11:49 am 
Regular
Regular

Joined: Tue Dec 30, 2008 8:14 pm
Posts: 50
If you enable show_sql in the hibernate config, ("<property name="show_sql">true</property>") you will be able to see the generate SQL. In this case, the generated query would check EMPLOYEE_FIRST_NAME=null, EMPLOYEE_LAST_NAME=null and EMPLOYEE_DOB=null, and return null result.
If you are only interested in the EMPLOYEE_USERNAME, EMPLOYEE_PASSWORD and EMPLOYEE_IS_ADMIN, Criteria query may be better than Example.

---
please rate


Top
 Profile  
 
 Post subject: I found
PostPosted: Sun Jan 25, 2009 5:02 am 
Newbie

Joined: Thu Jan 22, 2009 5:10 pm
Posts: 3
thank you veeeeeeeeeeeeeeeeery much linHib.


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

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.