java -javaagent:$GLASSFISH_HOME/lib/toplink-essentials-agent.jar
-classpath $GLASSFISH_HOME/javadb/lib/derbyclient.jar:. Client f1 11
3a. Uni-directional (source code)
Account.java without OneToOne Mapping and Owner field,
[TopLink Fine]: 2006.08.14
06:46:21.613--ClientSession(26752749)
--Connection(2352593)--Thread(Thread[main,5,main])--
INSERT
INTO ACCOUNT (ID, BALANCE, DEPOSIT, WITHDRAW)
VALUES (?, ?, ?, ?)
bind => [12, 10.0, 0.0,
0.0]
[TopLink Fine]: 2006.08.14
06:46:21.702--ClientSession(26752749)
--Connection(2352593)--Thread(Thread[main,5,main])--
INSERT
INTO VIPOWNER (OWNERID, OWNERSSN, HASSAVEBOX,
ACCT_INFO) VALUES (?, ?,
?, ?)
bind => [f2, 111-11-1111,
true, 12]
test1@brahma%
3b. Bi-directional ? (source code)
Account.java with OneToOne Mapping and Owner field,
Client.java
o.setAccount(a); OK
a.setOwner(o); Failed since Owner is a mapped
superclass
and can't be the target of a persistent relationship.
The error message is not clear. (???)
[TopLink Fine]: 2006.08.14
07:07:00.288--ClientSession(28290629)--
Connection(18751079)--Thread(Thread[main,5,main])--
INSERT
INTO ACCOUNT (ID, DEPOSIT, WITHDRAW, BALANCE, OWNER)
VALUES (?, ?, ?,
?, ?)
bind => [12, 0.0, 0.0,
10.0, VIPOwner@15093f1]
[TopLink Warning]: 2006.08.14
07:07:00.363--UnitOfWork(14247437)
--Thread(Thread[main,5,main])--Exception
[TOPLINK-4002]
(Oracle TopLink Essentials - 2006.7 (Build 060731)):
oracle.toplink.essentials.exceptions.DatabaseException
Internal Exception: org.apache.derby.client.am.SqlException:
Invalid
data conversion: Parameter object type is invalid
for requested
conversion.Error Code: -99999
Call:INSERT INTO ACCOUNT (ID, DEPOSIT, WITHDRAW, BALANCE, OWNER)
VALUES
(?, ?, ?, ?, ?)
bind => [12, 0.0, 0.0,
10.0, VIPOwner@15093f1]
Query:InsertObjectQuery(Account@1f6226)
Exception in thread "main" javax.persistence.RollbackException:
Exception [TOPLINK-4002] (Oracle TopLink Essentials - 2006.7 (Build
060731)): oracle.toplink.essentials.exceptions.DatabaseException
Internal Exception: org.apache.derby.client.am.SqlException:
Invalid
data conversion: Parameter object type is invalid for requested
conversion.Error Code: -99999
Call:INSERT INTO ACCOUNT (ID, DEPOSIT, WITHDRAW, BALANCE,
OWNER) VALUES
(?, ?, ?, ?, ?)
bind => [12, 0.0, 0.0,
10.0, VIPOwner@15093f1]
Query:InsertObjectQuery(Account@1f6226)
3c. Bi-directional (source code)
Account.java with OneToOne Mapping and VIPOwner field,
Client.java
o.setAccount(a); OK
a.setOwner((VIPOwner) o); OK,
VIPOwner inherits OWNERID from superclass Owner field annotated with @Id.
VIPOwner inherits Foreign Key, FK_ACCT, to Account.
VIPOwner overrides Foreign Key to Account to ACCT_INFO using
AssociationOverride annotation.
Account has Id as a primary key in Account.
Entity VIPOwner references a
single instance of Entity Account.
Entity Account references a
single instance of Entity VIPOwner.
Entity VIPOwner is the
owner of the relationship.
[TopLink Fine]: 2006.08.15 10:42:31.152--ClientSession(3753023)--
Connection(18751079)--Thread(Thread[main,5,main])--
INSERT INTO VIPOWNER
(OWNERID,
OWNERSSN, HAS
SAVEBOX, ACCT_INFO) VALUES (?, ?, ?, ?)
bind => [f1,
111-11-1111, true, null]
[TopLink Fine]: 2006.08.15 10:42:31.219--ClientSession(3753023)--
Connection(18751079)--Thread(Thread[main,5,main])--
INSERT INTO ACCOUNT
(ID,
DEPOSIT, WITHDRAW,
BALANCE, OWNER_OWNERID) VALUES (?, ?, ?, ?, ?)
bind => [11, 0.0, 0.0,
10.0, f1]
[TopLink Fine]: 2006.08.15 10:42:31.290--ClientSession(3753023)--
Connection(18751079)--Thread(Thread[main,5,main])--
UPDATE VIPOWNER
SET ACCT_INFO = ?, HASSAVEBO
X = ?, OWNERSSN = ? WHERE (OWNERID = ?)
bind => [11, true,
111-11-1111, f1]
test1@brahma%