[jboss-user] [EJB 3.0] - Re: RC6-PFD broke mappedBy and GenericGenerator workaround?
ldebetaz
do-not-reply at jboss.com
Thu Sep 14 12:17:53 EDT 2006
Is there a fix or workaround for the "unknown mappedBy" problem? No matter what I try I get this error. I have a Party (parent) and a Person (child) that I want to have the same primary key. The Party needs to control the creation of the primary key value and I want Person to use the same value. I've tried without the GenericGenerator - just trying to get the code to deploy without even worrying yet about setting the primary key correctly - and with the GenericGenerator but with no luck.
The code for Party:
| @Entity
| public class Party implements Serializable {
|
| @Id
| @GeneratedValue(strategy=javax.persistence.GenerationType.AUTO)
| public Long getId() {
| return id;
| }
|
| @OneToOne(optional=true, fetch=javax.persistence.FetchType.LAZY, mappedBy="party", cascade=javax.persistence.CascadeType.ALL)
| public Person getPerson() {
| return person;
| }
|
|
Code for Person
| @Entity
| public class Person implements Serializable {
| @Id
| @GeneratedValue(generator="foreign")
| @GenericGenerator(name="foreign",strategy="foreign",
| parameters={@Parameter(name="property",value="party")})
| public Long getId() {
| return id;
|
| @OneToOne(fetch=javax.persistence.FetchType.EAGER,cascade=javax.persistence.CascadeType.ALL)
| @PrimaryKeyJoinColumn
| public Party getParty() {
| return party;
| }
|
And I get this error
| DEBUG 14-09 10:57:50,671 (PropertyBinder.java:make:122) -Building property person
| DEBUG 14-09 10:57:50,671 (PropertyBinder.java:make:157) -Cascading person with all
| ERROR 14-09 10:57:50,687 (AbstractController.java:incrementState:350) -Error installing to Start: name=persistence.units:jar=classes.jar,unitName=try_talyor_prj state=Create
| org.hibernate.AnnotationException: Unknown mappedBy in: com.ndo.healthcare.entities.Party.person, referenced property unknown: com.ndo.healthcare.entities.Person.party
| at org.hibernate.cfg.OneToOneSecondPass.doSecondPass(OneToOneSecondPass.java:127)
| at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1049)
| at org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(AnnotationConfiguration.java:302)
| at org.hibernate.cfg.Configuration.buildMappings(Configuration.java:1034)
| at org.hibernate.ejb.Ejb3Configuration.buildMappings(Ejb3Configuration.java:1015)
| at org.hibernate.ejb.EventListenerConfigurator.configure(EventListenerConfigurator.java:154)
| at org.hibernate.ejb.Ejb3Configuration.createEntityManagerFactory(Ejb3Configuration.java:751)
| at org.hibernate.ejb.Ejb3Configuration.createContainerEntityManagerFactory(Ejb3Configuration.java:350)
| at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:119)
| at org.jboss.ejb3.entity.PersistenceUnitDeployment.start(PersistenceUnitDeployment.java:264)
| at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
| at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
| at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
| at java.lang.reflect.Method.invoke(Unknown Source)
| at org.jboss.reflect.plugins.introspection.ReflectionUtils.invoke(ReflectionUtils.java:55)
| at org.jboss.reflect.plugins.introspection.ReflectMethodInfoImpl.invoke(ReflectMethodInfoImpl.java:107)
| at org.jboss.joinpoint.plugins.BasicMethodJoinPoint.dispatch(BasicMethodJoinPoint.java:66)
| at org.jboss.kernel.plugins.dependency.KernelControllerContextActions.dispatchJoinPoint(KernelControllerContextActions.java:100)
| at org.jboss.kernel.plugins.dependency.KernelControllerContextActions$LifecycleAction.installAction(KernelControllerContextActions.java:582)
| at org.jboss.kernel.plugins.dependency.KernelControllerContextActions$KernelControllerContextAction.install(KernelControllerContextActions.java:175)
| at org.jboss.dependency.plugins.AbstractControllerContextActions.install(AbstractControllerContextActions.java:51)
| at org.jboss.dependency.plugins.AbstractControllerContext.install(AbstractControllerContext.java:226)
| at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:593)
| at org.jboss.dependency.plugins.AbstractController.incrementState(AbstractController.java:346)
| at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:438)
| at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:379)
| at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:225)
| at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:151)
| at org.jboss.kernel.plugins.dependency.AbstractKernelController.install(AbstractKernelController.java:79)
| at org.jboss.kernel.plugins.dependency.AbstractKernelController.install(AbstractKernelController.java:73)
| at org.jboss.ejb3.MCKernelAbstraction.install(MCKernelAbstraction.java:91)
| at org.jboss.ejb3.Ejb3Deployment.startPersistenceUnits(Ejb3Deployment.java:626)
| at org.jboss.ejb3.Ejb3Deployment.start(Ejb3Deployment.java:475)
| at org.jboss.ejb3.embedded.EJB3StandaloneDeployer.start(EJB3StandaloneDeployer.java:460)
| at org.jboss.ejb3.embedded.EJB3StandaloneBootstrap.scanClasspath(EJB3StandaloneBootstrap.java:291)
| at net.taylor.jboss.EJB3Container.startupEmbeddedJboss(EJB3Container.java:63)
| at net.taylor.jboss.EJB3Container.setUp(EJB3Container.java:31)
| at junit.extensions.TestSetup$1.protect(TestSetup.java:18)
| at junit.framework.TestResult.runProtected(TestResult.java:124)
| at junit.extensions.TestSetup.run(TestSetup.java:23)
| at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:128)
| at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
| at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
| at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
| at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
| at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
|
|
Am I modeling this wrong? Any help would be greatly appreciated.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3971608#3971608
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3971608
More information about the jboss-user
mailing list