-->
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.  [ 3 posts ] 
Author Message
 Post subject: FK is PK: Unable to find properties
PostPosted: Tue Apr 10, 2007 9:13 am 
Beginner
Beginner

Joined: Fri Sep 08, 2006 9:41 am
Posts: 23
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


Top
 Profile  
 
 Post subject: Re: FK is PK: Unable to find properties
PostPosted: Fri Dec 31, 2010 10:12 am 
Newbie

Joined: Mon Sep 24, 2007 2:55 pm
Posts: 13
How did you solve this problem?
I'm facing the same problem right now using JBoss6 including Hibernate 3.6.0.
14:45:16,603 ERROR [AbstractKernelController] Error installing to Start: name=persistence.unit:unitName=mbi2e-lafr-sb2000-ipc.ear/ejb-entity.jar#mbi2e-lafr-sb2000-ipc state=Create: org.hibernate.AnnotationException: Unable to find properties (adressNr) in entity annotated with @IdClass:biz.mbisoftware.fn.ejb.entity.MbiVsans
at org.hibernate.cfg.AnnotationBinder.processIdPropertiesIfNotAlready(AnnotationBinder.java:815) [:3.6.0.Final]
at org.hibernate.cfg.AnnotationBinder.bindClass(AnnotationBinder.java:707) [:3.6.0.Final]
at org.hibernate.cfg.Configuration$MetadataSourceQueue.processAnnotatedClassesQueue(Configuration.java:3977) [:3.6.0.Final]
at org.hibernate.cfg.Configuration$MetadataSourceQueue.processMetadata(Configuration.java:3931) [:3.6.0.Final]
at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1368) [:3.6.0.Final]
at org.hibernate.cfg.Configuration.buildMappings(Configuration.java:1345) [:3.6.0.Final]
at org.hibernate.ejb.Ejb3Configuration.buildMappings(Ejb3Configuration.java:1477) [:3.6.0.Final]
at org.hibernate.ejb.EventListenerConfigurator.configure(EventListenerConfigurator.java:193) [:3.6.0.Final]
at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:1096) [:3.6.0.Final]
at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:685) [:3.6.0.Final]
at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:73) [:3.6.0.Final]
at org.jboss.jpa.builder.DefaultCEMFBuilder.build(DefaultCEMFBuilder.java:47) [:1.0.2-alpha-3]
at org.jboss.as.jpa.scanner.HackCEMFBuilder.build(HackCEMFBuilder.java:49) [:6.0.1-SNAPSHOT]
at org.jboss.jpa.deployment.PersistenceUnitDeployment.start(PersistenceUnitDeployment.java:275) [:1.0.2-alpha-3]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [:1.6.0_23]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) [:1.6.0_23]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) [:1.6.0_23]
at java.lang.reflect.Method.invoke(Method.java:597) [:1.6.0_23]
at org.jboss.reflect.plugins.introspection.ReflectionUtils.invoke(ReflectionUtils.java:60) [jboss-reflect.jar:2.2.0.GA]
at org.jboss.reflect.plugins.introspection.ReflectMethodInfoImpl.invoke(ReflectMethodInfoImpl.java:168) [jboss-reflect.jar:2.2.0.GA]
at org.jboss.joinpoint.plugins.BasicMethodJoinPoint.dispatch(BasicMethodJoinPoint.java:66) [jboss-reflect.jar:2.2.0.GA]
at org.jboss.kernel.plugins.dependency.KernelControllerContextAction$JoinpointDispatchWrapper.execute(KernelControllerContextAction.java:257) [jboss-kernel.jar:2.2.0.GA]
at org.jboss.kernel.plugins.dependency.ExecutionWrapper.execute(ExecutionWrapper.java:47) [jboss-kernel.jar:2.2.0.GA]
at org.jboss.kernel.plugins.dependency.KernelControllerContextAction.dispatchExecutionWrapper(KernelControllerContextAction.java:125) [jboss-kernel.jar:2.2.0.GA]
at org.jboss.kernel.plugins.dependency.KernelControllerContextAction.dispatchJoinPoint(KernelControllerContextAction.java:72) [jboss-kernel.jar:2.2.0.GA]
at org.jboss.kernel.plugins.dependency.LifecycleAction.installActionInternal(LifecycleAction.java:202) [jboss-kernel.jar:2.2.0.GA]
at org.jboss.kernel.plugins.dependency.InstallsAwareAction.installAction(InstallsAwareAction.java:54) [jboss-kernel.jar:2.2.0.GA]
at org.jboss.kernel.plugins.dependency.InstallsAwareAction.installAction(InstallsAwareAction.java:42) [jboss-kernel.jar:2.2.0.GA]
at org.jboss.dependency.plugins.action.SimpleControllerContextAction.simpleInstallAction(SimpleControllerContextAction.java:62) [jboss-dependency.jar:2.2.0.GA]
at org.jboss.dependency.plugins.action.AccessControllerContextAction.install(AccessControllerContextAction.java:71) [jboss-dependency.jar:2.2.0.GA]
at org.jboss.dependency.plugins.AbstractControllerContextActions.install(AbstractControllerContextActions.java:51) [jboss-dependency.jar:2.2.0.GA]
at org.jboss.dependency.plugins.AbstractControllerContext.install(AbstractControllerContext.java:379) [jboss-dependency.jar:2.2.0.GA]
at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:2044) [jboss-dependency.jar:2.2.0.GA]
at org.jboss.dependency.plugins.AbstractController.incrementState(AbstractController.java:1083) [jboss-dependency.jar:2.2.0.GA]
at org.jboss.dependency.plugins.AbstractController.executeOrIncrementStateDirectly(AbstractController.java:1322) [jboss-dependency.jar:2.2.0.GA]
at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1246) [jboss-dependency.jar:2.2.0.GA]
at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1139) [jboss-dependency.jar:2.2.0.GA]
at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:894) [jboss-dependency.jar:2.2.0.GA]
at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:641) [jboss-dependency.jar:2.2.0.GA]
at org.jboss.deployers.vfs.deployer.kernel.BeanMetaDataDeployer.deploy(BeanMetaDataDeployer.java:182) [:2.2.0.GA]
at org.jboss.deployers.vfs.deployer.kernel.BeanMetaDataDeployer.deploy(BeanMetaDataDeployer.java:58) [:2.2.0.GA]
at org.jboss.deployers.spi.deployer.helpers.AbstractSimpleRealDeployer.internalDeploy(AbstractSimpleRealDeployer.java:62) [:2.2.0.GA]
at org.jboss.deployers.spi.deployer.helpers.AbstractRealDeployer.deploy(AbstractRealDeployer.java:55) [:2.2.0.GA]
at org.jboss.deployers.plugins.deployers.DeployerWrapper.deploy(DeployerWrapper.java:179) [:2.2.0.GA]
at org.jboss.deployers.plugins.deployers.DeployersImpl.doDeploy(DeployersImpl.java:1832) [:2.2.0.GA]
at org.jboss.deployers.plugins.deployers.DeployersImpl.doInstallParentFirst(DeployersImpl.java:1550) [:2.2.0.GA]
at org.jboss.deployers.plugins.deployers.DeployersImpl.doInstallParentFirst(DeployersImpl.java:1571) [:2.2.0.GA]
at org.jboss.deployers.plugins.deployers.DeployersImpl.doInstallParentFirst(DeployersImpl.java:1603) [:2.2.0.GA]
at org.jboss.deployers.plugins.deployers.DeployersImpl.install(DeployersImpl.java:1491) [:2.2.0.GA]
at org.jboss.dependency.plugins.AbstractControllerContext.install(AbstractControllerContext.java:379) [jboss-dependency.jar:2.2.0.GA]
at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:2044) [jboss-dependency.jar:2.2.0.GA]
at org.jboss.dependency.plugins.AbstractController.incrementState(AbstractController.java:1083) [jboss-dependency.jar:2.2.0.GA]
at org.jboss.dependency.plugins.AbstractController.executeOrIncrementStateDirectly(AbstractController.java:1322) [jboss-dependency.jar:2.2.0.GA]
at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1246) [jboss-dependency.jar:2.2.0.GA]
at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1139) [jboss-dependency.jar:2.2.0.GA]
at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:939) [jboss-dependency.jar:2.2.0.GA]
at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:654) [jboss-dependency.jar:2.2.0.GA]
at org.jboss.deployers.plugins.deployers.DeployersImpl.change(DeployersImpl.java:1983) [:2.2.0.GA]
at org.jboss.deployers.plugins.deployers.DeployersImpl.process(DeployersImpl.java:1076) [:2.2.0.GA]
at org.jboss.deployers.plugins.main.MainDeployerImpl.process(MainDeployerImpl.java:679) [:2.2.0.GA]
at org.jboss.system.server.profileservice.deployers.MainDeployerPlugin.process(MainDeployerPlugin.java:106) [:6.0.1-SNAPSHOT]
at org.jboss.profileservice.dependency.ProfileControllerContext$DelegateDeployer.process(ProfileControllerContext.java:143) [:0.2.2]
at org.jboss.profileservice.dependency.ProfileDeployAction.deploy(ProfileDeployAction.java:151) [:0.2.2]
at org.jboss.profileservice.dependency.ProfileDeployAction.installActionInternal(ProfileDeployAction.java:94) [:0.2.2]
at org.jboss.kernel.plugins.dependency.InstallsAwareAction.installAction(InstallsAwareAction.java:54) [jboss-kernel.jar:2.2.0.GA]
at org.jboss.kernel.plugins.dependency.InstallsAwareAction.installAction(InstallsAwareAction.java:42) [jboss-kernel.jar:2.2.0.GA]
at org.jboss.dependency.plugins.action.SimpleControllerContextAction.simpleInstallAction(SimpleControllerContextAction.java:62) [jboss-dependency.jar:2.2.0.GA]
at org.jboss.dependency.plugins.action.AccessControllerContextAction.install(AccessControllerContextAction.java:71) [jboss-dependency.jar:2.2.0.GA]
at org.jboss.dependency.plugins.AbstractControllerContextActions.install(AbstractControllerContextActions.java:51) [jboss-dependency.jar:2.2.0.GA]
at org.jboss.dependency.plugins.AbstractControllerContext.install(AbstractControllerContext.java:379) [jboss-dependency.jar:2.2.0.GA]
at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:2044) [jboss-dependency.jar:2.2.0.GA]
at org.jboss.dependency.plugins.AbstractController.incrementState(AbstractController.java:1083) [jboss-dependency.jar:2.2.0.GA]
at org.jboss.dependency.plugins.AbstractController.executeOrIncrementStateDirectly(AbstractController.java:1322) [jboss-dependency.jar:2.2.0.GA]
at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1246) [jboss-dependency.jar:2.2.0.GA]
at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1139) [jboss-dependency.jar:2.2.0.GA]
at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:939) [jboss-dependency.jar:2.2.0.GA]
at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:654) [jboss-dependency.jar:2.2.0.GA]
at org.jboss.profileservice.dependency.ProfileActivationWrapper$BasicProfileActivation.start(ProfileActivationWrapper.java:190) [:0.2.2]
at org.jboss.profileservice.dependency.ProfileActivationWrapper.start(ProfileActivationWrapper.java:87) [:0.2.2]
at org.jboss.profileservice.dependency.ProfileActivationService.activateProfile(ProfileActivationService.java:215) [:0.2.2]
at org.jboss.profileservice.dependency.ProfileActivationService.activate(ProfileActivationService.java:159) [:0.2.2]
at org.jboss.profileservice.bootstrap.AbstractProfileServiceBootstrap.activate(AbstractProfileServiceBootstrap.java:112) [:0.2.2]
at org.jboss.profileservice.resolver.BasicResolverFactory$ProfileResolverFacade.deploy(BasicResolverFactory.java:87) [:0.2.2]
at org.jboss.profileservice.bootstrap.AbstractProfileServiceBootstrap.start(AbstractProfileServiceBootstrap.java:91) [:0.2.2]
at org.jboss.system.server.profileservice.bootstrap.BasicProfileServiceBootstrap.start(BasicProfileServiceBootstrap.java:132) [:6.0.1-SNAPSHOT]
at org.jboss.system.server.profileservice.bootstrap.BasicProfileServiceBootstrap.start(BasicProfileServiceBootstrap.java:56) [:6.0.1-SNAPSHOT]
at org.jboss.bootstrap.impl.base.server.AbstractServer.startBootstraps(AbstractServer.java:827) [jboss-bootstrap-impl-base.jar:2.1.0-alpha-5]
at org.jboss.bootstrap.impl.base.server.AbstractServer$StartServerTask.run(AbstractServer.java:417) [jboss-bootstrap-impl-base.jar:2.1.0-alpha-5]
at java.lang.Thread.run(Thread.java:662) [:1.6.0_23]

/**
* Data object for table MbiVsans.
*/
@Entity
@IdClass( value = MbiVsans.PK.class )
@Table( name = "mbi_vsans" )
public class MbiVsans implements Serializable, Comparable<MbiVsans>
{
/** Field debitorNr. */
@Id
@Column( name = "debitor_nr", nullable = false )
private Integer debitorNr;

/** Relation with MbiAdres. */
@Id
@ManyToOne( fetch = FetchType.LAZY )
@PrimaryKeyJoinColumn( name = "adress_nr" )
private MbiAdres mbiAdresAdressNr;
...
/**
* The Primary Key class.
*/
public static class PK implements Serializable
{
/** Default class version id. */
private static final long serialVersionUID = 1L;

/** Field debitorNr. */
@Column( name = "debitor_nr" )
private Integer debitorNr;

/** Field adressNr. */
@Column( name = "adress_nr" )
private Integer adressNr;
...
}
}


Top
 Profile  
 
 Post subject: Re: FK is PK: Unable to find properties
PostPosted: Fri Dec 31, 2010 11:15 am 
Beginner
Beginner

Joined: Fri Sep 08, 2006 9:41 am
Posts: 23
No, so I switched to EclipseLink and there it worked.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

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.