I have two entities that I'm trying to associate using one to one. Below is
the code snippet for each:
In Relationship.java (an Entity)
| private TascForce tascForce;
|
| @OneToOne(cascade=Cascade.ALL, fetch=FetchType.EAGER)
| @JoinColumn(name="fk_tasc_tascforce")
| public TascForce getTascForce()
| {
| return(this.tascForce);
| }
|
| public void setTascForce(TascForce tascForce)
| {
| this.tascForce = tascForce;
| }
|
In TascForce.java (an Entity):
| private Relationship relationship;
|
| @OneToOne(mappedBy="tascForce", fetch=FetchType.EAGER)
| public Relationship getRelationship()
| {
| return(this.relationship);
| }
|
| public void setRelationship(Relationship relationship)
| {
| this.relationship = relationship;
| }
|
Database schemas (in MySQL 5.0):
| CREATE TABLE tasc_relationship (
| internalKey BIGINT AUTO_INCREMENT NOT NULL PRIMARY KEY,
| created DATETIME,
| createdBy BINARY(15),
| lastUpdated DATETIME,
| lastUpdatedBy BINARY(15),
| version BIGINT,
| relationshipId BINARY(15),
| loginId VARCHAR(150),
| pin BINARY(6),
| authenticationType ENUM('NATIVE', 'ACTIVE_DIRECTORY'),
| lockedOut TINYINT(1),
| fk_tasc_tascforce BIGINT
| ) TYPE = Innodb;
|
| CREATE TABLE tasc_tascforce (
| internalKey BIGINT AUTO_INCREMENT NOT NULL PRIMARY KEY,
| created DATETIME,
| createdBy BINARY(15),
| lastUpdated DATETIME,
| lastUpdatedBy BINARY(15),
| version BIGINT,
| address1 VARCHAR(100),
| address2 VARCHAR(100),
| city VARCHAR(40),
| state CHAR(2),
| deliveryArea CHAR(5),
| plusFour CHAR(4),
| fk_tasc_contact BIGINT
| ) TYPE = InnoDB;
|
I can successfully create a TascForce instance and search for a TascForce
instance (i.e. no EJB errors and the database records look good), but when I
attempt a EntityManager.merge on the TascForce object I get the following error:
| 09:10:25,868 INFO [LongType] could not bind value '[EMAIL
PROTECTED]@1c02db5[internalKey=1,created=2005-12-14 08:47:02.0,[EMAIL
PROTECTED],lastUpdated=Wed Dec 14 09:10:25 CST 2005,[EMAIL
PROTECTED],version=1,[EMAIL
PROTECTED],firstName=Michael,middleName=],[EMAIL
PROTECTED],trunk=,number=,extension=],[EMAIL
PROTECTED],trunk=,number=,extension=],[EMAIL
PROTECTED],trunk=,number=,extension=],[EMAIL
PROTECTED],trunk=,number=,extension=],[EMAIL
PROTECTED]@tasconline.com]],address=]' to parameter: 1
| 09:10:26,054 WARN [JDBCExceptionReporter] SQL Error: 0, SQLState: S1009
| 09:10:26,054 ERROR [JDBCExceptionReporter] Statement parameter 1 not set.
| 09:10:26,056 ERROR [AjaxPhaseListener] AJAX request failed: null;
CausedByException is:
| could not load an entity: [EMAIL
PROTECTED]@1c02db5[internalKey=1,created=2005-12-14 08:47:02.0,[EMAIL
PROTECTED],lastUpdated=Wed Dec 14 09:10:25 CST 2005,[EMAIL
PROTECTED],version=1,[EMAIL
PROTECTED],firstName=Michael,middleName=],[EMAIL
PROTECTED],trunk=,number=,extension=],[EMAIL
PROTECTED],trunk=,number=,extension=],[EMAIL
PROTECTED],trunk=,number=,extension=],[EMAIL
PROTECTED],trunk=,number=,extension=],[EMAIL
PROTECTED]@tasconline.com]],address=]]
| javax.ejb.EJBException: null; CausedByException is:
| could not load an entity: [EMAIL
PROTECTED]@1c02db5[internalKey=1,created=2005-12-14 08:47:02.0,[EMAIL
PROTECTED],lastUpdated=Wed Dec 14 09:10:25 CST 2005,[EMAIL
PROTECTED],version=1,[EMAIL
PROTECTED],firstName=Michael,middleName=],[EMAIL
PROTECTED],trunk=,number=,extension=],[EMAIL
PROTECTED],trunk=,number=,extension=],[EMAIL
PROTECTED],trunk=,number=,extension=],[EMAIL
PROTECTED],trunk=,number=,extension=],[EMAIL
PROTECTED]@tasconline.com]],address=]]
| at
org.jboss.ejb3.tx.Ejb3TxPolicy.handleExceptionInOurTx(Ejb3TxPolicy.java:46)
| at org.jboss.aspects.tx.TxPolicy.invokeInOurTx(TxPolicy.java:70)
| at
org.jboss.aspects.tx.TxInterceptor$Required.invoke(TxInterceptor.java:134)
| at
org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)
| at
org.jboss.aspects.tx.TxPropagationInterceptor.invoke(TxPropagationInterceptor.java:61)
| at
org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)
| at
org.jboss.ejb3.stateless.StatelessInstanceInterceptor.invoke(StatelessInstanceInterceptor.java:39)
| at
org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)
| at
org.jboss.aspects.security.RoleBasedAuthorizationInterceptor.invoke(RoleBasedAuthorizationInterceptor.java:151)
| at
org.jboss.ejb3.security.RoleBasedAuthorizationInterceptor.invoke(RoleBasedAuthorizationInterceptor.java:85)
| at
org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)
| at
org.jboss.aspects.security.AuthenticationInterceptor.invoke(AuthenticationInterceptor.java:63)
| at
org.jboss.aop.joinpoint.MethodInvocation.invokeNext