I'm sure this is an easy problem, can anyone offer suggestions? Thanks Steve
Hi
I'm using 1.0.rc6 and I must have something misconfigured. I'm loading a class Login which contains (has-a) instance of Contact. I retrieve the Login fine but the Contact is always null.
repository.xml
<!-- Definitions for Login -->
<class-descriptor class="org.apache.cocoon.ojb.samples.bean.Login" table="login">
<!-- actual data members of this class -->
<field-descriptor name="_login" column="login" jdbc-type="VARCHAR" primarykey="true"/>
<field-descriptor name="_password" column="password" jdbc-type="VARCHAR" nullable="false"/>
<!-- anonymous doesn't exist in class itself used as join to Contact table -->
<field-descriptor name="contactId" column="id"
jdbc-type="VARCHAR" nullable="true" access="anonymous"/>
<!-- implement the join with the Contact table -->
<reference-descriptor name="_contact"
class-ref="org.apache.cocoon.ojb.samples.bean.Contact">
<foreignkey field-ref="contactId"/>
</reference-descriptor>
</class-descriptor>
<class-descriptor class="org.apache.cocoon.ojb.samples.bean.Contact" table="contact">
<!-- id is join id with Login table -->
<field-descriptor name="_id" column="id"
jdbc-type="VARCHAR" nullable="false"
primarykey="true"/>
<field-descriptor name="_honorific" column="honorific"
jdbc-type="VARCHAR" nullable="true"/>
<field-descriptor name="_firstName" column="firstName"
jdbc-type="VARCHAR" nullable="false"/>
<field-descriptor name="_otherName" column="otherName"
jdbc-type="VARCHAR" nullable="true"/>
<field-descriptor name="_surname" column="surname"
jdbc-type="VARCHAR" nullable="false"/>
<field-descriptor name="_lineage" column="lineage"
jdbc-type="VARCHAR" nullable="true"/>
<field-descriptor name="_email" column="email"
jdbc-type="VARCHAR" nullable="false"/>
<field-descriptor name="_website" column="website"
jdbc-type="VARCHAR" nullable="true"/>
<field-descriptor name="_country" column="country"
jdbc-type="VARCHAR" nullable="true"/>
<field-descriptor name="_countrySubElement" column="countrySubElement"
jdbc-type="VARCHAR" nullable="true"/>
<field-descriptor name="_city" column="city"
jdbc-type="VARCHAR" nullable="true"/>
</class-descriptor>
I load the Login as follows:
// omitted code above
org.odmg.Transaction tx = impl.newTransaction();
try {
tx.begin();
// 2. get an OQLQuery object from the ODMG facade
OQLQuery query = impl.newOQLQuery();
// 3. set the OQL select statement
query.create("select one from " + Login.class.getName() +
" where login = $1 and password= $2");
// query using incoming bean login field value
query.bind(bean.getLogin());
query.bind(bean.getPassword());
try {
DList results = (DList) query.execute();
try {
// get the data if any
bean = (Login) results.iterator().next();
}
catch (IndexOutOfBoundsException ex) {
return false;
}
}
catch (QueryException ex) {
return false;
}
tx.commit();// more omitted code
With trace on it looks like it is finding both my Login instance and locking the Contact instance (with id=1) but I never see the select to load the Contact instance.
[org.apache.ojb.odmg.TransactionImpl] DEBUG: Begin transaction was called on tx [EMAIL PROTECTED], with associated PB null
[org.apache.ojb.odmg.oql.OQLQueryImpl] DEBUG: create query for query-string: select one from org.apache.cocoon.ojb.samples.bean.Login where login = $1 and password= $2
[org.apache.ojb.odmg.oql.OQLQueryImpl] DEBUG: Start execute query
[org.apache.ojb.broker.core.QueryReferenceBroker] DEBUG: getCollectionByQuery (class org.apache.ojb.odmg.collections.DListImpl_2, class org.apache.cocoon.ojb.samples.bean.Login, Query from class org.apache.cocoon.ojb.samples.bean.Login where [login = [EMAIL PROTECTED], [password = 123456]])
[org.apache.ojb.broker.accesslayer.sql.SqlQueryStatement$TableAlias] DEBUG: TableAlias(): using hints ? false
[org.apache.ojb.broker.accesslayer.sql.SqlQueryStatement$TableAlias] DEBUG: TableAlias(): using hints ? false
[org.apache.ojb.odmg.TransactionImpl] DEBUG: lock object was called on tx [EMAIL PROTECTED]
[org.apache.ojb.odmg.TransactionImpl] DEBUG: proceeding with lock on class: org.apache.cocoon.ojb.samples.bean.Login object [EMAIL PROTECTED]
[org.apache.ojb.odmg.locking.LockManagerDefaultImpl] DEBUG: LM.readLock(tx-127.0.0.1:988707:fdc9bbf600:-7fff, [EMAIL PROTECTED])
[org.apache.ojb.odmg.TransactionImpl] DEBUG: lock object was called on tx [EMAIL PROTECTED]
[org.apache.ojb.odmg.TransactionImpl] DEBUG: proceeding with lock on class: org.apache.cocoon.ojb.samples.bean.Contact object [EMAIL PROTECTED]
[org.apache.ojb.odmg.locking.LockManagerDefaultImpl] DEBUG: LM.readLock(tx-127.0.0.1:988707:fdc9bbf600:-7fff, org.apache.cocoon.ojb.samples.bean.Contact{1})
[org.apache.ojb.odmg.ObjectEnvelopeTable] DEBUG: register: org.apache.cocoon.ojb.samples.bean.Contact{1}(org.apache.ojb.odmg.states.StateOldClean)
[org.apache.ojb.odmg.ObjectEnvelopeTable] DEBUG: register: [EMAIL PROTECTED](org.apache.ojb.odmg.states.StateOldClean)
[org.apache.ojb.odmg.TransactionImpl] DEBUG: call beginTransaction() on PB instance
[org.apache.ojb.odmg.ObjectEnvelopeTable] DEBUG: PB is in internal tx: true broker was: [EMAIL PROTECTED]
[org.apache.ojb.odmg.TransactionImpl] DEBUG: Commit transaction [EMAIL PROTECTED], commit on broker [EMAIL PROTECTED]
[org.apache.ojb.odmg.locking.LockManagerDefaultImpl] DEBUG: LM.releaseLock(tx-127.0.0.1:988707:fdc9bbf600:-7fff, [EMAIL PROTECTED])
[org.apache.ojb.odmg.locking.LockManagerDefaultImpl] DEBUG: LM.releaseLock(tx-127.0.0.1:988707:fdc9bbf600:-7fff, org.apache.cocoon.ojb.samples.bean.Contact{1})
[org.apache.ojb.odmg.TransactionImpl] DEBUG: Close Transaction and release current PB [EMAIL PROTECTED] on tx [EMAIL PROTECTED]
Any help would be greatly appreciated. Thanks Steve
_________________________________________________________________
Planning a family vacation? Check out the MSN Family Travel guide! http://dollar.msn.com
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
