facebook

Exception at AbstractEntityTuplizer.createProxy

  1. MyEclipse IDE
  2.  > 
  3. Off Topic
Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #258461 Reply

    pablogmuller
    Member

    Hi,
    I’m getting this exception:

    java.lang.NullPointerException
         at org.hibernate.tuple.AbstractEntityTuplizer.createProxy(AbstractEntityTuplizer.java:372)
         at org.hibernate.persister.entity.AbstractEntityPersister.createProxy(AbstractEntityPersister.java:3232)
        at org.hibernate.event.def.DefaultLoadEventListener.createProxyIfNecessary(DefaultLoadEventListener.java:237)
        at org.hibernate.event.def.DefaultLoadEventListener.proxyOrLoad(DefaultLoadEventListener.java:174)
         at org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:86)
         at org.hibernate.impl.SessionImpl.fireLoad(SessionImpl.java:871)
         at org.hibernate.impl.SessionImpl.internalLoad(SessionImpl.java:839)
         at org.hibernate.type.EntityType.resolveIdentifier(EntityType.java:266)
         at org.hibernate.type.EntityType.resolve(EntityType.java:303)
         at org.hibernate.engine.TwoPhaseLoad.initializeEntity(TwoPhaseLoad.java:116)
         at org.hibernate.loader.Loader.initializeEntitiesAndCollections(Loader.java:842)
         at org.hibernate.loader.Loader.doQuery(Loader.java:717)
         at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:224)
         at org.hibernate.loader.Loader.doList(Loader.java:2145)
         at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2029)
         at org.hibernate.loader.Loader.list(Loader.java:2024)
         at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:392)
         at org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:333)
         at org.hibernate.engine.query.HQLQueryPlan.performList(HQLQueryPlan.java:172)
         at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1114)
         at org.hibernate.impl.QueryImpl.list(QueryImpl.java:79)

    which is thrown at this line:

    
    tareas = getSession().createQuery("from Tarea t where template=1").list();

    I have two problems with it:
    1) I don’t know what’s the problem
    2) It doesn’t always happen, sometimes it works, without changing a single line of code, so I’t very difficult to track.
    There’s very little info about this out there.
    Has anyone seen this before?

    I’m using java 1.5.0_05, hibernate 3.1.2, struts, and jboss 4.0.4.GA

    Thanks a lot
    Pablo.

    #258465 Reply

    Haris Peco
    Member

    Pablo,

    It is hard to conclude, but it is possible that you have table or view (Tarea) without primary key in database and your hibernate ID have null value (some property in ID).

    Can you send your database,jdbc version and vendor and ddl script for your table

    Best
    Peco

    #258466 Reply

    pablogmuller
    Member

    Thanks for the reply Peco,
    I’m using MySql 5 with their jdbc driver.
    This is the mapping for Tarea:

    
    <class name="com.movilogic.modelo.Tarea" table="tarea">
            <id name="id" column="id">
                <generator class="increment"/>
            </id>
            <property name="descripcion"/>
            <property name="horaFin" column="hora_fin"/>
            <property name="horaInicio" column="hora_inicio"/>
            <property name="multiplicidad" column="multiplicidad"/>
            <property name="template"/>
            <many-to-one name="direccion" class="com.movilogic.modelo.Direccion"/>
            <many-to-one name="contacto" class="com.movilogic.modelo.Contacto" />
            <set name="subtareas" table="tarea_subtareas">
                <key column="id_tarea"/>
                <many-to-many column="id_subtarea" class="com.movilogic.modelo.Tarea"/>
            </set>
            <set name="predecesores" table="predecesores">
                <key column="id_tarea"/>
                <many-to-many column="id_predecesora" class="com.movilogic.modelo.Tarea"/>
            </set>
        </class>

    And this is the sql for those tables:

    
    DROP TABLE IF EXISTS `omwa`.`tarea`;
    CREATE TABLE  `omwa`.`tarea` (
      `id` int(11) NOT NULL auto_increment,
      `descripcion` varchar(255) default NULL,
      `hora_fin` datetime default NULL,
      `hora_inicio` datetime default NULL,
      `multiplicidad` int(11) default NULL,
      `direccion` int(11) default NULL,
      `contacto` int(11) default NULL,
      `template` bit(1) default NULL,
      PRIMARY KEY  (`id`),
      KEY `FK69077017B523EA` (`direccion`),
      CONSTRAINT `FK69077017B523EA` FOREIGN KEY (`direccion`) REFERENCES `direccion` (`id`)
    ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
    
    DROP TABLE IF EXISTS `omwa`.`predecesores`;
    CREATE TABLE  `omwa`.`predecesores` (
      `id_tarea` int(11) NOT NULL,
      `id_predecesora` int(11) NOT NULL,
      PRIMARY KEY  (`id_tarea`,`id_predecesora`),
      KEY `FK1B06C2BE4D7038B8` (`id_predecesora`),
      KEY `FK1B06C2BE412BC68` (`id_tarea`),
      CONSTRAINT `FK1B06C2BE412BC68` FOREIGN KEY (`id_tarea`) REFERENCES `tarea` (`id`),
      CONSTRAINT `FK1B06C2BE4D7038B8` FOREIGN KEY (`id_predecesora`) REFERENCES `tarea` (`id`)
    ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
    
    DROP TABLE IF EXISTS `omwa`.`tarea_subtareas`;
    CREATE TABLE  `omwa`.`tarea_subtareas` (
      `id_tarea` int(11) NOT NULL,
      `id_subtarea` int(11) NOT NULL,
      PRIMARY KEY  (`id_tarea`,`id_subtarea`),
      KEY `FKBE15DC141F29A8F0` (`id_subtarea`),
      KEY `FKBE15DC14412BC68` (`id_tarea`),
      CONSTRAINT `FKBE15DC141F29A8F0` FOREIGN KEY (`id_subtarea`) REFERENCES `tarea` (`id`),
      CONSTRAINT `FKBE15DC14412BC68` FOREIGN KEY (`id_tarea`) REFERENCES `tarea` (`id`)
    ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
    
    
    

    I think that’s all. If I missed anything please tell me.
    Thanks again.
    Pablo

    #258469 Reply

    Haris Peco
    Member

    Pablo,

    I am not sure, but you have this mapping

    <many-to-one name=”contacto” class=”com.movilogic.modelo.Contacto” />

    and there isn’t FK for table contacto

    Can you send ddl for contacto and dirrecion tables and mappings (and java) for all classes ?

    Thanks

    #258487 Reply

    pablogmuller
    Member

    Thanks again for your time,

    Here’s the whole mapping:

    <hibernate-mapping>
            
        <class name="com.movilogic.modelo.Direccion" table="direccion">
            <id name="id" column="id">    
                <generator class="identity"/>
            </id>
            <property name="calle"/>
            <property name="codigoPostal" column="codigo_postal"/>
            <property name="departamento"/>
            <property name="localidad"/>
            <property name="numero"/>
            <property name="piso"/>
            <property name="provincia"/>
        </class>
        
        <class name="com.movilogic.modelo.Telefono" table="telefono">
            <id name="id" column="id">
                <generator class="identity"/>
            </id>
            <property name="numero"/>
            <property name="tipo"/>
        </class>
        
        <class name="com.movilogic.modelo.Usuario" table="usuario">
            <id name="id" column="id">
                <generator class="identity"/>
            </id>
            <property name="usuario"/>
            <property name="password"/>
            <property name="estado"/>
        </class>
        
        <class name="com.movilogic.modelo.Plan" table="planes">
            <id name="id" column="id">
                <generator class="identity"/>
            </id>
            <property name="planner"/>
            <property name="observaciones"/>
            <many-to-one column="usuario" name="usuario" class="com.movilogic.modelo.Usuario"></many-to-one>
            <set name="tareas" table="plan_tareas">
                <key column="id_plan"/>
                <many-to-many column="id_tarea" class="com.movilogic.modelo.Tarea"/>
            </set>
        </class>
        
        <class name="com.movilogic.modelo.Contacto" table="contacto" abstract="true">
            <id name="id" column="id">
                <generator class="increment"/>
            </id>
            <property name="titulo"/>
            <set name="direcciones" table="contacto_direccion">
                <key column="id_contacto"/>
                <many-to-many column="id_direccion" class="com.movilogic.modelo.Direccion"></many-to-many> 
            </set>
            <set name="telefonos" table="contacto_telefono">
                <key column="id_contacto"/>
                <many-to-many column="id_telefono" class="com.movilogic.modelo.Telefono"></many-to-many> 
            </set>
            <union-subclass name="com.movilogic.modelo.Empresa" table="empresa">
                <property name="cuit"/>
                <property name="razonSocial" column="razon_social"/>
            </union-subclass>
            <union-subclass name="com.movilogic.modelo.Persona" table="persona">
                <property name="apellido"/>
                <property name="nombre"/>
                <!-- property name="empresa" type="com.movilogic.modelo.Empresa"/-->
            </union-subclass>
        </class>        
        
        <class name="com.movilogic.modelo.Tarea" table="tarea">
            <id name="id" column="id">
                <generator class="increment"/>
            </id>
            <property name="descripcion"/>
            <property name="horaFin" column="hora_fin"/>
            <property name="horaInicio" column="hora_inicio"/>
            <property name="multiplicidad" column="multiplicidad"/>
            <property name="template"/>
            <many-to-one name="direccion" class="com.movilogic.modelo.Direccion"/>
            <many-to-one name="contacto" class="com.movilogic.modelo.Contacto" />
            <set name="subtareas" table="tarea_subtareas">
                <key column="id_tarea"/>
                <many-to-many column="id_subtarea" class="com.movilogic.modelo.Tarea"/>
            </set>
            <set name="predecesores" table="predecesores">
                <key column="id_tarea"/>
                <many-to-many column="id_predecesora" class="com.movilogic.modelo.Tarea"/>
            </set>
        </class>
    </hibernate-mapping>
    

    And here are the sql for the tables:

    
    
    DROP TABLE IF EXISTS `omwa`.`contacto_direccion`;
    CREATE TABLE  `omwa`.`contacto_direccion` (
      `id_contacto` int(11) NOT NULL,
      `id_direccion` int(11) NOT NULL,
      PRIMARY KEY  (`id_contacto`,`id_direccion`),
      KEY `FKED61D14028C5C6` (`id_direccion`),
      CONSTRAINT `FKED61D14028C5C6` FOREIGN KEY (`id_direccion`) REFERENCES `direccion` (`id`)
    ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
    
    DROP TABLE IF EXISTS `omwa`.`contacto_telefono`;
    CREATE TABLE  `omwa`.`contacto_telefono` (
      `id_contacto` int(11) NOT NULL,
      `id_telefono` int(11) NOT NULL,
      PRIMARY KEY  (`id_contacto`,`id_telefono`),
      KEY `FK65D624E49312A5C2` (`id_telefono`),
      CONSTRAINT `FK65D624E49312A5C2` FOREIGN KEY (`id_telefono`) REFERENCES `telefono` (`id`)
    ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
    
    DROP TABLE IF EXISTS `omwa`.`direccion`;
    CREATE TABLE  `omwa`.`direccion` (
      `id` int(11) NOT NULL auto_increment,
      `calle` varchar(255) default NULL,
      `codigo_postal` int(11) default NULL,
      `departamento` varchar(255) default NULL,
      `localidad` varchar(255) default NULL,
      `numero` int(11) default NULL,
      `piso` int(11) default NULL,
      `provincia` varchar(255) default NULL,
      PRIMARY KEY  (`id`)
    ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
    
    DROP TABLE IF EXISTS `omwa`.`empresa`;
    CREATE TABLE  `omwa`.`empresa` (
      `id` int(11) NOT NULL,
      `titulo` varchar(255) default NULL,
      `cuit` varchar(255) default NULL,
      `razon_social` varchar(255) default NULL,
      PRIMARY KEY  (`id`)
    ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
    
    DROP TABLE IF EXISTS `omwa`.`persona`;
    CREATE TABLE  `omwa`.`persona` (
      `id` int(11) NOT NULL,
      `titulo` varchar(255) default NULL,
      `apellido` varchar(255) default NULL,
      `nombre` varchar(255) default NULL,
      PRIMARY KEY  (`id`)
    ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
    
    DROP TABLE IF EXISTS `omwa`.`plan_tareas`;
    CREATE TABLE  `omwa`.`plan_tareas` (
      `id_plan` int(11) NOT NULL,
      `id_tarea` int(11) NOT NULL,
      PRIMARY KEY  (`id_plan`,`id_tarea`),
      KEY `FK70A7AB684A70E32C` (`id_plan`),
      KEY `FK70A7AB68412BC68` (`id_tarea`),
      CONSTRAINT `FK70A7AB68412BC68` FOREIGN KEY (`id_tarea`) REFERENCES `tarea` (`id`),
      CONSTRAINT `FK70A7AB684A70E32C` FOREIGN KEY (`id_plan`) REFERENCES `planes` (`id`)
    ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
    
    DROP TABLE IF EXISTS `omwa`.`planes`;
    CREATE TABLE  `omwa`.`planes` (
      `id` int(11) NOT NULL auto_increment,
      `planner` varchar(255) default NULL,
      `observaciones` varchar(255) default NULL,
      `usuario` int(11) default NULL,
      PRIMARY KEY  (`id`),
      KEY `FKC53E719748774A66` (`usuario`),
      CONSTRAINT `FKC53E719748774A66` FOREIGN KEY (`usuario`) REFERENCES `usuario` (`id`)
    ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
    
    DROP TABLE IF EXISTS `omwa`.`predecesores`;
    CREATE TABLE  `omwa`.`predecesores` (
      `id_tarea` int(11) NOT NULL,
      `id_predecesora` int(11) NOT NULL,
      PRIMARY KEY  (`id_tarea`,`id_predecesora`),
      KEY `FK1B06C2BE4D7038B8` (`id_predecesora`),
      KEY `FK1B06C2BE412BC68` (`id_tarea`),
      CONSTRAINT `FK1B06C2BE412BC68` FOREIGN KEY (`id_tarea`) REFERENCES `tarea` (`id`),
      CONSTRAINT `FK1B06C2BE4D7038B8` FOREIGN KEY (`id_predecesora`) REFERENCES `tarea` (`id`)
    ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
    
    DROP TABLE IF EXISTS `omwa`.`tarea`;
    CREATE TABLE  `omwa`.`tarea` (
      `id` int(11) NOT NULL auto_increment,
      `descripcion` varchar(255) default NULL,
      `hora_fin` datetime default NULL,
      `hora_inicio` datetime default NULL,
      `multiplicidad` int(11) default NULL,
      `direccion` int(11) default NULL,
      `contacto` int(11) default NULL,
      `template` bit(1) default NULL,
      PRIMARY KEY  (`id`),
      KEY `FK69077017B523EA` (`direccion`),
      CONSTRAINT `FK69077017B523EA` FOREIGN KEY (`direccion`) REFERENCES `direccion` (`id`)
    ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
    
    DROP TABLE IF EXISTS `omwa`.`tarea_subtareas`;
    CREATE TABLE  `omwa`.`tarea_subtareas` (
      `id_tarea` int(11) NOT NULL,
      `id_subtarea` int(11) NOT NULL,
      PRIMARY KEY  (`id_tarea`,`id_subtarea`),
      KEY `FKBE15DC141F29A8F0` (`id_subtarea`),
      KEY `FKBE15DC14412BC68` (`id_tarea`),
      CONSTRAINT `FKBE15DC141F29A8F0` FOREIGN KEY (`id_subtarea`) REFERENCES `tarea` (`id`),
      CONSTRAINT `FKBE15DC14412BC68` FOREIGN KEY (`id_tarea`) REFERENCES `tarea` (`id`)
    ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
    
    DROP TABLE IF EXISTS `omwa`.`telefono`;
    CREATE TABLE  `omwa`.`telefono` (
      `id` int(11) NOT NULL auto_increment,
      `numero` varchar(255) default NULL,
      `tipo` varchar(255) default NULL,
      PRIMARY KEY  (`id`)
    ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
    
    DROP TABLE IF EXISTS `omwa`.`usuario`;
    CREATE TABLE  `omwa`.`usuario` (
      `id` int(11) NOT NULL auto_increment,
      `usuario` varchar(255) default NULL,
      `password` varchar(255) default NULL,
      `estado` varchar(255) default NULL,
      PRIMARY KEY  (`id`)
    ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
    
    

    I’ll send the java code of the attributes declaration only, not to make the post huge. The missing part are just the getters and setters.

    
    public class Tarea {
    
        private Integer id;
        private String descripcion;
        private Date horaInicio;
        private Date horaFin;
        private Contacto contacto;
        private Direccion direccion;
        private Set subtareas;
        private Integer multiplicidad;
        private Integer orden;
        private static TareaDao DAO;
        private Set predecesores;
        private Set resultados;
        private Boolean template;
    
    
    public class Empresa implements Contacto {
    
        private Integer id;
        private String razonSocial;
        private String cuit;
        private Set telefonos;
        private Set direcciones;
        private static EmpresaDao DAO;
    
    public class Persona implements Contacto {
    
        private Integer id;
        private String nombre;
        private String apellido;
        private Empresa empresa;
        private Set telefonos;
        private Set direcciones;
        private static PersonaDao DAO;
    
    public class Plan {
    
        private int id;
        private Usuario usuario;
        private String observaciones;
        private String planner;
        private Set tareas;
        private static PlanDao DAO;
    
    public class Telefono {
    
        private String tipo;
        private String numero;
        private int id;
        private static TelefonoDao DAO;
    
    public class Direccion {
    
        private int id;
        private String calle;
        private int numero;
        private String departamento;
        private int piso;
        private String localidad;
        private String provincia;
        private int codigoPostal;
        private static DireccionDao DAO;

    Thanks.

    #258607 Reply

    Haris Peco
    Member

    Pablo,

    Sorry for my delay.I haven’t tried your exactly case , because you haven’t sent Contacto table, but I have tried case with many-to-one without foreign key (your Tarea have many-to-one to abstract class Contacto)

    you can try next query (i suppose that it will throw exception always)

    tareas = getSession().createQuery(“from Tarea”).list();

    Best

    #258608 Reply

    pablogmuller
    Member

    Hi Peco, Thanks for looking into it!!
    Contacto is not a table because it’s mapped as abstract. The actual data is in Persona and Empresa.
    Thanks again.

    #258609 Reply

    Haris Peco
    Member

    Pablo,

    I have thought Contacto class – have you tried query ?

    Best

    #258610 Reply

    pablogmuller
    Member

    Peco,
    I just made it work. Contacto was an interface, I changed it for an abstract class.
    Hibernate needed a constructor to initialize the proxy.
    Thanks a lot for your time.

    #273165 Reply

    Rai Singh
    Member

    For what it’s worth, I experienced a similar exception in my Hibernate and Spring enabled project. The runtimes for cglib seemed to be the culplit. MyEclipse packaged version 2.1.3 with my project (Hibernate 3.1 libraries included cglib-2.1.3.jar and Spring 2.0 AOP included cglib-nodep-2.1.3.jar). I placed version 2.2 beta 1 for both libraries in front of both previous versions in my project classpath and then it worked fine.

Viewing 10 posts - 1 through 10 (of 10 total)
Reply To: Exception at AbstractEntityTuplizer.createProxy

You must be logged in to post in the forum log in