-->
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.  [ 2 posts ] 
Author Message
 Post subject: Rows are all repeated?
PostPosted: Mon Mar 20, 2006 4:25 pm 
Newbie

Joined: Sat Mar 04, 2006 1:13 am
Posts: 5
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:


Top
 Profile  
 
 Post subject: Re: Rows are all repeated?
PostPosted: Tue Mar 21, 2006 12:23 pm 
Newbie

Joined: Sat Mar 04, 2006 1:13 am
Posts: 5
I'm an idiot, the answer was that the mapping file made index the key, instead of part number. Once I flipped that, it worked, it did bring up another issue that I have found about clobs and distinct throwing an
ORA-00932: inconsistent datatypes: expected - got CLOB, but I will work around that one.

Thanks to all that looked. Sorry for taking any of your time.



mwilliamson wrote:
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:


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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.