Hi,
When using OJB, is it possible in a 1:1 relationship to have the primary and
foreign keys the same? For example, I have a MEMBERS table and a
MEMBER_BANK_DETAILS table. The primary key in both is MEMBER_CAE_NUMBER. I
explicitly set this value in both member objects and add a reference to the
bank details object in the member object. When I try to store the member
object I get the error below. The relevent mappings are also shown.
Thanks,
John
<!-- MemberModel -->
<class-descriptor class="ie.mcps.member.model.MemberModel" table="members">
<field-descriptor name="CAENumber"
column="MEMBER_CAE_NUMBER"
jdbc-type="VARCHAR"
primarykey="true"/>
<field-descriptor name="name" column="MEMBER_NAME"
jdbc-type="VARCHAR"/>
.
.
<reference-descriptor name="bankDetails"
class-ref="ie.mcps.member.model.BankDetailsModel"
auto-update="true" auto-delete="true">
<foreignkey field-ref="CAENumber"/>
</reference-descriptor>
</class-descriptor>
<!-- BankDetailsModel -->
<class-descriptor class="ie.mcps.member.model.BankDetailsModel"
table="member_bank_details">
<field-descriptor name="memberCAENumber"
column="MEMBER_CAE_NUMBER"
jdbc-type="VARCHAR"
primarykey="true"/>
<field-descriptor name="bankName" column="BANK_NAME"
jdbc-type="VARCHAR"/>
.
.
<reference-descriptor name="member"
class-ref="ie.mcps.member.model.MemberModel">
<foreignkey field-ref="memberCAENumber"/>
</reference-descriptor>
</class-descriptor>
java.sql.SQLException: ORA-01400: cannot insert NULL into
("MCPS_TEST"."MEMBERS"."MEMBER_CAE_NUMBER")
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:169)
at oracle.jdbc.ttc7.TTIoer.processError(TTIoer.java:208) at
oracle.jdbc.ttc7.Oall7.receive(Oall7.java:543) at
oracle.jdbc.ttc7.TTC7Protocol.doOall7(TTC7Protocol.java:1405)[org.apache.ojb
.broker.accesslayer.JdbcAccessImpl] ERROR: SQLException during the execution
of the insert (for a ie.mcps.member.model.MemberModel): ORA-01400: cannot
insert NULL into ("MCPS_TEST"."MEMBERS"."MEMBER_CAE_NUMBER")
ORA-01400: cannot insert NULL into
("MCPS_TEST"."MEMBERS"."MEMBER_CAE_NUMBER")
at
oracle.jdbc.ttc7.TTC7Protocol.parseExecuteFetch(TTC7Protocol.java:822) at
oracle.jdbc.driver.OracleStatement.executeNonQuery(OracleStatement.java:1602
) at
oracle.jdbc.driver.OracleStatement.doExecuteOther(OracleStatement.java:1527)
at
oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java
:2045) at
oracle.jdbc.driver.OraclePreparedStatement.executeUpdate(OraclePreparedState
ment.java:395) at
com.p6spy.engine.logging.P6LogPreparedStatement.executeUpdate(P6LogPreparedS
tatement.java:182) at
org.apache.ojb.broker.accesslayer.JdbcAccessImpl.executeInsert(JdbcAccessImp
l.java:199) at
org.apache.ojb.broker.singlevm.PersistenceBrokerImpl.storeToDb(PersistenceBr
okerImpl.java:1742) at
org.apache.ojb.broker.singlevm.PersistenceBrokerImpl.store(PersistenceBroker
Impl.java:1683) at
org.apache.ojb.broker.singlevm.PersistenceBrokerImpl.store(PersistenceBroker
Impl.java:632) at
org.apache.ojb.broker.singlevm.DelegatingPersistenceBroker.store(DelegatingP
ersistenceBroker.java:151) at
ie.mcps.member.dao.MemberDAO.addMember(MemberDAO.java:54) at
ie.mcps.member.dao.TestMemberDAO.testAddMember(TestMemberDAO.java:197) at
java.lang.reflect.Method.invoke(Native Method) at
junit.framework.TestCase.runTest(TestCase.java:166) at
junit.framework.TestCase.runBare(TestCase.java:140) at
junit.framework.TestResult$1.protect(TestResult.java:106) at
junit.framework.TestResult.runProtected(TestResult.java:124) at
junit.framework.TestResult.run(TestResult.java:109) at
junit.framework.TestCase.run(TestCase.java:131) at
junit.framework.TestSuite.runTest(TestSuite.java:173) at
junit.framework.TestSuite.run(TestSuite.java:168) at
com.borland.jbuilder.unittest.JBTestRunner.run(JBTestRunner.java:161) at
com.borland.jbuilder.unittest.JBTestRunner.initiateTest(JBTestRunner.java:19
4) at
com.borland.jbuilder.unittest.JBTestRunner.main(JBTestRunner.java:486) 516
[main] FATAL ie.mcps.member.dao.MemberDAO - Exception thrown while adding
Member. Message: ORA-01400: cannot insert NULL into
("MCPS_TEST"."MEMBERS"."MEMBER_CAE_NUMBER")
-----Original Message-----
From: Joerg Lensing [mailto:[EMAIL PROTECTED]
Sent: 28 February 2003 11:43
To: OJB Users List
Subject: ODMG vs broker
hi experts,
i studied the junit-test to learn about mapping and querying. Although
the documention says, the mapping can be used to both (ODMG(OQL-Queries)
and PersistenceBroker)
it seems to me, that there are differences. (e.g.
org.apache.ojb.odmg.Article vs. org.apache.ojb.broker.Article) . Is
there a general rule?
thanx
joerg
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
************************************************************************
This e-mail and any files transmitted with it are confidential and may be
privileged and are intended solely for the individual named/ for the use of
the individual or entity to whom they are addressed.If you are not the
intended addressee, you should not disseminate, distribute or copy this
e-mail.Please notify the sender immediately if you have received this e-mail
by mistake and delete this e-mail from your system.If you are not the
intended recipient, you are notified that reviewing, disclosing, copying,
distributing or taking any action in reliance on the contents of this e-mail
is strictly prohibited.Please note that any views or opinions expressed in
this e-mail are solely those of the author and do not necessarily represent
those of Traventec Limited.E-mail transmission cannot be guaranteed to be
secure or error-free as information could be intercepted, corrupted, lost,
destroyed, or arrive late or incomplete.Traventec Limited therefore does not
accept liability for any errors or omissions in the contents of this
message, which arise as a result of e-mail transmission.The recipient should
check this e-mail and any attachments for the presence of viruses.This
e-mail has been swept for computer viruses however Traventec Limited accepts
no liability for any damage caused by any virus transmitted by this e-mail.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]