Unable to find properties (contractnr, producttypenr) in entity annotated with @IdClass:nl.reinders.bm.Producttype2Contract
I assume this exception tries to tell me it can't find the properties in the Producttype2ContractPK class specified in nl.reinders.bm.Producttype2Contract. So I tried to resolved that, but now am stuck.
There basically is a N-M relation between Producttype and Contract. However, the N-M relation "Producttype2Contract" itself contains some attributes, so it is in fact a N-1 plus 1-M.
Producttype and Contract each have an integer as the PK, so Producttype2Contract has both integers as its primary key, so there is a special PK class. It works if the N-M class has a separate PK, but if the PK is just both FK's then I have this problem.
One note: all entity classes are split in two: a user editable part and a from-the-DB generated part.
@Entity
@Table(name="producttype2contract")
@IdClass(nl.reinders.bm.generated.Producttype2ContractPK.class)
public class Producttype2Contract extends nl.reinders.bm.generated.Producttype2Contract
...
@MappedSuperclass
public class Producttype2Contract
...
@Id @ManyToOne @JoinColumn(name="contractnr") private nl.reinders.bm.Contract iContract;
final static public String PROPERTY_CONTRACT = "contract";
...
@Id @ManyToOne @JoinColumn(name="producttypenr") private nl.reinders.bm.Producttype iProducttype;
final static public String PROPERTY_PRODUCTTYPE = "producttype";
public class Producttype2ContractPK
implements java.io.Serializable
{
/** Producttypenr */
public Integer getProducttypenr() { return producttypenr; }
public void setProducttypenr(Integer value)
{
Integer lValue = producttypenr;
producttypenr = value;
}
private Integer producttypenr;
/** Contractnr */
public Integer getContractnr() { return contractnr; }
public void setContractnr(Integer value)
{
Integer lValue = contractnr;
contractnr = value;
}
private Integer contractnr;
}
Hibernate version:
3.2.3ga
Mapping documents:
JPA
Code between sessionFactory.openSession() and session.close():
N/A
Full stack trace of any exception that occurs:
Exception in thread "main" javax.persistence.PersistenceException: org.hibernate.AnnotationException: Unable to find properties (contractnr, producttypenr) in entity annotated with @IdClass:nl.reinders.bm.Producttype2Contract
at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:247)
at org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:120)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:51)
at nl.reinders.BMTest.main(BMTest.java:35)
Caused by: org.hibernate.AnnotationException: Unable to find properties (contractnr, producttypenr) in entity annotated with @IdClass:nl.reinders.bm.Producttype2Contract
at org.hibernate.cfg.AnnotationBinder.bindClass(AnnotationBinder.java:724)
at org.hibernate.cfg.AnnotationConfiguration.processArtifactsOfType(AnnotationConfiguration.java:452)
at org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(AnnotationConfiguration.java:268)
at org.hibernate.cfg.Configuration.buildMappings(Configuration.java:1115)
at org.hibernate.ejb.Ejb3Configuration.buildMappings(Ejb3Configuration.java:1211)
at org.hibernate.ejb.EventListenerConfigurator.configure(EventListenerConfigurator.java:154)
at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:847)
at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:178)
at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:235)
... 3 more
Name and version of the database you are using:
Informix 10
The generated SQL (show_sql=true):
N/A
Debug level Hibernate log excerpt:
Binding entity from annotated class: nl.reinders.bm.Producttype2Contract
Binding column DTYPE unique false
Import with entity name=Producttype2Contract
Bind entity nl.reinders.bm.Producttype2Contract on table producttype2contract
Processing nl.reinders.bm.Producttype2Contract property annotation
Processing nl.reinders.bm.Producttype2Contract property annotation
Processing nl.reinders.bm.Producttype2Contract field annotation
Processing nl.reinders.bm.Producttype2Contract field annotation
Binding component with path: nl.reinders.bm.Producttype2Contract.id
Processing nl.reinders.bm.generated.Producttype2ContractPK field annotation
Processing annotations of nl.reinders.bm.generated.Producttype2ContractPK.producttypenr
Binding column producttypenr unique false
binding property producttypenr with lazy=false
building SimpleValue for producttypenr
Building property producttypenr
Cascading producttypenr with null
Processing annotations of nl.reinders.bm.generated.Producttype2ContractPK.contractnr
Binding column contractnr unique false
binding property contractnr with lazy=false
building SimpleValue for contractnr
Building property contractnr
Cascading contractnr with null
Binding component with path: nl.reinders.bm.Producttype2Contract._identifierMapper
Processing nl.reinders.bm.Producttype2Contract field annotation
Processing annotations of nl.reinders.bm.Producttype2Contract.producttypenr
Binding column producttypenr unique false
binding property producttypenr with lazy=false
building SimpleValue for producttypenr
Building property producttypenr
Cascading producttypenr with null
Processing annotations of nl.reinders.bm.Producttype2Contract.contractnr
Binding column contractnr unique false
binding property contractnr with lazy=false
building SimpleValue for contractnr
Building property contractnr
Cascading contractnr with null
Processing annotations of nl.reinders.bm.Producttype2Contract.iProducttype
Binding column producttypenr unique false
Binding column iProducttype unique false
Building property iProducttype
Cascading iProducttype with none
Processing annotations of nl.reinders.bm.Producttype2Contract.iContract
Binding column contractnr unique false
Binding column iContract unique false
Building property iContract
Cascading iContract with none
Processing annotations of nl.reinders.bm.Producttype2Contract.iRetailprice
Binding column retailprice unique false
binding property iRetailprice with lazy=false
building SimpleValue for iRetailprice
Building property iRetailprice
Cascading iRetailprice with null
Processing annotations of nl.reinders.bm.Producttype2Contract.iWholesaleprice
Binding column wholesaleprice unique false
binding property iWholesaleprice with lazy=false
building SimpleValue for iWholesaleprice
Building property iWholesaleprice
Cascading iWholesaleprice with null
Processing annotations of nl.reinders.bm.Producttype2Contract.iDwhmodified
Binding column dwhmodified unique false
binding property iDwhmodified with lazy=false
building SimpleValue for iDwhmodified
Building property iDwhmodified
Cascading iDwhmodified with null
Processing annotations of nl.reinders.bm.Producttype2Contract.iDwhby
Binding column dwhby unique false
binding property iDwhby with lazy=false
building SimpleValue for iDwhby
Building property iDwhby
Cascading iDwhby with null
|