-->
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.  [ 3 posts ] 
Author Message
 Post subject: Getting the same record in search
PostPosted: Sat Feb 09, 2008 7:37 pm 
Newbie

Joined: Sat Feb 09, 2008 7:11 pm
Posts: 2
Location: Mexico
Hi, I have a very annoying issue, I have a simple catalog, and I want to get all the values for that catalog, but I am getting the same record over and over, for instance, I have 4 values in the catalog, and I am getting the same value 4 times. I am using the latest versions of hibernate and spring. This is used in an application in swing connecting via spring to an oracle application server.


Here are my mappings
Code:
<hibernate-mapping>
    <class name="Listavalores" table="listavalores">
        <id name="idlistavalores" type="int">
            <column name="idlistavalores" />
            <generator class="increment" />
        </id>
        <property name="secuencia" type="java.lang.Short">
            <column name="secuencia" />
        </property>
        <property name="desclistavalores" type="string">
           <column name="desclistavalores" length="200" not-null="true" />
        </property>
        <property name="estatuslistavalores" type="java.lang.Short">
            <column name="estatuslistavalores" />
        </property>
    </class>
</hibernate-mapping>


and currently I just want to have a select all query and I am using this:

Code:
List result = getHibernateTemplate().find("from Listavalores");


I would really appreciate any help, I am already frustrated with this issue, and I still haven't been even near to a solution.

thanks alot


Top
 Profile  
 
 Post subject:
PostPosted: Sun Feb 10, 2008 3:52 am 
Expert
Expert

Joined: Mon Nov 26, 2007 2:29 pm
Posts: 443
Aztek56 ,

En tu mensaje no hay nada que explique la causa del problema. Debería funcionar correctamente.
Algunas ideas:

- si es en absoluto posible, no uses HibernateTemplate. Es obsoleto, te conviene obtener la sesión directamente con SessionUtils.getCurrentSession()

- en tu clase, asegúrate de que hashCode y equals estén definidos, y preferentemente utiliza columnas que no sean el ID generado (es decir, columnas que tengan "significado de negocios").

- pregunta tonta, pero ¿cómo estás recorriendo la lista de resultado? Por ahí el problema radica en eso.

- chequea también que los valores en la tabla sean realmente distintos. Podría ser que lo único que difiere sea el ID y todo lo demás fuese igual.

_________________
Gonzalo Díaz


Top
 Profile  
 
 Post subject: Same record
PostPosted: Wed Feb 27, 2008 12:42 am 
Newbie

Joined: Sat Feb 09, 2008 7:11 pm
Posts: 2
Location: Mexico
Thanks for the reply, and I found the reason.. it was that this table had a compund key, so to solve the problem i just created the PK object and fixed the mapping. Having done that, the issue was solved.

Code:
<composite-id name="key" class="com.sictel.core.dto.ListavaloresPK" >
        <key-property name="idlistavalores" type="int" column="idlistavalores" />
        <key-property name="secuencia" type="java.lang.Short" column="secuencia" />
      </composite-id>


Hope this helps someone else. if you have any issue please contact me and I can help you through


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