-->
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: Error Type not supported: org.hibernate.type.ManyToOneType
PostPosted: Mon Aug 26, 2013 9:51 am 
Newbie

Joined: Mon Aug 26, 2013 9:22 am
Posts: 1
Hello.

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

this is my code.

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;
    }

}


Code:
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;
    }
}


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

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


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.