-->
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.  [ 1 post ] 
Author Message
 Post subject: weird case with org.hibernate.WrongClassException
PostPosted: Fri Mar 30, 2007 8:04 am 
Newbie

Joined: Mon Mar 12, 2007 8:47 pm
Posts: 5
Hi guys

my cousin and me are in a project and we are in madness problem

read carefully the explanation, we are out of ideas to resolve this

i am very worry about of this message
Quote:
Hibernate: select detalleent0_.idDetalleAlmacen as idDetall1_7_0_, detalleent0_.idArticulo as idArticulo7_0_, detalleent0_.cantidad as cantidad7_0_, detalleent0_.preciounitario as precioun5_7_0_, detalleent0_.subtotal as subtotal7_0_, detalleent0_.idnumero as idnumero7_0_, detalleent0_.serie as serie7_0_, detalleent0_.idHistorialArticulo as idHistor9_7_0_ from DetalleAlmacen detalleent0_ where detalleent0_.idHistorialArticulo=? and detalleent0_.tipo='DETENTALM'
14:41:13 WARN org.directwebremoting.impl.DefaultRemoter warn Method execution failed:
org.hibernate.WrongClassException: Object with id: 111400E was not of the specified subclass: com.lagranjita.modelo.entidades.DetalleEntradaAlma cen (loaded object was of wrong class class com.lagranjita.modelo.entidades.DetalleSalidaAlmac en)
at org.hibernate.loader.Loader.instanceAlreadyLoaded( Loader.java:1234)
at org.hibernate.loader.Loader.getRow(Loader.java:118 6)


Quote:
idHistor9_7_0_ from DetalleAlmacen detalleent0_ where detalleent0_.idHistorialArticulo=? and detalleent0_.tipo='DETENTALM'

worry here becasue the obhect that i am using is "DETSALALM" and not "DETENTALM"

Quote:
at org.hibernate.loader.Loader.instanceAlreadyLoaded( Loader.java:1234)

why???

for your information i have these set of classes

sorry for my grammar

2 super classes called DetalleAlmacen (DetailWareHouse) and HistorialArticulo (HistoryArticle)
each of them has 2 subclasses

so DetalleAlmacen has DetalleEntradaAlmacen and DetalleSalidaAlmacen
(Entrada=Entry , Salida=out/retire )
and HistorialArticulo has how subclasses HistorialEntradaArticulo and HistorialSalidaArticulo

now each subclasseshas a relation one-to-one
in this way
DetalleEntradaAlmacen with HistorialEntradaArticulo
and
DetalleSalidaAlmacen with HistorialSalidaArticulo

so for each creation of one move/transaction of the warehouse, i create a document
with its header (CabeceraCAlmacen C=Entrada or Salida, depends the case)
so if i insert a product to the warehouse
it follows the next process
1: create a DetalleEntradaAlmacen
2: update stock of article
3: create a HistorialEntradaArticulo

the service method work with 3 BO and each of them with 3 DAO methods, the third DAO method is the source of this pain

Code:
public void insertarHistorialSalidaArticuloDAO(String idArticulo, String idDetalleAlmacen)
   throws MyGlobalException{
   HistorialSalidaArticulo historialSalidaArticulo=null;
   try{
         
      historialSalidaArticulo = new HistorialSalidaArticulo();
         
      Articulo articulo = (Articulo) getHibernateTemplate().get(Articulo.class,idArticulo);
      if(articulo==null)
         throw new MyFinderException();   
         
      logger.info("insertarHistorialSalidaArticuloDAO idDetalleAlmacen"+idDetalleAlmacen);
      DetalleSalidaAlmacen  detalleSalidaAlmacen = (DetalleSalidaAlmacen)  getHibernateTemplate().get(
            DetalleSalidaAlmacen.class, idDetalleAlmacen);
      if(detalleSalidaAlmacen==null)
         throw new MyFinderException();
      logger.info("insertarHistorialSalidaArticuloDAO detalleSalidaAlmacen: "+detalleSalidaAlmacen.toString());
         
      String idHistorialArticulo = articulo.getIdArticulo().concat(detalleSalidaAlmacen.getIdDetalleAlmacen());
      logger.info("insertarHistorialSalidaArticuloDAO idHistorialArticulo: "+idHistorialArticulo);
      historialSalidaArticulo.setIdHistorialArticulo(idHistorialArticulo);
         
      historialSalidaArticulo.setCantidad(detalleSalidaAlmacen.getCantidad());
      historialSalidaArticulo.setFecha(new Date());
         
      logger.info("before relaciones");
      //relaciones - relations START TO HERE FAILS - se the log report
      articulo.getHistorialArticulos().add(historialSalidaArticulo);
      historialSalidaArticulo.setIdArticulo(articulo);
         
      detalleSalidaAlmacen.setHistorialSalidaArticulo(historialSalidaArticulo);
      historialSalidaArticulo.setDetalleSalidaAlmacen(detalleSalidaAlmacen);
      logger.info("before doom");
      //getHibernateTemplate().saveOrUpdate(detalleSalidaAlmacen);
      getHibernateTemplate().save(historialSalidaArticulo);
         
      }
      catch(DataAccessException dae){
         //System.out.println("");
         logger.info("insertarHistorialSalidaArticuloDAO DataAccessException : "+dae.getMessage());
         dae.printStackTrace();
         throw new MyCreateException();
      }
   }


check //relaciones - relations START TO HERE FAILS - see the log report
from there start the show
so the last log message that i can saw is
logger.info("before relaciones");
but really i cant say in which line thrown the exception
but if this help
this line logger.info("before doom"); is not executed

Quote:
14:41:13 INFO a.modelo.dao.implementaciones.HistorialSalidaArticuloDAOImpl istorialSalidaArticuloDAO insertarHistorialSalidaArticuloDAO idDetalleAlmacen111400S
14:41:13 INFO a.modelo.dao.implementaciones.HistorialSalidaArticuloDAOImpl istorialSalidaArticuloDAO insertarHistorialSalidaArticuloDAO detalleSalidaAlmacen:
idDetalleAlmacen: 111400S
cantidad: 5
preciounitario: 5
subtotal:25.00

DetalleSalidaAlmacen String toString() - : :p
14:41:13 INFO a.modelo.dao.implementaciones.HistorialSalidaArticuloDAOImpl istorialSalidaArticuloDAO insertarHistorialSalidaArticuloDAO idHistorialArticulo: 11400111400S
14:41:13 INFO a.modelo.dao.implementaciones.HistorialSalidaArticuloDAOImpl istorialSalidaArticuloDAO before relaciones
Hibernate: select historiala0_.idArticulo as idArticulo1_, historiala0_.idHistorialArticulo as idHistor1_1_, historiala0_.idHistorialArticulo as idHistor1_13_0_, historiala0_.idArticulo as idArticulo13_0_, historiala0_.cantidad as cantidad13_0_, historiala0_.fecha as fecha13_0_, historiala0_.tipo as tipo13_0_ from HistorialArticulo historiala0_ where historiala0_.idArticulo=?
Hibernate: select detalleent0_.idDetalleAlmacen as idDetall1_7_0_, detalleent0_.idArticulo as idArticulo7_0_, detalleent0_.cantidad as cantidad7_0_, detalleent0_.preciounitario as precioun5_7_0_, detalleent0_.subtotal as subtotal7_0_, detalleent0_.idnumero as idnumero7_0_, detalleent0_.serie as serie7_0_, detalleent0_.idHistorialArticulo as idHistor9_7_0_ from DetalleAlmacen detalleent0_ where detalleent0_.idHistorialArticulo=? and detalleent0_.tipo='DETENTALM'
14:41:13 WARN org.directwebremoting.impl.DefaultRemoter warn Method execution failed:
org.hibernate.WrongClassException: Object with id: 111400E was not of the specified subclass: com.lagranjita.modelo.entidades.DetalleEntradaAlmacen (loaded object was of wrong class class com.lagranjita.modelo.entidades.DetalleSalidaAlmacen)
at org.hibernate.loader.Loader.instanceAlreadyLoaded(Loader.java:1234)
at org.hibernate.loader.Loader.getRow(Loader.java:1186)


so one of these lines is the blame

Code:
articulo.getHistorialArticulos().add(historialSalidaArticulo);
historialSalidaArticulo.setIdArticulo(articulo);
         
detalleSalidaAlmacen.setHistorialSalidaArticulo(historialSalidaArticulo);
historialSalidaArticulo.setDetalleSalidaAlmacen(detalleSalidaAlmacen);


weird right???
and more fun the catch part, not caught nothing

now this is the part is importnat too, sql report qith a db tool

Quote:
idDetalleAlmacen tipo idArticulo cantidad preciounitario subtotal idnumero serie idHistorialArticulo
------------------- --------- ------------- ----------- ----------------- ----------- ----------- -------- ----------------------
110001E DETENTALM 10001 5 5 25 1 ENT 10001110001E
111001S DETSALALM 11001 5 5 25 1 SAL 11001111001S


for details of the warehouse

110001E is the result after of concat the numer header of the doucument warehouse (1)
the coide of the product(10001) and a simply E (Entry )

here i am fine

the part joke is the other case when i trie to retire the same product
so the code should be 110001S (S = salida = out or retire )

but any for any document, see my log file

Quote:
06:28:49 INFO jita.modelo.dao.implementaciones.DetalleSalidaAlmacenDAOImpl arDetalleSalidaAlmacenDAO insertarDetalleSalidaAlmacenDAO idDetalleAlmacen :210001S
06:28:49 INFO jita.modelo.dao.implementaciones.DetalleSalidaAlmacenDAOImpl arDetalleSalidaAlmacenDAO insertarDetalleSalidaAlmacenDAO detalleSalidaAlmacen.getIdDetalleAlmacen() :210001S
06:28:49 INFO AbstractProcesoMovimientoAlmacenBO tarDetalleSalidaAlmacenBO doProcesoMovimientoInsertarDetalleSalidaAlmacenBO idDetalleAlmacen: 210001S
idArticulo: 10001
06:28:49 INFO a.modelo.dao.implementaciones.HistorialSalidaArticuloDAOImpl istorialSalidaArticuloDAO insertarHistorialSalidaArticuloDAO idDetalleAlmacen210001S
06:28:49 INFO a.modelo.dao.implementaciones.HistorialSalidaArticuloDAOImpl istorialSalidaArticuloDAO insertarHistorialSalidaArticuloDAO detalleSalidaAlmacen:
idDetalleAlmacen: 210001S
cantidad: 5
preciounitario: 5
subtotal:25.00

DetalleSalidaAlmacen String toString() - : :p
06:28:49 INFO a.modelo.dao.implementaciones.HistorialSalidaArticuloDAOImpl istorialSalidaArticuloDAO insertarHistorialSalidaArticuloDAO idHistorialArticulo: 10001210001S
06:28:49 INFO a.modelo.dao.implementaciones.HistorialSalidaArticuloDAOImpl istorialSalidaArticuloDAO before relaciones


and i recieve this error,

Quote:
DetalleSalidaAlmacen String toString() - : :p
06:28:49 INFO a.modelo.dao.implementaciones.HistorialSalidaArticuloDAOImpl istorialSalidaArticuloDAO insertarHistorialSalidaArticuloDAO idHistorialArticulo: 10001210001S
06:28:49 INFO a.modelo.dao.implementaciones.HistorialSalidaArticuloDAOImpl istorialSalidaArticuloDAO before relaciones
Hibernate: select historiala0_.idArticulo as idArticulo1_, historiala0_.idHistorialArticulo as idHistor1_1_, historiala0_.idHistorialArticulo as idHistor1_13_0_, historiala0_.idArticulo as idArticulo13_0_, historiala0_.cantidad as cantidad13_0_, historiala0_.fecha as fecha13_0_, historiala0_.tipo as tipo13_0_ from HistorialArticulo historiala0_ where historiala0_.idArticulo=?
Hibernate: select detalleent0_.idDetalleAlmacen as idDetall1_7_0_, detalleent0_.idArticulo as idArticulo7_0_, detalleent0_.cantidad as cantidad7_0_, detalleent0_.preciounitario as precioun5_7_0_, detalleent0_.subtotal as subtotal7_0_, detalleent0_.idnumero as idnumero7_0_, detalleent0_.serie as serie7_0_, detalleent0_.idHistorialArticulo as idHistor9_7_0_ from DetalleAlmacen detalleent0_ where detalleent0_.idHistorialArticulo=? and detalleent0_.tipo='DETENTALM'
06:28:49 WARN org.directwebremoting.impl.DefaultRemoter warn Method execution failed:
org.hibernate.WrongClassException: Object with id: 110001E was not of the specified subclass: com.lagranjita.modelo.entidades.DetalleEntradaAlmacen (loaded object was of wrong class class com.lagranjita.modelo.entidades.DetalleSalidaAlmacen)
at org.hibernate.loader.Loader.instanceAlreadyLoaded(Loader.java:1234)
at org.hibernate.loader.Loader.getRow(Loader.java:1186)
at org.hibernate.loader.Loader.getRowFromResultSet(Loader.java:568)


i cant understand why Object with id: 110001E is called or tried to use, is not really shouldent be call

Quote:

org.hibernate.WrongClassException:
Object with id: 110001E was not of the specified subclass:
com.lagranjita.modelo.entidades.DetalleEntradaAlmacen
(loaded object was of wrong class class
com.lagranjita.modelo.entidades.DetalleSalidaAlmacen)


thi is madness , in the DAO ( insertarHistorialSalidaArticuloDAO )object i only work with objects of class DetalleSalidaAlmacen (Salida = out/retire) and i cant undestand why is called an object of DetalleEntradaAlmacen (Entrada = Entry)


where for the love of god , appear some DetalleEntradaAlmacen ????
jesus where??!!!!


here the mapping files
Code:
<?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">

<hibernate-mapping
>
    <class
        name="com.lagranjita.modelo.entidades.DetalleAlmacen"
        table="DetalleAlmacen"
        discriminator-value="DETALM"
    >

        <id
            name="idDetalleAlmacen"
            column="idDetalleAlmacen"
            type="java.lang.String"
            length="32"
        >
            <generator class="assigned">
              <!-- 
                  To add non XDoclet generator parameters, create a file named
                  hibernate-generator-params-DetalleAlmacen.xml
                  containing the additional parameters and place it in your merge dir.
              -->
            </generator>
        </id>

        <discriminator
            column="tipo"
            type="string"
            length="10"
        />

        <many-to-one
            name="idArticulo"
            class="com.lagranjita.modelo.entidades.Articulo"
            cascade="none"
            outer-join="auto"
            update="true"
            insert="true"
            column="idArticulo"
            not-null="true"
        />

        <property
            name="cantidad"
            type="java.math.BigDecimal"
            update="true"
            insert="true"
            column="cantidad"
            length="6"
            not-null="true"
        />

        <property
            name="preciounitario"
            type="java.math.BigDecimal"
            update="true"
            insert="true"
            column="preciounitario"
            length="6"
            not-null="true"
        />

        <property
            name="subtotal"
            type="java.math.BigDecimal"
            update="true"
            insert="true"
            column="subtotal"
            length="6"
            not-null="true"
        />

        <!--
            To add non XDoclet property mappings, create a file named
                hibernate-properties-DetalleAlmacen.xml
            containing the additional properties and place it in your merge dir.
        -->
        <subclass
            name="com.lagranjita.modelo.entidades.DetalleEntradaAlmacen"
            discriminator-value="DETENTALM"
        >

        <many-to-one
            name="cabeceraEntradaAlmacen"
            class="com.lagranjita.modelo.entidades.CabeceraEntradaAlmacen"
            cascade="none"
            outer-join="auto"
            update="true"
            insert="true"
        >
            <column
                name="idnumero"
            />
            <column
                name="serie"
            />
        </many-to-one>

        <many-to-one
            name="historialEntradaArticulo"
            class="com.lagranjita.modelo.entidades.HistorialEntradaArticulo"
            cascade="none"
            outer-join="auto"
            update="true"
            insert="true"
            column="idHistorialArticulo"
            not-null="false"
        />

       <!--
               To add non XDoclet property mappings, create a file named
                hibernate-properties-DetalleEntradaAlmacen.xml
      containing the additional properties and place it in your merge dir.
       -->

        </subclass>
        <subclass
            name="com.lagranjita.modelo.entidades.DetalleSalidaAlmacen"
            discriminator-value="DETSALALM"
        >

        <many-to-one
            name="cabeceraSalidaAlmacen"
            class="com.lagranjita.modelo.entidades.CabeceraSalidaAlmacen"
            cascade="none"
            outer-join="auto"
            update="true"
            insert="true"
        >
            <column
                name="idnumero"
            />
            <column
                name="serie"
            />
        </many-to-one>

        <many-to-one
            name="historialSalidaArticulo"
            class="com.lagranjita.modelo.entidades.HistorialSalidaArticulo"
            cascade="none"
            outer-join="auto"
            update="true"
            insert="true"
            column="idHistorialArticulo"
            not-null="false"
        />

       <!--
               To add non XDoclet property mappings, create a file named
                hibernate-properties-DetalleSalidaAlmacen.xml
      containing the additional properties and place it in your merge dir.
       -->

        </subclass>

    </class>

</hibernate-mapping>


HistorialArticulo.hbm.xml

Code:
<?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">

<hibernate-mapping
>
    <class
        name="com.lagranjita.modelo.entidades.HistorialArticulo"
        table="HistorialArticulo"
    >

        <id
            name="idHistorialArticulo"
            column="idHistorialArticulo"
            type="java.lang.String"
            length="40"
        >
            <generator class="assigned">
              <!-- 
                  To add non XDoclet generator parameters, create a file named
                  hibernate-generator-params-HistorialArticulo.xml
                  containing the additional parameters and place it in your merge dir.
              -->
            </generator>
        </id>

        <discriminator
            column="tipo"
            type="string"
            length="10"
        />

        <many-to-one
            name="idArticulo"
            class="com.lagranjita.modelo.entidades.Articulo"
            cascade="none"
            outer-join="auto"
            update="true"
            insert="true"
            column="idArticulo"
            not-null="true"
        />

        <property
            name="cantidad"
            type="java.math.BigDecimal"
            update="true"
            insert="true"
            column="cantidad"
            length="6"
            not-null="true"
        />

        <property
            name="fecha"
            type="date"
            update="true"
            insert="true"
            column="fecha"
            not-null="true"
        />

        <!--
            To add non XDoclet property mappings, create a file named
                hibernate-properties-HistorialArticulo.xml
            containing the additional properties and place it in your merge dir.
        -->
        <subclass
            name="com.lagranjita.modelo.entidades.HistorialSalidaArticulo"
            discriminator-value="HISTSALALM"
        >

        <one-to-one
            name="detalleSalidaAlmacen"
            class="com.lagranjita.modelo.entidades.DetalleSalidaAlmacen"
            cascade="none"
            outer-join="auto"
            constrained="false"
            property-ref="historialSalidaArticulo"
        />

       <!--
               To add non XDoclet property mappings, create a file named
                hibernate-properties-HistorialSalidaArticulo.xml
      containing the additional properties and place it in your merge dir.
       -->

        </subclass>
        <subclass
            name="com.lagranjita.modelo.entidades.HistorialEntradaArticulo"
            discriminator-value="HISTENTALM"
        >

        <one-to-one
            name="detalleEntradaAlmacen"
            class="com.lagranjita.modelo.entidades.DetalleEntradaAlmacen"
            cascade="none"
            outer-join="auto"
            constrained="false"
            property-ref="historialEntradaArticulo"
        />

       <!--
               To add non XDoclet property mappings, create a file named
                hibernate-properties-HistorialEntradaArticulo.xml
      containing the additional properties and place it in your merge dir.
       -->

        </subclass>

    </class>

</hibernate-mapping>


pls, help us, out boss are like hell

pls help!!!

thanks for advanced


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

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.