I'm really getting mad with this EJB3 stuff, because I'm trying to set up a concept for migrating EJB2.0-Entity-Beans to EJB3.0-Entities. Was testing it with OpenJPA - didn't work! Was testing it with EclipseLink - didn't work! And now I'm testing Hibernate and...
Ok, here is my problem. The log messages from the deployment show, that the annotation @Column(name="VTR_ID") at my pk-attribute vtrId gets ignored. I'm not positive, but I think it has to do with that I'm using an IdClass.
Has anyone a similar problem or - even better - a solution for how to map the attribute Vertrag.vtrId to the table-column EJB3_VTR.VTR_ID when using an Id-Class?!? Or am I doing anything wrong?!? (I really need the Id-Class in some other cases, that are more difficult. It won't help me to leave out the Id-Class-Annotation or to replace it by an embedded Id.)
Here is my entity:Code:
import javax.persistence.*;
import de.ivv.aa.jif.business.TransferObject;
@Entity
@Table(name="EJB3_VTR")
@IdClass(VertragPK.class)
@NamedQueries({
@NamedQuery(name="Vertrag.getMaxId", query="SELECT MAX(vtr.vtrId) FROM Vertrag AS vtr"),
@NamedQuery(name="Vertrag.getMinId", query="SELECT MIN(vtr.vtrId) FROM Vertrag AS vtr")
})
public class Vertrag implements Serializable {
private Integer vtrId;
private String vsnr;
@Id @Column(name="VTR_ID")
public Integer getVtrId() { return this.vtrId;}
public void setVtrId(Integer aVtrId) { this.vtrId = aVtrId; }
@Column(name="VSNR")
public String getVsnr() { return this.vsnr; }
public void setVsnr(String aVsnr) { this.vsnr = aVsnr; }
}
---------------------------------------------------------
import java.io.Serializable;
public class VertragPK implements Serializable {
private Integer vtrId;
public VertragPK(){}
public VertragPK(Integer vtrId) { this.vtrId = vtrId; }
public Integer getVtrId() { return this.vtrId; }
public void setVtrId(Integer vtrId) { this.vtrId = vtrId; }
public boolean equals(Object obj) {
if (obj == this) { return true; }
if (!(obj instanceof VertragPK)) { return false; }
VertragPK pk = (VertragPK) obj;
if ( pk.getVtrId().equals(this.vtrId)) { return true; }
else { return false; }
}
public int hashCode() {
//some custom implementation
}
public String toString() {
//some custom implementation
}
}
And this is the log-output from the deployment:I marked the significant lines, that show which binding gets done.
DEBUG - org.hibernate.ejb.Ejb3Configuration - Processing PersistenceUnitInfo [
name: aa_ejb3test_business
persistence provider classname: org.hibernate.ejb.HibernatePersistence
classloader: weblogic.utils.classloaders.GenericClassLoader@f774bc finder: weblogic.utils.classloaders.CodeGenClassFinder@1743f01 annotation: aa_ejb3test_app@
Temporary classloader: weblogic.utils.classloaders.GenericClassLoader@d470f0 finder: weblogic.utils.classloaders.CodeGenClassFinder@142cc2c annotation:
excludeUnlistedClasses: false
JTA datasource: weblogic.jdbc.common.internal.RmiDataSource@40a47f
Non JTA datasource: null
Transaction type: JTA
PU root URL: file:/C:/wls10/user_projects/domains/user/servers/AdminServer/tmp/_WL_user/aa_ejb3test_app/91utdo/aa_ejb3test_business/
Jar files URLs []
Managed classes names [
de.ivv.aa.ejb3test.business.Vertrag]
Mapping files names []
Properties [
hibernate.transaction.manager_lookup_class: org.hibernate.transaction.WeblogicTransactionManagerLookup
hibernate.dialect: org.hibernate.dialect.MySQLDialect
hibernate.show_sql: true
hibernate.transaction.factory_class: org.hibernate.transaction.JTATransactionFactory]
DEBUG - org.hibernate.ejb.Ejb3Configuration - Detect class: true; detect hbm: true
DEBUG - org.hibernate.ejb.Ejb3Configuration - Detect class: true; detect hbm: true
DEBUG - org.hibernate.ejb.packaging.AbstractJarVisitor - Searching mapped entities in jar/par: file:/C:/wls10/user_projects/domains/user/servers/AdminServer/tmp/_WL_user/aa_ejb3test_app/91utdo/aa_ejb3test_business/
DEBUG - org.hibernate.ejb.packaging.AbstractJarVisitor - Filtering: de.ivv.aa.ejb3test.business.SvcPersistierung
DEBUG - org.hibernate.ejb.packaging.AbstractJarVisitor - Filtering: de.ivv.aa.ejb3test.business.SvcPersistierungBean
DEBUG - org.hibernate.ejb.packaging.AbstractJarVisitor - Filtering: de.ivv.aa.ejb3test.business.SvcPersistierungBeanImpl
DEBUG - org.hibernate.ejb.packaging.AbstractJarVisitor - Filtering: de.ivv.aa.ejb3test.business.SvcPersistierungGen
DEBUG - org.hibernate.ejb.packaging.AbstractJarVisitor - Filtering: de.ivv.aa.ejb3test.business.SvcPersistierungHome
DEBUG - org.hibernate.ejb.packaging.AbstractJarVisitor - Filtering: de.ivv.aa.ejb3test.business.SvcPersistierung_pitod4_ELOImpl
DEBUG - org.hibernate.ejb.packaging.AbstractJarVisitor - Filtering: de.ivv.aa.ejb3test.business.SvcPersistierung_pitod4_Impl
DEBUG - org.hibernate.ejb.packaging.AbstractJarVisitor - Filtering: de.ivv.aa.ejb3test.business.SvcPersistierung_pitod4_Intf
DEBUG - org.hibernate.ejb.packaging.AbstractJarVisitor - Filtering: de.ivv.aa.ejb3test.business.SvcPersistierung_pitod4_LocalHomeImpl
DEBUG - org.hibernate.ejb.packaging.AbstractJarVisitor - Filtering: de.ivv.aa.ejb3test.business.Vertrag
DEBUG - org.hibernate.ejb.packaging.AbstractJarVisitor - Java element filter matched for de.ivv.aa.ejb3test.business.Vertrag
DEBUG - org.hibernate.ejb.packaging.AbstractJarVisitor - Filtering: de.ivv.aa.ejb3test.business.VertragGen
DEBUG - org.hibernate.ejb.packaging.AbstractJarVisitor - Filtering: de.ivv.aa.ejb3test.business.VertragImpl
DEBUG - org.hibernate.ejb.packaging.AbstractJarVisitor - Filtering: de.ivv.aa.ejb3test.business.VertragPK
WARN - org.hibernate.ejb.Ejb3Configuration - Overriding hibernate.transaction.factory_class is dangerous, this might break the EJB3 specification implementation
DEBUG - org.hibernate.cfg.AnnotationConfiguration - Execute first pass mapping processing
DEBUG - org.hibernate.cfg.AnnotationConfiguration - Process hbm files
DEBUG - org.hibernate.cfg.AnnotationConfiguration - Process annotated classes
INFO - org.hibernate.cfg.AnnotationBinder - Binding entity from annotated class: de.ivv.aa.ejb3test.business.Vertrag
INFO - org.hibernate.cfg.annotations.QueryBinder - Binding Named query: Vertrag.getMaxId => SELECT MAX(vtr.vtrId) FROM Vertrag AS vtr
INFO - org.hibernate.cfg.annotations.QueryBinder - Binding Named query: Vertrag.getMinId => SELECT MIN(vtr.vtrId) FROM Vertrag AS vtr
DEBUG - org.hibernate.cfg.Ejb3Column - Binding column DTYPE. Unique false. Nullable false.
DEBUG - org.hibernate.cfg.annotations.EntityBinder - Import with entity name Vertrag
INFO - org.hibernate.cfg.annotations.EntityBinder - Bind entity de.ivv.aa.ejb3test.business.Vertrag on table EJB3_VTR
DEBUG - org.hibernate.cfg.AnnotationBinder - Processing de.ivv.aa.ejb3test.business.Vertrag property annotation
DEBUG - org.hibernate.cfg.AnnotationBinder - Binding component with path: de.ivv.aa.ejb3test.business.Vertrag.id
DEBUG - org.hibernate.cfg.AnnotationBinder - Processing de.ivv.aa.ejb3test.business.VertragPK property annotation
DEBUG - org.hibernate.cfg.AnnotationBinder - Processing annotations of de.ivv.aa.ejb3test.business.VertragPK.vtrId
DEBUG - org.hibernate.cfg.Ejb3Column -
Binding column vtrId. Unique false. Nullable true.
DEBUG - org.hibernate.cfg.annotations.PropertyBinder - binding property vtrId with lazy=false
DEBUG - org.hibernate.cfg.annotations.SimpleValueBinder - building SimpleValue for vtrId
DEBUG - org.hibernate.cfg.annotations.PropertyBinder - Building property vtrId
DEBUG - org.hibernate.cfg.annotations.PropertyBinder - Cascading vtrId with null
DEBUG - org.hibernate.cfg.AnnotationBinder - Binding component with path: de.ivv.aa.ejb3test.business.Vertrag._identifierMapper
DEBUG - org.hibernate.cfg.AnnotationBinder - Processing de.ivv.aa.ejb3test.business.Vertrag property annotation
DEBUG - org.hibernate.cfg.AnnotationBinder - Processing annotations of de.ivv.aa.ejb3test.business.Vertrag.vtrId
DEBUG - org.hibernate.cfg.Ejb3Column -
Binding column vtrId. Unique false. Nullable true.
DEBUG - org.hibernate.cfg.annotations.PropertyBinder - binding property vtrId with lazy=false
DEBUG - org.hibernate.cfg.annotations.SimpleValueBinder - building SimpleValue for vtrId
DEBUG - org.hibernate.cfg.annotations.PropertyBinder - Building property vtrId
DEBUG - org.hibernate.cfg.annotations.PropertyBinder - Cascading vtrId with null
DEBUG - org.hibernate.cfg.AnnotationBinder - Processing annotations of de.ivv.aa.ejb3test.business.Vertrag.vsnr
DEBUG - org.hibernate.cfg.Ejb3Column -
Binding column VSNR. Unique false. Nullable true.
DEBUG - org.hibernate.cfg.annotations.PropertyBinder - binding property vsnr with lazy=false
DEBUG - org.hibernate.cfg.annotations.SimpleValueBinder - building SimpleValue for vsnr
DEBUG - org.hibernate.cfg.annotations.PropertyBinder - Building property vsnr
DEBUG - org.hibernate.cfg.annotations.PropertyBinder - Cascading vsnr with null
...
Greetings from Hannover, Germany