Hello,

I would be very grateful if anyone could explain to me why the following code complains about the "LockConflict"?
I make only one query in Exclusive mode, so why the QueryResults tries to lock the object again and causes LockConflict?


It's not a productive code, I simplified my code as it was possible. In a real code I want to query for objects in Exclusive and ReadOnly modes.

public void manual()
{
JDO jdo = null;
Database db = null;
QueryResults result = null;
try {
jdo = new JDO();
jdo.setDatabaseName( "grms-devel_jobreg" );
jdo.setConfiguration( "./etc/jobreg_database.xml" );
db = jdo.getDatabase();
db.begin();
OQLQuery query = db.getOQLQuery("select job from grms.jobreg.JobInfo job where job.id=$1");
query.bind("JOB_ID0");
result = query.execute( Database.Exclusive);
JobInfo job = null;
if( result.hasMore())
job = (JobInfo)result.next();


//some updates
System.out.println( "JOB_NAME = " + job.jobId);
db.commit();
db.close();
} catch ( Exception e) {
e.printStackTrace();
}
}


The executions finishes with following exception:

org.exolab.castor.jdo.PersistenceException: Lock conflict: attempt to load object of type grms.jobreg.JobInfo with identity 1 in two different locks modes (exclusive and non exclusive) in the same transaction
at org.exolab.castor.persist.TransactionContext.load(TransactionContext.java:627)
at org.exolab.castor.persist.TransactionContext.load(TransactionContext.java:555)
at org.exolab.castor.persist.ClassMolder.load(ClassMolder.java:764)
at org.exolab.castor.persist.LockEngine.load(LockEngine.java:356)
at org.exolab.castor.persist.TransactionContext.load(TransactionContext.java:649)
at org.exolab.castor.persist.TransactionContext.load(TransactionContext.java:555)
at org.exolab.castor.persist.ClassMolder.load(ClassMolder.java:793)
at org.exolab.castor.persist.LockEngine.load(LockEngine.java:356)
at org.exolab.castor.persist.TransactionContext.load(TransactionContext.java:649)
at org.exolab.castor.persist.QueryResults.fetch(QueryResults.java:229)
at org.exolab.castor.jdo.engine.OQLQueryImpl$OQLEnumeration.hasMore(OQLQueryImpl.java:627)
at org.exolab.castor.jdo.engine.OQLQueryImpl$OQLEnumeration.hasMore(OQLQueryImpl.java:610)
at grms.tests.jobreg.RepositoryThreads.manual(RepositoryThreads.java:198)
at grms.tests.jobreg.RepositoryThreads.main(RepositoryThreads.java:212)


and the mapping file more less is:

<?xml version="1.0" encoding="UTF-8"?>

<mapping>
   <description>Castor generated mapping file</description>

   <class name="grms.jobreg.JobInfo" identity="dbId" key-generator="MAX">
   <description>Default mapping for class grms.jobreg.JobInfo</description>
   <map-to xml="job-info" table="grms_repository_job"/>
       <field name="dbId" type="int">
       <bind-xml name="db-id" node="attribute"/>
       <sql name="job_rep_job_id" type="integer"/>
       </field>


<field name="id" type="java.lang.String"> <bind-xml name="id" node="element"/> <sql name="job_id" type="char"/> </field>

<field name="fileDirs" type="grms.jobreg.InOutFileDir" collection="array">
<bind-xml name="out-files" node="element"/>
<sql many-key="job_rep_job_id"/>
</field>


<field name="jobHistory" type="grms.jobreg.JobHistory" collection="array">
<bind-xml name="job-history" node="element"/>
<sql many-key="job_rep_job_id"/>
</field>


<field name="jobNotifications" type="grms.jobreg.JobNotification" collection="array">
<bind-xml name="job-notifications" node="element"/>
<sql many-key="job_rep_job_id"/>
</field>
</class>


<class name="grms.jobreg.JobHistory" identity="dbId" key-generator="MAX" depends="grms.jobreg.JobInfo">
<description>Default mapping for class grms.jobreg.JobHistory</description>
<map-to xml="job-history" table="grms_repository_history"/>
<field name="dbId" type="integer">
<bind-xml name="db-id" node="attribute"/>
<sql name="job_rep_history_id" type="integer"/>
</field>


           <field name="homeDirectory" type="java.lang.String">
       <bind-xml name="home-directory" node="element"/>
       <sql name="home_directory" type="char"/>
       </field>

       <field name="jobInfo" type="grms.jobreg.JobInfo">
       <bind-xml name="job-info" node="attribute"/>
       <sql name="job_rep_job_id"/>
       </field>

   </class>


<class name="grms.jobreg.InOutFileDir" identity="dbId" key-generator="MAX" depends="grms.jobreg.JobInfo">
<description>Default mapping for class InOutFile</description>
<map-to table="grms_repository_filedir"/>


           <field name="dbId" type="integer" direct="true">
       <bind-xml name="db-id" node="attribute"/>
               <sql name="job_rep_filedir_id" type="integer"/>
           </field>

           <field name="jobInfo" type="grms.jobreg.JobInfo" direct="true">
               <bind-xml reference="true" node="attribute"/>
               <sql name="job_rep_job_id"/>
           </field>
   </class>


<class name="grms.jobreg.JobNotification" identity="dbId" key-generator="MAX" depends="grms.jobreg.JobInfo">
<description>Default mapping for class grms.jobreg.JobNotification</description>
<map-to table="grms_repository_notif"/>
<field name="dbId" type="integer">
<bind-xml name="db-id" node="attribute"/>
<sql name="job_rep_notif_id" type="integer"/>
</field>


<field name="jobNotificationUsers" type="grms.jobreg.JobNotificationUser" collection="array">
<bind-xml name="job-notification-users" node="element"/>
<sql many-key="job_rep_notif_id"/>
</field>


       <field name="JobInfo" type="grms.jobreg.JobInfo">
               <bind-xml reference="true" node="attribute"/>
       <sql name="job_rep_job_id"/>
           </field>
  </class>

<class name="grms.jobreg.JobNotificationUser" identity="dbId" key-generator="MAX" depends="grms.jobreg.JobNotification">
<description>Default mapping for class grms.jobreg.JobNotificationUser</description>
<map-to table="grms_repository_notif_dn"/>
<field name="dbId" type="int">
<bind-xml name="db-id" node="attribute"/>
<sql name="job_rep_notif_dn_id" type="integer"/>
</field>


       <field name="JobNotification" type="grms.jobreg.JobNotification">
               <bind-xml reference="true" node="attribute"/>
       <sql name="job_rep_notif_id"/>
           </field>

  </class>
</mapping>

I will be very grateful for any hints how to solve the problem and for information what is the casue of it.

All the best,
Tomasz



----------------------------------------------------------- If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
unsubscribe castor-user

Reply via email to