users@glassfish.java.net

Need help with persisting composit foreign keys

From: <glassfish_at_javadesktop.org>
Date: Mon, 27 Aug 2007 13:03:17 PDT

Hi all,

    I am new to JPA and only worked/played with it for about a month. I am running into a problem of persisting an entity bean that has a composite foreign key to another bean.

I have 3 entity beans.

PropertyTransaction that has a ManyToOne relationship to VendorAccount.
VendorAccount has a ManyToOne relationship to Property.

And when I try to persist PropertyTransaction I got the following error. But it works when I persist VendorAccount. So I am not sure is the error message really pointing to my problem. The class definitions are at the bottom of the post.

Exception Description: Missing mapping for field [Vendor_Account.property_Id].
Descriptor: RelationalDescriptor(com.sandboxcomputing.propertymgmt.model.entity.VendorAccount --> [DatabaseTable(Vendor_Account)])
Aug 27, 2007 3:27:49 PM com.sun.faces.lifecycle.InvokeApplicationPhase execute
SEVERE: #{propertyTransaction.create}: javax.faces.el.EvaluationException: org.springframework.transaction.UnexpectedRollbackException: JPA transaction unexpectedly rolled back (maybe marked rollback-only after a failed operation); nested exception is javax.persistence.RollbackException: Exception [TOPLINK-45] (Oracle TopLink Essentials - 2.0 (Build b41-beta2 (03/30/2007))): oracle.toplink.essentials.exceptions.DescriptorException
Exception Description: Missing mapping for field [Vendor_Account.property_Id].
Descriptor: RelationalDescriptor(com.sandboxcomputing.propertymgmt.model.entity.VendorAccount --> [DatabaseTable(Vendor_Account)])
javax.faces.FacesException: #{propertyTransaction.create}: javax.faces.el.EvaluationException: org.springframework.transaction.UnexpectedRollbackException: JPA transaction unexpectedly rolled back (maybe marked rollback-only after a failed operation); nested exception is javax.persistence.RollbackException: Exception [TOPLINK-45] (Oracle TopLink Essentials - 2.0 (Build b41-beta2 (03/30/2007))): oracle.toplink.essentials.exceptions.DescriptorException
Exception Description: Missing mapping for field [Vendor_Account.property_Id].
Descriptor: RelationalDescriptor(com.sandboxcomputing.propertymgmt.model.entity.VendorAccount --> [DatabaseTable(Vendor_Account)])
        at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:78)
        at javax.faces.component.UICommand.broadcast(UICommand.java:312)
        at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:267)
        at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:381)
        at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:75)
        at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:200)
        at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:90)
        at javax.faces.webapp.FacesServlet.service(FacesServlet.java:197)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
        at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
        at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
        at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
        at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
        at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
        at java.lang.Thread.run(Thread.java:613)
Caused by: javax.faces.el.EvaluationException: org.springframework.transaction.UnexpectedRollbackException: JPA transaction unexpectedly rolled back (maybe marked rollback-only after a failed operation); nested exception is javax.persistence.RollbackException: Exception [TOPLINK-45] (Oracle TopLink Essentials - 2.0 (Build b41-beta2 (03/30/2007))): oracle.toplink.essentials.exceptions.DescriptorException
Exception Description: Missing mapping for field [Vendor_Account.property_Id].
Descriptor: RelationalDescriptor(com.sandboxcomputing.propertymgmt.model.entity.VendorAccount --> [DatabaseTable(Vendor_Account)])
        at com.sun.faces.el.MethodBindingImpl.invoke(MethodBindingImpl.java:130)
        at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:72)
        ... 21 more
Caused by: org.springframework.transaction.UnexpectedRollbackException: JPA transaction unexpectedly rolled back (maybe marked rollback-only after a failed operation); nested exception is javax.persistence.RollbackException: Exception [TOPLINK-45] (Oracle TopLink Essentials - 2.0 (Build b41-beta2 (03/30/2007))): oracle.toplink.essentials.exceptions.DescriptorException
Exception Description: Missing mapping for field [Vendor_Account.property_Id].
Descriptor: RelationalDescriptor(com.sandboxcomputing.propertymgmt.model.entity.VendorAccount --> [DatabaseTable(Vendor_Account)])
        at org.springframework.orm.jpa.JpaTransactionManager.doCommit(JpaTransactionManager.java:436)
        at org.springframework.transaction.support.AbstractPlatformTransactionManager.processCommit(AbstractPlatformTransactionManager.java:662)
        at org.springframework.transaction.support.AbstractPlatformTransactionManager.commit(AbstractPlatformTransactionManager.java:632)
        at org.springframework.transaction.interceptor.TransactionAspectSupport.commitTransactionAfterReturning(TransactionAspectSupport.java:314)
        at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:117)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:166)
        at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
        at $Proxy32.create(Unknown Source)
        at com.sandboxcomputing.propertymgmt.control.PropertyTransactionController.create(PropertyTransactionController.java:74)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:585)
        at com.sun.faces.el.MethodBindingImpl.invoke(MethodBindingImpl.java:126)
        ... 22 more
Caused by: javax.persistence.RollbackException: Exception [TOPLINK-45] (Oracle TopLink Essentials - 2.0 (Build b41-beta2 (03/30/2007))): oracle.toplink.essentials.exceptions.DescriptorException
Exception Description: Missing mapping for field [Vendor_Account.property_Id].
Descriptor: RelationalDescriptor(com.sandboxcomputing.propertymgmt.model.entity.VendorAccount --> [DatabaseTable(Vendor_Account)])
        at oracle.toplink.essentials.internal.ejb.cmp3.transaction.base.EntityTransactionImpl.commit(EntityTransactionImpl.java:105)
        at oracle.toplink.essentials.internal.ejb.cmp3.transaction.EntityTransactionImpl.commit(EntityTransactionImpl.java:45)
        at org.springframework.orm.jpa.JpaTransactionManager.doCommit(JpaTransactionManager.java:433)
        ... 35 more
Caused by: Exception [TOPLINK-45] (Oracle TopLink Essentials - 2.0 (Build b41-beta2 (03/30/2007))): oracle.toplink.essentials.exceptions.DescriptorException
Exception Description: Missing mapping for field [Vendor_Account.property_Id].
Descriptor: RelationalDescriptor(com.sandboxcomputing.propertymgmt.model.entity.VendorAccount --> [DatabaseTable(Vendor_Account)])
        at oracle.toplink.essentials.exceptions.DescriptorException.missingMappingForField(DescriptorException.java:886)
        at oracle.toplink.essentials.internal.descriptors.ObjectBuilder.extractValueFromObjectForField(ObjectBuilder.java:1597)
        at oracle.toplink.essentials.mappings.OneToOneMapping.writeFromObjectIntoRow(OneToOneMapping.java:1076)
        at oracle.toplink.essentials.internal.descriptors.ObjectBuilder.buildRow(ObjectBuilder.java:732)
        at oracle.toplink.essentials.internal.descriptors.ObjectBuilder.buildRow(ObjectBuilder.java:720)
        at oracle.toplink.essentials.internal.queryframework.DatabaseQueryMechanism.insertObjectForWrite(DatabaseQueryMechanism.java:425)
        at oracle.toplink.essentials.queryframework.InsertObjectQuery.executeCommit(InsertObjectQuery.java:74)
        at oracle.toplink.essentials.internal.queryframework.DatabaseQueryMechanism.performUserDefinedWrite(DatabaseQueryMechanism.java:635)
        at oracle.toplink.essentials.internal.queryframework.DatabaseQueryMechanism.performUserDefinedInsert(DatabaseQueryMechanism.java:599)
        at oracle.toplink.essentials.internal.queryframework.DatabaseQueryMechanism.insertObjectForWriteWithChangeSet(DatabaseQueryMechanism.java:495)
        at oracle.toplink.essentials.queryframework.WriteObjectQuery.executeCommitWithChangeSet(WriteObjectQuery.java:130)
        at oracle.toplink.essentials.internal.queryframework.DatabaseQueryMechanism.executeWriteWithChangeSet(DatabaseQueryMechanism.java:283)
        at oracle.toplink.essentials.queryframework.WriteObjectQuery.executeDatabaseQuery(WriteObjectQuery.java:67)
        at oracle.toplink.essentials.queryframework.DatabaseQuery.execute(DatabaseQuery.java:609)
        at oracle.toplink.essentials.queryframework.DatabaseQuery.executeInUnitOfWork(DatabaseQuery.java:536)
        at oracle.toplink.essentials.queryframework.ObjectLevelModifyQuery.executeInUnitOfWorkObjectLevelModifyQuery(ObjectLevelModifyQuery.java:123)
        at oracle.toplink.essentials.queryframework.ObjectLevelModifyQuery.executeInUnitOfWork(ObjectLevelModifyQuery.java:95)
        at oracle.toplink.essentials.internal.sessions.UnitOfWorkImpl.internalExecuteQuery(UnitOfWorkImpl.java:2219)
        at oracle.toplink.essentials.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:937)
        at oracle.toplink.essentials.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:894)
        at oracle.toplink.essentials.internal.sessions.CommitManager.commitNewObjectsForClassWithChangeSet(CommitManager.java:254)
        at oracle.toplink.essentials.internal.sessions.CommitManager.commitAllObjectsWithChangeSet(CommitManager.java:175)
        at oracle.toplink.essentials.internal.sessions.AbstractSession.writeAllObjectsWithChangeSet(AbstractSession.java:2638)
        at oracle.toplink.essentials.internal.sessions.UnitOfWorkImpl.commitToDatabase(UnitOfWorkImpl.java:1030)
        at oracle.toplink.essentials.internal.ejb.cmp3.base.RepeatableWriteUnitOfWork.commitToDatabase(RepeatableWriteUnitOfWork.java:387)
        at oracle.toplink.essentials.internal.sessions.UnitOfWorkImpl.commitToDatabaseWithChangeSet(UnitOfWorkImpl.java:1112)
        at oracle.toplink.essentials.internal.ejb.cmp3.base.RepeatableWriteUnitOfWork.commitRootUnitOfWork(RepeatableWriteUnitOfWork.java:91)
        at oracle.toplink.essentials.internal.sessions.UnitOfWorkImpl.commitAndResume(UnitOfWorkImpl.java:842)
        at oracle.toplink.essentials.internal.ejb.cmp3.transaction.base.EntityTransactionImpl.commit(EntityTransactionImpl.java:87)
        ... 37 more
Aug 27, 2007 3:27:49 PM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet Faces Servlet threw exception
javax.faces.FacesException: #{propertyTransaction.create}: javax.faces.el.EvaluationException: org.springframework.transaction.UnexpectedRollbackException: JPA transaction unexpectedly rolled back (maybe marked rollback-only after a failed operation); nested exception is javax.persistence.RollbackException: Exception [TOPLINK-45] (Oracle TopLink Essentials - 2.0 (Build b41-beta2 (03/30/2007))): oracle.toplink.essentials.exceptions.DescriptorException
Exception Description: Missing mapping for field [Vendor_Account.property_Id].
Descriptor: RelationalDescriptor(com.sandboxcomputing.propertymgmt.model.entity.VendorAccount --> [DatabaseTable(Vendor_Account)])
        at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:78)
        at javax.faces.component.UICommand.broadcast(UICommand.java:312)
        at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:267)
        at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:381)
        at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:75)
        at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:200)
        at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:90)
        at javax.faces.webapp.FacesServlet.service(FacesServlet.java:197)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
        at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
        at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
        at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
        at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
        at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
        at java.lang.Thread.run(Thread.java:613)
Caused by: javax.faces.el.EvaluationException: org.springframework.transaction.UnexpectedRollbackException: JPA transaction unexpectedly rolled back (maybe marked rollback-only after a failed operation); nested exception is javax.persistence.RollbackException: Exception [TOPLINK-45] (Oracle TopLink Essentials - 2.0 (Build b41-beta2 (03/30/2007))): oracle.toplink.essentials.exceptions.DescriptorException
Exception Description: Missing mapping for field [Vendor_Account.property_Id].
Descriptor: RelationalDescriptor(com.sandboxcomputing.propertymgmt.model.entity.VendorAccount --> [DatabaseTable(Vendor_Account)])
        at com.sun.faces.el.MethodBindingImpl.invoke(MethodBindingImpl.java:130)
        at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:72)
        ... 21 more
Caused by: org.springframework.transaction.UnexpectedRollbackException: JPA transaction unexpectedly rolled back (maybe marked rollback-only after a failed operation); nested exception is javax.persistence.RollbackException: Exception [TOPLINK-45] (Oracle TopLink Essentials - 2.0 (Build b41-beta2 (03/30/2007))): oracle.toplink.essentials.exceptions.DescriptorException
Exception Description: Missing mapping for field [Vendor_Account.property_Id].
Descriptor: RelationalDescriptor(com.sandboxcomputing.propertymgmt.model.entity.VendorAccount --> [DatabaseTable(Vendor_Account)])
        at org.springframework.orm.jpa.JpaTransactionManager.doCommit(JpaTransactionManager.java:436)
        at org.springframework.transaction.support.AbstractPlatformTransactionManager.processCommit(AbstractPlatformTransactionManager.java:662)
        at org.springframework.transaction.support.AbstractPlatformTransactionManager.commit(AbstractPlatformTransactionManager.java:632)
        at org.springframework.transaction.interceptor.TransactionAspectSupport.commitTransactionAfterReturning(TransactionAspectSupport.java:314)
        at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:117)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:166)
        at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
        at $Proxy32.create(Unknown Source)
        at com.sandboxcomputing.propertymgmt.control.PropertyTransactionController.create(PropertyTransactionController.java:74)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:585)
        at com.sun.faces.el.MethodBindingImpl.invoke(MethodBindingImpl.java:126)
        ... 22 more
Caused by: javax.persistence.RollbackException: Exception [TOPLINK-45] (Oracle TopLink Essentials - 2.0 (Build b41-beta2 (03/30/2007))): oracle.toplink.essentials.exceptions.DescriptorException
Exception Description: Missing mapping for field [Vendor_Account.property_Id].
Descriptor: RelationalDescriptor(com.sandboxcomputing.propertymgmt.model.entity.VendorAccount --> [DatabaseTable(Vendor_Account)])
        at oracle.toplink.essentials.internal.ejb.cmp3.transaction.base.EntityTransactionImpl.commit(EntityTransactionImpl.java:105)
        at oracle.toplink.essentials.internal.ejb.cmp3.transaction.EntityTransactionImpl.commit(EntityTransactionImpl.java:45)
        at org.springframework.orm.jpa.JpaTransactionManager.doCommit(JpaTransactionManager.java:433)
        ... 35 more
Caused by: Exception [TOPLINK-45] (Oracle TopLink Essentials - 2.0 (Build b41-beta2 (03/30/2007))): oracle.toplink.essentials.exceptions.DescriptorException
Exception Description: Missing mapping for field [Vendor_Account.property_Id].
Descriptor: RelationalDescriptor(com.sandboxcomputing.propertymgmt.model.entity.VendorAccount --> [DatabaseTable(Vendor_Account)])
        at oracle.toplink.essentials.exceptions.DescriptorException.missingMappingForField(DescriptorException.java:886)
        at oracle.toplink.essentials.internal.descriptors.ObjectBuilder.extractValueFromObjectForField(ObjectBuilder.java:1597)
        at oracle.toplink.essentials.mappings.OneToOneMapping.writeFromObjectIntoRow(OneToOneMapping.java:1076)
        at oracle.toplink.essentials.internal.descriptors.ObjectBuilder.buildRow(ObjectBuilder.java:732)
        at oracle.toplink.essentials.internal.descriptors.ObjectBuilder.buildRow(ObjectBuilder.java:720)
        at oracle.toplink.essentials.internal.queryframework.DatabaseQueryMechanism.insertObjectForWrite(DatabaseQueryMechanism.java:425)
        at oracle.toplink.essentials.queryframework.InsertObjectQuery.executeCommit(InsertObjectQuery.java:74)
        at oracle.toplink.essentials.internal.queryframework.DatabaseQueryMechanism.performUserDefinedWrite(DatabaseQueryMechanism.java:635)
        at oracle.toplink.essentials.internal.queryframework.DatabaseQueryMechanism.performUserDefinedInsert(DatabaseQueryMechanism.java:599)
        at oracle.toplink.essentials.internal.queryframework.DatabaseQueryMechanism.insertObjectForWriteWithChangeSet(DatabaseQueryMechanism.java:495)
        at oracle.toplink.essentials.queryframework.WriteObjectQuery.executeCommitWithChangeSet(WriteObjectQuery.java:130)
        at oracle.toplink.essentials.internal.queryframework.DatabaseQueryMechanism.executeWriteWithChangeSet(DatabaseQueryMechanism.java:283)
        at oracle.toplink.essentials.queryframework.WriteObjectQuery.executeDatabaseQuery(WriteObjectQuery.java:67)
        at oracle.toplink.essentials.queryframework.DatabaseQuery.execute(DatabaseQuery.java:609)
        at oracle.toplink.essentials.queryframework.DatabaseQuery.executeInUnitOfWork(DatabaseQuery.java:536)
        at oracle.toplink.essentials.queryframework.ObjectLevelModifyQuery.executeInUnitOfWorkObjectLevelModifyQuery(ObjectLevelModifyQuery.java:123)
        at oracle.toplink.essentials.queryframework.ObjectLevelModifyQuery.executeInUnitOfWork(ObjectLevelModifyQuery.java:95)
        at oracle.toplink.essentials.internal.sessions.UnitOfWorkImpl.internalExecuteQuery(UnitOfWorkImpl.java:2219)
        at oracle.toplink.essentials.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:937)
        at oracle.toplink.essentials.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:894)
        at oracle.toplink.essentials.internal.sessions.CommitManager.commitNewObjectsForClassWithChangeSet(CommitManager.java:254)
        at oracle.toplink.essentials.internal.sessions.CommitManager.commitAllObjectsWithChangeSet(CommitManager.java:175)
        at oracle.toplink.essentials.internal.sessions.AbstractSession.writeAllObjectsWithChangeSet(AbstractSession.java:2638)
        at oracle.toplink.essentials.internal.sessions.UnitOfWorkImpl.commitToDatabase(UnitOfWorkImpl.java:1030)
        at oracle.toplink.essentials.internal.ejb.cmp3.base.RepeatableWriteUnitOfWork.commitToDatabase(RepeatableWriteUnitOfWork.java:387)
        at oracle.toplink.essentials.internal.sessions.UnitOfWorkImpl.commitToDatabaseWithChangeSet(UnitOfWorkImpl.java:1112)
        at oracle.toplink.essentials.internal.ejb.cmp3.base.RepeatableWriteUnitOfWork.commitRootUnitOfWork(RepeatableWriteUnitOfWork.java:91)
        at oracle.toplink.essentials.internal.sessions.UnitOfWorkImpl.commitAndResume(UnitOfWorkImpl.java:842)
        at oracle.toplink.essentials.internal.ejb.cmp3.transaction.base.EntityTransactionImpl.commit(EntityTransactionImpl.java:87)
        ... 37 more

************************************************

@Entity
@Table(name="Property_Transaction")
public class PropertyTransaction implements Serializable
{
        @Id
        @GeneratedValue(strategy=GenerationType.IDENTITY)
        private int id;

        @ManyToOne
        @JoinColumns({
                @JoinColumn(name="property_Id", referencedColumnName="property_Id"),
                @JoinColumn(name="vendor_Id", referencedColumnName="vendor_Id"),
                @JoinColumn(name="vendor_Account_Num", referencedColumnName="account_Num")
        })
        private VendorAccount vendorAccount;

........


@Entity
@Table(name="Vendor_Account")
public class VendorAccount implements Serializable
{
        @EmbeddedId
        private VendorAccount.PK pk;

        //This is the relationship, so therefore this propertyId is not the one that needs to be modified(insert/update) when the object is persisted.
        @ManyToOne
        @JoinColumn(name="property_Id", insertable=false, updatable=false)
        private Property propertyId;

        //This is the relationship, so therefore this vendorId is not the one that needs to be modified(insert/update) when the object is persisted.
        @ManyToOne
        @JoinColumn(name="vendor_Id", insertable=false, updatable=false)
        private Vendor vendorId;

.... with embededId Pk
        @Embeddable
        public static class PK implements Serializable
        {
                @Column(name="property_id")
                private int propertyId;
                
                @Column(name="vendor_id")
                private int vendorId;
                
                @Column(name="account_Num")
                private String accountNum;
                private static final long serialVersionUID = 1L;

.......

@Entity
public class Property implements Serializable
{
        @Id
        @GeneratedValue(strategy=GenerationType.IDENTITY)
        private int id;

        @ManyToOne
        @JoinColumn(name="owner_Id")
        private Contact ownerId;

        @ManyToOne
        @JoinColumn(name="agent_Id")
        private Contact agentId;

Thanks in advance,
Benny
[Message sent by forum member 'blackrose12' (blackrose12)]

http://forums.java.net/jive/thread.jspa?messageID=232789