0 Replies Latest reply on Aug 26, 2013 10:52 AM by juanedsa

    Error: Type not supported: org.hibernate.type.ManyToOneType

    juanedsa

      Hello.

      I need to record audit in my Entities witlh relations @ManyToOne.

      this is my code.

       

      import java.io.*;
      import javax.persistence.*;
      import org.openxava.annotations.*;
      
      @Entity
      @Table(name="TAB_ENRUTAMIENTOS_COMPENSACION")
      @Audited
      @AuditTable("AUDITORIA.ENRUTAMIENTOS_COMPENSACION_AUD")
      @IdClass(EnrutamientosCompensacionPK.class)
      public class EnrutamientosCompensacion implements Serializable {
          private static final long serialVersionUID = 1L;
      
      @Id
          @Column(name="CODIGO_CONVENIO")
          private String codigoConvenio;
      
      //bi-directional many-to-one association to TabHost
          @Id
          @ManyToOne
          @JoinColumn(name="FK_TAB_HOSTS_ID_CONVENIO")
          @DescriptionsList
          private Host hostConvenio;
      
       @Column(name="APLICA_COMPENSACION", length=1)
          private String aplicaCompensacion;
      
       //bi-directional many-to-one association to TabHost
          @ManyToOne
          @JoinColumn(name="FK_TAB_HOSTS_ID_COMPENSACION")
          private Host hostCompensacion;
      
          public EnrutamientosCompensacion() {
          }
          public String getAplicaCompensacion() {
              return this.aplicaCompensacion;
          }
          public void setAplicaCompensacion(String aplicaCompensacion) {
              this.aplicaCompensacion = aplicaCompensacion;
          }
          public Host getHostConvenio() {
              return hostConvenio;
          }
          public void setHostConvenio(Host hostConvenio) {
              this.hostConvenio = hostConvenio;
          }
          public String getCodigoConvenio() {
              return codigoConvenio;
          }
          public void setCodigoConvenio(String codigoConvenio) {
              this.codigoConvenio = codigoConvenio;
          }
          public Host getHostCompensacion() {
              return hostCompensacion;
          }
          public void setHostCompensacion(Host hostCompensacion) {
              this.hostCompensacion = hostCompensacion;
          }
      }
      
      
      
      

       

       

       

       

      import java.io.*;
      import javax.persistence.*;
      
      /**
      * The primary key class for the TAB_ENRUTAMIENTOS_COMPENSACION database table.
      *
      */
      @Embeddable
      public class EnrutamientosCompensacionPK implements Serializable {
          //default serial version id, required for serializable classes.
          private static final long serialVersionUID = 1L;
      
      private String codigoConvenio;
      private Host hostConvenio;
      
          public EnrutamientosCompensacionPK() {
          }
          public String getCodigoConvenio() {
              return this.codigoConvenio;
          }
          public void setCodigoConvenio(String codigoConvenio) {
              this.codigoConvenio = codigoConvenio;
          }
          public Host getHostConvenio() {
              return this.hostConvenio;
          }
          public void setHostsIdConvenio(Host hostConvenio) {
              this.hostConvenio = hostConvenio;
          }
          public boolean equals(Object other) {
              if (this == other) {
                  return true;
              }
              if (!(other instanceof EnrutamientosCompensacionPK)) {
                  return false;
              }
              EnrutamientosCompensacionPK castOther = (EnrutamientosCompensacionPK)other;
              return
                  this.codigoConvenio.equals(castOther.codigoConvenio)
                  && (this.hostConvenio == castOther.hostConvenio);
          }
          public int hashCode() {
              final int prime = 31;
              int hash = 17;
              hash = hash * prime + this.codigoConvenio.hashCode();
              hash = hash * prime + ((int) (this.hostConvenio.getHostId() ^ (this.hostConvenio.getHostId() >>> 32)));
      
      
              return hash;
          }
      }
      

       

       

      import java.io.*;
      import java.util.*;
      
      import javax.persistence.*;
      import org.hibernate.envers.*;
      import org.openxava.annotations.*;
      
      @Entity
      @Table(name="TAB_HOSTS")
      @View(members="nombre; clasesJava; estado")
      @Tab(properties="hostId, nombre, clasesJava.nombre, estado.nombre")
      @Audited
      @AuditTable("AUDITORIA.HOSTS_AUD")
      public class Host implements Serializable {
          private static final long serialVersionUID = 1L;
      
      @Id
          @Hidden
          @GeneratedValue(strategy = GenerationType.AUTO, generator = "TAB_HOSTS_SEQ_GEN")
          @SequenceGenerator(name = "TAB_HOSTS_SEQ_GEN", sequenceName = "TAB_HOSTS_SEQ")
          @Column(name="TAB_HOSTS_ID")
          private long hostId;
      
      @Column(nullable=false, length=100)
          private String nombre; 
      
      //bi-directional many-to-one association to enrutamientoCompensacion
          @OneToMany(mappedBy="hostCompensacion")
          @NotAudited
          private List<EnrutamientosCompensacion> enrutamientoCompensacion;
      
        public Host() {
          }
          public long getHostId() {
              return this.hostId;
          }
          public void setHostId(long tabHostsId) {
              this.hostId = tabHostsId;
          }
          public String getNombre() {
              return this.nombre;
          }
          public void setNombre(String nombre) {
              this.nombre = nombre;
          }
          public List<ConfiguracionesHost> getTabConfiguracionesHosts() {
              return this.tabConfiguracionesHosts;
          }
          public void setTabConfiguracionesHosts(List<ConfiguracionesHost> tabConfiguracionesHosts) {
              this.tabConfiguracionesHosts = tabConfiguracionesHosts;
          }
          public ConfiguracionesHost addTabConfiguracionesHost(ConfiguracionesHost tabConfiguracionesHost) {
              getTabConfiguracionesHosts().add(tabConfiguracionesHost);
              tabConfiguracionesHost.setHost(this);
              return tabConfiguracionesHost;
          }
          public ConfiguracionesHost removeTabConfiguracionesHost(ConfiguracionesHost tabConfiguracionesHost) {
              getTabConfiguracionesHosts().remove(tabConfiguracionesHost);
              tabConfiguracionesHost.setHost(null);
              return tabConfiguracionesHost;
          }
          public List<EnrutamientosHost> getEnrutamientosHosts() {
              return this.enrutamientosHosts;
          }
          public void setEnrutamientosHosts(List<EnrutamientosHost> tabEnrutamientosHosts) {
              this.enrutamientosHosts = tabEnrutamientosHosts;
          }
          public EnrutamientosHost addTabEnrutamientosHost(EnrutamientosHost tabEnrutamientosHost) {
              getEnrutamientosHosts().add(tabEnrutamientosHost);
              tabEnrutamientosHost.setHost(this);
              return tabEnrutamientosHost;
          }
          public EnrutamientosHost removeTabEnrutamientosHost(EnrutamientosHost tabEnrutamientosHost) {
              getEnrutamientosHosts().remove(tabEnrutamientosHost);
              tabEnrutamientosHost.setHost(null);
              return tabEnrutamientosHost;
          }
          public ClasesJava getClasesJava() {
              return this.clasesJava;
          }
          public void setClasesJava(ClasesJava tabClasesJava) {
              this.clasesJava = tabClasesJava;
          }
          public Estado getEstado() {
              return this.estado;
          }
          public void setEstado(Estado estado) {
              this.estado = estado;
          }
          public List<EnrutamientosCompensacion> getEnrutamientoCompensacion() {
              return enrutamientoCompensacion;
          }
          public void setEnrutamientoCompensacion(
                  List<EnrutamientosCompensacion> enrutamientoCompensacion) {
              this.enrutamientoCompensacion = enrutamientoCompensacion;
          }
          public List<EnrutamientosCompensacion> getEnrutamientoHostConvenio() {
              return enrutamientoHostConvenio;
          }
          public void setEnrutamientoHostConvenio(
                  List<EnrutamientosCompensacion> enrutamientoHostConvenio) {
              this.enrutamientoHostConvenio = enrutamientoHostConvenio;
          }
          public List<PenalizacionesHost> getPenalizacionesHosts() {
              return penalizacionesHosts;
          }
          public void setPenalizacionesHosts(
                  List<PenalizacionesHost> tabPenalizacionesHosts) {
              this.penalizacionesHosts = tabPenalizacionesHosts;
          }
          public PenalizacionesHost addPenalizacionesHost(PenalizacionesHost penalizacionesHost) {
              getPenalizacionesHosts().add(penalizacionesHost);
              penalizacionesHost.setHost(this);
              return penalizacionesHost;
          }
          public PenalizacionesHost removePenalizacionesHost(PenalizacionesHost penalizacionesHost) {
              getPenalizacionesHosts().remove(penalizacionesHost);
              penalizacionesHost.setHost(null);
              return penalizacionesHost;
          }
          public List<ReversosHost> getReversosHosts() {
              return this.reversosHosts;
          }
          public void setTabReversosHosts(List<ReversosHost> tabReversosHosts) {
              this.reversosHosts = tabReversosHosts;
          }
          public ReversosHost addTabReversosHost(ReversosHost tabReversosHost) {
              getReversosHosts().add(tabReversosHost);
              tabReversosHost.setHost(this);
              return tabReversosHost;
          }
          public ReversosHost removeTabReversosHost(ReversosHost tabReversosHost) {
              getReversosHosts().remove(tabReversosHost);
              tabReversosHost.setHost(null);
              return tabReversosHost;
          }
      

       

       

      and this is the error

       

      org.hibernate.MappingException: Type not supported: org.hibernate.type.ManyToOneType
          org.hibernate.envers.configuration.metadata.IdMetadataGenerator.addIdProperties(IdMetadataGenerator.java:75)
          org.hibernate.envers.configuration.metadata.IdMetadataGenerator.addId(IdMetadataGenerator.java:106)
          org.hibernate.envers.configuration.metadata.AuditMetadataGenerator.generateFirstPass(AuditMetadataGenerator.java:412)
          org.hibernate.envers.configuration.EntitiesConfigurator.configure(EntitiesConfigurator.java:102)
          org.hibernate.envers.configuration.AuditConfiguration.<init>(AuditConfiguration.java:97)
          org.hibernate.envers.configuration.AuditConfiguration.getFor(AuditConfiguration.java:129)
          org.hibernate.envers.event.AuditEventListener.initialize(AuditEventListener.java:337)
          org.hibernate.event.EventListeners$1.processListener(EventListeners.java:198)
          org.hibernate.event.EventListeners.processListeners(EventListeners.java:181)
          org.hibernate.event.EventListeners.initializeListeners(EventListeners.java:194)
          org.hibernate.cfg.Configuration.getInitializedEventListeners(Configuration.java:2010)
          org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1872)
          org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:906)
          org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:57)
          javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:63)
          org.openxava.jpa.XPersistence.getEntityManagerFactory(XPersistence.java:182)
          org.openxava.jpa.XPersistence.openManager(XPersistence.java:113)
          org.openxava.jpa.XPersistence.getManager(XPersistence.java:94)
          com.openxava.naviox.impl.DB.createDB(DB.java:71)
          com.openxava.naviox.impl.DB.init(DB.java:33)
          com.openxava.naviox.Modules.<clinit>(Modules.java:35)
          com.openxava.naviox.web.NaviOXFilter.doFilter(NaviOXFilter.java:42)
      

       

       

      could you help me please?