[Persistence, JBoss/CMP, Hibernate, Database] - Having trouble with OneToOne with PrimaryKeyJoinColumn
by ldebetaz
When I try to model a bidirectional OneToOne mapping using PrimaryKeyJoinColumn I receive an "unknown mappedBy" error. When I try to model it as a unidirectional OneToOne mapping with PrimaryKeyJoinColumn I don't receive this error (there's no mappedBy so that's not a surprise) but there is no foreign key relationship created in the database.
I'm using the hibernate-all-alpha8.jar (at least that's the name of the jar picked up from taylor.sourceforge.net/maven2 with the jboss-ejb3-all-alpha8.jar) and embedded jboss.
I have a Party (parent) and Person (child) which share a primary key. The party table needs to control the creation of the primary key because not all Party records have a corresponding Person record but every Person is a Party.
Party code:
| @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;
| }
|
Person code
| @Entity
| public class Person implements Serializable {
| @Id
| public Long getId() {
| return id;
|
| @OneToOne(fetch=javax.persistence.FetchType.EAGER,cascade=javax.persistence.CascadeType.ALL)
| @PrimaryKeyJoinColumn
| public Party getParty() {
| return party;
| }
|
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: n
| ame=persistence.units:jar=classes.jar,unitName=try_talyor_prj state=Create
| org.hibernate.AnnotationException: Unknown mappedBy in: com.ndo.healthcare.entities.Party.person, re
| ferenced 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:3
| 50)
| 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(KernelContr
| ollerContextActions.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(AbstractControllerContextA
| ctions.java:51)
| at org.jboss.dependency.plugins.AbstractControllerContext.install(AbstractControllerContext.java:22
| 6)
| 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.ja
| va:79)
| at org.jboss.kernel.plugins.dependency.AbstractKernelController.install(AbstractKernelController.ja
| va: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:12
| 8)
| 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)
|
|
When I comment out the OneToOne annotation in Party, then there are no errors reported, but there is no foreign key created in the Person table to refer to the Party table. I'm assuming there should be.
So,
(1) Am I modeling something wrong in the bidirectional OneToOne case? I do realize that I need to either use a GenericGenerator in the Person class to get the primary key value in the Party table or explicitly set it, but this "unknown mappedBy" error is my concern.
(2) In the unidirectional OneToOne case, am I correct to assume that a foreign key relationship should be created?
Thanks for any help.
Lori Debetaz
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3972048#3972048
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3972048
19 years, 7 months
[Clustering/JBoss] - Re: Farm deployement problem
by bstansberry@jboss.com
Scott,
For 5.0 we're using a 640K receive buffer in the shared multiplexer channel. Our perf testing also uses that size receive buffer, and even in 4.0.x we'd like to make our default config more performant. So I don't have a big issue with the receive buffer.
For the send buffers, I do think the fc-fast-minimalthreads 25,000,000 is too big for cluster-service.xml, which shouldn't usually be pushing as much data as the tc5-cluster-service.xml channel. I'm thinking 2,000,000 is more reasonable.
What do you think?
(Oh, just realized this info isn't in the thread -- a couple weeks back we had a support case where transfer of large files (> 30MB) was failing midway. Increasing the buffers resolved the problem and greatly increased the speed.)
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3972045#3972045
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3972045
19 years, 7 months
[JNDI/Naming/Network] - Socket Exception: Broken Pipe thrown when starting JBoss 4.0
by krishnanr
I have an installation of JBoss 4.0.4 and all I am doing is trying to start the application server. I am running it in unix enviroment.
I dont have anything configured or added.
Looking at the server.log gives always gives me the following exception:
And this keeps repeating periodically.
Can someone shed some light as to the cause of this error.
Thanks in advance.
Here is an excerpt of the exception:
DEBUG [org.jboss.naming.NamingService] Error writing response to /X.Y.Z.A
java.net.SocketException: Broken pipe
at java.net.SocketOutputStream.socketWrite0(Native Method)
at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:92)
at java.net.SocketOutputStream.write(SocketOutputStream.java:136)
at java.io.ObjectOutputStream$BlockDataOutputStream.drain(ObjectOutputStream.java:1682)
at java.io.ObjectOutputStream$BlockDataOutputStream.setBlockDataMode(ObjectOutputStream.java:1591)
at java.io.ObjectOutputStream.writeNonProxyDesc(ObjectOutputStream.java:1173)
at java.io.ObjectOutputStream.writeClassDesc(ObjectOutputStream.java:1127)
at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1284)
at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1079)
at java.io.ObjectOutputStream.writeFatalException(ObjectOutputStream.java:1398)
at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:305)
at org.jnp.server.Main$BootstrapRequestHandler.run(Main.java:476)
at org.jboss.util.threadpool.RunnableTaskWrapper.run(RunnableTaskWrapper.java:148)
at EDU.oswego.cs.dl.util.concurrent.PooledExecutor$Worker.run(PooledExecutor.java:748)
at java.lang.Thread.run(Thread.java:595)
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3972042#3972042
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3972042
19 years, 7 months