Problem with enhancing classes

47 views
Skip to first unread message

jmdi...@yahoo.com

unread,
Feb 16, 2014, 2:19:09 AM2/16/14
to eb...@googlegroups.com
I have entity EquipoRecibido with two birectional one to many relationships, with DetalleEquipoRecibido and DocumentoRelacionado. I have some days working with it but suddenly the enhancement stop working, it fails with:

[avajeEnhance] Current Directory: C:\memorydata\Downloads\eclipse-jee-kepler-R-win32
[avajeEnhance] transform> cls: com/ace/model/AbstractBaseEntity  msg: ... ignore field _ebean_intercept
[avajeEnhance] java.lang.RuntimeException: java.lang.ClassNotFoundException: com.ace.model.DetalleEquipoRecibido
[avajeEnhance]     at com.avaje.ebean.enhance.asm.ClassWriter.getCommonSuperClass(ClassWriter.java:1284)
[avajeEnhance]     at com.avaje.ebean.enhance.asm.ClassWriter.getMergedType(ClassWriter.java:1244)
[avajeEnhance]     at com.avaje.ebean.enhance.asm.Frame.merge(Frame.java:1373)
[avajeEnhance]     at com.avaje.ebean.enhance.asm.Frame.merge(Frame.java:1280)
[avajeEnhance]     at com.avaje.ebean.enhance.asm.MethodWriter.visitMaxs(MethodWriter.java:1270)
[avajeEnhance]     at com.avaje.ebean.enhance.asm.MethodAdapter.visitMaxs(MethodAdapter.java:189)
[avajeEnhance]     at com.avaje.ebean.enhance.asm.ClassReader.accept(ClassReader.java:1447)

The ant task is:

    <taskdef name="avajeEnhance"
        classname="com.avaje.ebean.enhance.ant.AntEnhanceTask">
        <classpath>
            <pathelement path="C:/Users/dell/.m2/repository/org/avaje/ebeanorm/avaje-ebeanorm-agent/3.2.2/avaje-ebeanorm-agent-3.2.2.jar"/>
        </classpath>
    </taskdef>

    <target name="ormEnhance">
        <avajeEnhance
            classsource="C:\Users\dell\eclipsekepler\PcExpressPosModel\bin\"
            packages="com.ace.model"           
            />
    </target>


And the relevant classes:

@Entity
@Table(name="equipo_recibido")
public class EquipoRecibido extends AbstractBaseEntity {
   
      @Basic(optional=false)
      @Column(name="folio")
      private long folio;
     
      @Basic(optional=false)
      @Column(name="propietario")
      private String propietario;
     
      @Basic(optional=false)
      @Column(name="telefono")
      private String telefono;
     
      @Basic(optional=false)
      @Column(name="email")
      private String email;
     
      @ManyToOne(optional=false)
      @JoinColumn(name="id_tipo_equipo", referencedColumnName="id")
      private TipoEquipo tipoEquipo;
     
      @Basic(optional=false)
      @Column(name="descripcion_equipo")
      private String descripcionEquipo;
     
      @Basic(optional=false)
      @Column(name="descripcion_falla")
      private String descripcionFalla;
     
      @Basic(optional=false)
      @Column(name="diagnostico_preliminar")
      private String diagnosticoPreliminar;
     
      @Basic(optional=false)
      @Column(name="servicio_a_realizar")
      private String servicioARealizar;
     
      @Basic(optional=false)
      @Column(name="precio_estimado")
      private double precioEstimado;
     
      @Basic(optional=false)
      @Column(name="fecha_estimada_entrega")
      private java.sql.Timestamp fechaEstimadaEntrega;
     
      @Basic
      @Column(name="notas")
      private String notas;
     
      @ManyToOne(optional=false)
      @JoinColumn(name="tecnico_recibe", referencedColumnName="id")
      private Person tecnicoRecibe;

      @ManyToOne(optional=false)
      @JoinColumn(name="id_estado_servicio", referencedColumnName="id")
      private EstadoServicio estadoServicio;
     
      @ManyToOne(optional=true)
      @JoinColumn(name="tecnico_servicio", referencedColumnName="id")
      private Person tecnicoServicio;
     
      @Basic(optional=true)
      @Column(name="precio_final")
      private Double precioFinal;
     
      @Basic(optional=true)
      @Column(name="indicaciones_finales")
      private String indicacionesFinales;
     
      @OneToMany(mappedBy="equipo", cascade=CascadeType.ALL)
      private List<DetalleEquipoRecibido> detallesEquipoRecibido;

      @OneToMany(mappedBy="equipoRecibido", cascade=CascadeType.ALL)
      private List<DocumentoRelacionado> documentosRelacionados;

     /// other code deleted
}

@Entity
@Table(name="detalle_equipo_recibido")
public class DetalleEquipoRecibido extends AbstractBaseEntity {

      @ManyToOne
      @JoinColumn(name="id_equipo_recibido", referencedColumnName="id")
      private EquipoRecibido equipo;
     
      @Basic(optional=false)
      @Column(name="numero_linea")
      private int numero_linea;
     
      @Basic(optional=false)
      @Column(name="elemento")
      private String elemento;
     
      @Basic(optional=true)
      @Column(name="marca")
      private String marca;
     
      @Basic(optional=true)
      @Column(name="serie")
      private String serie;
     
      @Basic(optional=true)
      @Column(name="capacidad")
      private String capacidad;
     
      @Basic(optional=true)
      @Column(name="estado")
      private String estado;
    
      //other code deleted
}

@MappedSuperclass
public abstract class AbstractBaseEntity implements Serializable {
    private static final long serialVersionUID = 1L;

    @Id
    private String id;

    public AbstractBaseEntity() {
        this.id = UUID.randomUUID().toString();
    }
   
    public String getId() {
        return id;
    }

    public void setId(String pid) {
        this.id = pid;
    }

    @Override
    public int hashCode() {
        return id.hashCode();
    }

    @Override
    public boolean equals(Object obj) {
        if (this == obj)
            return true;
        if (obj == null)
            return false;
        if (!(obj instanceof AbstractBaseEntity)) {
            return false;
        }
        AbstractBaseEntity other = (AbstractBaseEntity) obj;
        return this.id.equals(other.id);
    }
}

I can not think on any reason for this, I tried to find a more recent version of the enhacer without sucess.

Thanks in advance.

jmdi...@yahoo.com

unread,
Feb 16, 2014, 10:55:54 AM2/16/14
to eb...@googlegroups.com
I found the source of the problem: in EquipoRecibo (one side) I have code to modifiy entities of DetalleEquipoRecibido (the many side), when I comment out this modifications the enhancer works well. For your information, eclipselink jpa enhancer works well with this.

This is the method of EquipoRecibido that makes the problem apper, specifically, the las for loop (if I comment this loop the enhancer works well):

    public void setTipoEquipo(TipoEquipo tipoEquipo) {
        boolean modificarDetalles = (tipoEquipo != this.tipoEquipo);       
        this.tipoEquipo = tipoEquipo;
       
        if (! modificarDetalles) return;
       
        //Eliminar los detalles de accesorios que no se hayan usado y que no estén en la nueva plantilla
        List<DetalleEquipoRecibido> deEliminar = new ArrayList<DetalleEquipoRecibido>();
        for (DetalleEquipoRecibido de : this.getDetallesEquipoRecibido()) {
            if (! de.isEmpty()) continue; //
            boolean eliminar = true;
            for (String parte: tipoEquipo.getListaDetallesEquipo()) {
                if (parte.equals(de.getElemento())) {
                    eliminar = false;
                }
            }
            if (eliminar)
                deEliminar.add(de);
        }
        this.getDetallesEquipoRecibido().removeAll(deEliminar);
       
        //Agregar a Detalles las plantillas de accesorios del nuevo tipo de equipo
        List<DetalleEquipoRecibido> deAgregar = new ArrayList<DetalleEquipoRecibido>();
        for (String parte: tipoEquipo.getListaDetallesEquipo()) {
            boolean agregar = true;
            for (DetalleEquipoRecibido de : this.getDetallesEquipoRecibido()) {
                if (de.getElemento().equals(parte)) {
                    agregar = false;
                }
            }
            if (agregar) {
                DetalleEquipoRecibido de = new DetalleEquipoRecibido();
                de.setElemento(parte);
                deAgregar.add(de);
            }
        }
        this.getDetallesEquipoRecibido().addAll(deAgregar);
       
        int i = 0;
        for (DetalleEquipoRecibido er : this.getDetallesEquipoRecibido() ) {
            i++;
            er.setNumeroLinea(i);
        }
    }

Reply all
Reply to author
Forward
0 new messages