Hello,
I have taken the Hibernate generated sql and run it in sql plus to verify that it works and it does. However, when I run the junit tests, Hibernate returns the correct number of rows, but, it all the first row, just repeated 15 times.
The only things that I could possibly suspect is the float? I thought it was the fact that there was a clob, but I removed it, and the same behavior is happening.
Output from Hibernate JUnit Test:
[junit] DEBUG - TaskDaoImplTest.testFindPartsByTask(66) | The task index: 24595.0
[junit] DEBUG - TaskDaoImplTest.testFindPartsByTask(67) | The part Number: 1234_123_1234
[junit] DEBUG - TaskDaoImplTest.testFindPartsByTask(68) | The part cname: TEST_IT
[junit] DEBUG - TaskDaoImplTest.testFindPartsByTask(66) | The task index: 24595.0
[junit] DEBUG - TaskDaoImplTest.testFindPartsByTask(67) | The part Number: 1234_123_1234
[junit] DEBUG - TaskDaoImplTest.testFindPartsByTask(68) | The part cname: TEST_IT
[junit] DEBUG - TaskDaoImplTest.testFindPartsByTask(66) | The task index: 24595.0
[junit] DEBUG - TaskDaoImplTest.testFindPartsByTask(67) | The part Number: 1234_123_1234
[junit] DEBUG - TaskDaoImplTest.testFindPartsByTask(68) | The part cname: TEST_IT
[junit] DEBUG - TaskDaoImplTest.testFindPartsByTask(66) | The task index: 24595.0
[junit] DEBUG - TaskDaoImplTest.testFindPartsByTask(67) | The part Number: 1234_123_1234
[junit] DEBUG - TaskDaoImplTest.testFindPartsByTask(68) | The part cname: TEST_IT
[junit] DEBUG - TaskDaoImplTest.testFindPartsByTask(66) | The task index: 24595.0
[junit] DEBUG - TaskDaoImplTest.testFindPartsByTask(67) | The part Number: 1234_123_1234
[junit] DEBUG - TaskDaoImplTest.testFindPartsByTask(68) | The part cname: TEST_IT
[junit] DEBUG - TaskDaoImplTest.testFindPartsByTask(66) | The task index: 24595.0
[junit] DEBUG - TaskDaoImplTest.testFindPartsByTask(67) | The part Number: 1234_123_1234
[junit] DEBUG - TaskDaoImplTest.testFindPartsByTask(68) | The part cname: TEST_IT
[junit] DEBUG - TaskDaoImplTest.testFindPartsByTask(66) | The task index: 24595.0
[junit] DEBUG - TaskDaoImplTest.testFindPartsByTask(67) | The part Number: 1234_123_1234
[junit] DEBUG - TaskDaoImplTest.testFindPartsByTask(68) | The part cname: TEST_IT
[junit] DEBUG - TaskDaoImplTest.testFindPartsByTask(66) | The task index: 24595.0
[junit] DEBUG - TaskDaoImplTest.testFindPartsByTask(67) | The part Number: 1234_123_1234
[junit] DEBUG - TaskDaoImplTest.testFindPartsByTask(68) | The part cname: TEST_IT
[junit] DEBUG - TaskDaoImplTest.testFindPartsByTask(66) | The task index: 24595.0
[junit] DEBUG - TaskDaoImplTest.testFindPartsByTask(67) | The part Number: 1234_123_1234
[junit] DEBUG - TaskDaoImplTest.testFindPartsByTask(68) | The part cname: TEST_IT
[junit] DEBUG - TaskDaoImplTest.testFindPartsByTask(66) | The task index: 24595.0
[junit] DEBUG - TaskDaoImplTest.testFindPartsByTask(67) | The part Number: 1234_123_1234
[junit] DEBUG - TaskDaoImplTest.testFindPartsByTask(68) | The part cname: TEST_IT
[junit] DEBUG - TaskDaoImplTest.testFindPartsByTask(66) | The task index: 24595.0
[junit] DEBUG - TaskDaoImplTest.testFindPartsByTask(67) | The part Number: 1234_123_1234
[junit] DEBUG - TaskDaoImplTest.testFindPartsByTask(68) | The part cname: TEST_IT
[junit] DEBUG - TaskDaoImplTest.testFindPartsByTask(66) | The task index: 24595.0
[junit] DEBUG - TaskDaoImplTest.testFindPartsByTask(67) | The part Number: 1234_123_1234
[junit] DEBUG - TaskDaoImplTest.testFindPartsByTask(68) | The part cname: TEST_IT
Below is a sample of the output that comes directly from the database:
TASK_INDEX PART_NUMBER COMMON_NAME
---------- -------------------- ----------------------------------------
24595 1234_123_1234 TEST_IT
24595 893_234_12344 WIDGET
24595 3333333333333333 GADGET
....
...
...
(15 different rows)
HELP!!!!
Hibernate version:
3.1
Mapping documents:
<?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 package="com.company.application.model.impl">
<class name="TaskImpl" table="MICKY" entity-name="Task" mutable='false'>
<id name="index" column="T_INDEX" type="float"/>
<property name="partNumber" column='PART_NUMBER' />
<property name='cName' column='COMMON_NAME'/>
</class>
</hibernate-mapping>
Code:
public class TaskImpl implements Task
{
private float index;
private String partNumber;
private String description;
private String cname;
public float getIndex(){
return index;
}
public void setIndex(float index){
this.index = index;
}
public String getPartNumber()
{
return partNumber;
}
public void setPartNumber(String partNumber)
{
this.partNumber = partNumber;
}
public String getCName()
{
return this.cname;
}
public void setCName(String cname)
{
this.cname = cname;
}
Code:
package com.company.application.dao;
import java.util.List;
import com.company.application.model.Task;
public interface TaskDao
{
public List<Task> getPartsByTask(Float taskIndex);
}
Code between sessionFactory.openSession() and session.close():Code:
Session session = this.getSession();
List<Task> temp = session.createQuery("select t from Task t where index = :index order by t.partNumber, t.cName")
.setFloat("index", inIndex)
.list();
session.close();
return temp;
Full stack trace of any exception that occurs:Name and version of the database you are using:Oracle 10XE
The generated SQL (show_sql=true): select
task0_.TASK_INDEX as TASK1_4_,
task0_.PART_NUMBER as PART2_4_,
task0_.COMMON_NAME as COMMON3_4_
from
MICKY task0_
where
task0_.TASK_INDEX=?
order by
task0_.PART_NUMBER,
task0_.COMMON_NAME
SQL> desc micky
Name Null? Type
----------------------------------------- -------- ----------------------------
TASK_INDEX FLOAT(126)
PART_NUMBER VARCHAR2(32)
COMMON_NAME VARCHAR2(100)
SQL>
Code: