I did try moving db.update() after reading your last message but to no
avail.  I have noticed that in past messages, people have mentioned that
the Relationship mapping is not enforced in all cases.  Is this one of
those cases where it would be enforced?  Can you elaborate a little on
when it is and when it is not, enforced?

Also,  I have included a mapping for an Employee class that I am unable
to change any attribute for, even in one transaction.  I keep getting
the Concurrent Transaction Error.  I have tried commenting out all
relationships in the mapping and added dirty="ignore" , but still the
same error.  Colud this have something to do with the Database types and
java types not jiving?

SQL 2000 server

CODE:

db.setAutoStore(true);
db.begin();

OQLQuery oqlQuery4 = db.getOQLQuery("select p from Employee p where
employeeId = $1");
oqlQuery4.bind(59);
QueryResults results4 = oqlQuery4.execute();
Employee emp = (Employee)results4.next();
emp.setLogin("CASTOR");

db.commit();
db.close();

MAPPING:
        <class name="Employee"
                identity="employeeId" key-generator="IDENTITY"
cache-type="none">
                <cache-type type="count-limited" capacity="1000"/>
                <description>Employee Class</description>
                <map-to table="Employees" xml="employee"/>
                <field name="employeeId" type="integer">
                        <sql name="emp_id" type="integer"
dirty="ignore"/>
                </field>
                <field name="login" type="string">
                        <sql name="emp_login" type="char"
dirty="ignore"/>
                </field>
                <field name="password" type="string">
                        <sql name="emp_password" type="char"
dirty="ignore"/>
                </field>
                <field name="firstName" type="string">
                                <sql name="emp_first_name" type="char"
dirty="ignore"/>
                </field>
                <field name="lastName" type="string">
                        <sql name="emp_last_name" type="char"
dirty="ignore"/>
                </field>
                <field name="middleName" type="string">
                        <sql name="emp_middle_name" type="char"
dirty="ignore"/>
                </field>
                <!--
                <field name="employeeManagerId" type="integer">
                        <sql name="emp_manager" type="integer"
dirty="ignore"/>
                </field>
                -->
                <field name="email" type="string">
                        <sql name="emp_email" type="char"
dirty="ignore"/>
                </field>
                <field name="faxNumber" type="string">
                        <sql name="emp_fax" type="char" dirty="ignore"/>
                </field>
                <field name="mobilePhoneNumber" type="string">
                        <sql name="emp_mobile_phone" type="char"
dirty="ignore"/>
                </field>
                <field name="phoneNumber" type="string">
                        <sql name="emp_phone" type="char"
dirty="ignore"/>
                </field>
                <field name="employeeNote" type="string">
                        <sql name="emp_note" type="char"
dirty="ignore"/>
                </field>
                <field name="isActive" type="boolean">
                        <sql name="active" type="bit" dirty="ignore"/>
                </field>
                <field name="isPEApprover" type="boolean">
                        <sql name="emp_pe_approver" type="bit"
dirty="ignore"/>
                </field>
                <field name="version" type="date">
                        <sql name="version" type="date" dirty="ignore"/>
                </field>
                <field name="isManager" type="boolean">
                        <sql name="emp_ismanager" type="bit"
dirty="ignore"/>
                </field>
                <field name="employeeRole" type="EmployeeRole">
                        <sql name="emp_role_id" dirty="ignore"/>
                </field>
                <field name="employeeOffice" type="EmployeeOffice">
                        <sql name="emp_office_id" dirty="ignore"/>
                </field>
                <field name="employeeTitle" type="EmployeeTitle">
                        <sql name="emp_title_id" dirty="ignore"/>
                </field>
                <!--<field name="manager" type="Employee">
                        <sql name="emp_manager"/>
                </field>-->
                <field name="region" type="Region">
                        <sql name="emp_region_id" dirty="ignore"/>
                </field>
                <field name="securityRoles" type="SecurityRole"
                                collection="vector">
                        <sql many-table="employee_security"
many-key="employee_id" name="security_id" dirty="ignore" />
                </field>
        </class>

-----Original Message-----
From: Bruce Snyder [mailto:[EMAIL PROTECTED]] 
Sent: Tuesday, October 15, 2002 11:38 AM
To: [EMAIL PROTECTED]
Subject: Re: [castor-dev] Concurrent Transactions Error

This one time, at band camp, Steve Mayzak said:

SM>If at anytime we try to alter one of the child objects of an object,
SM>castor does not commit the changes to the database.  We receive no
SM>errors but no "updates" are done.  If we change any other attribute
of
SM>this object but do not call db.update() and do not modify any other
SM>child objects, the object will not be updated.  If we do call
db.update
SM>in the same scenario, the database does get updated.  If we change a
SM>child object and call db.update() we get the exception, as expected.
So
SM>my question is, why does castor not update the database when we
change a
SM>child objects reference?  Does having multiple primary keys effect
the
SM>way castor behaves in general?
SM>Do you see any problems with the mapping file below or have we done
SM>something out of order to cause this behavior?
SM>
SM>Mapping:
SM><class name="OpportunityEmployee" identity="oppId empId" >
SM>            <description>OpportunityEmployee class</description>
SM>            <cache-type type="none"/>
SM>            <map-to table="opportunity_employee"/>
SM>                        <field name="oppId" type="integer">
SM>                                   <sql name="opp_id" type="integer"
SM>dirty="check"/>
SM>                        </field>             
SM>                        <field name="emp" type="Employee">
SM>                                    <sql name="emp_id"/>
SM>                        </field> 
SM>                        <field name="version" type="date">
SM>                                   <sql name="version" type="date"
SM>dirty="ignore"/>
SM>                        </field>             
SM>                        
SM>                        <field name="role" type="EmployeeRole">
SM>                                    <sql name="emp_role_id"
SM>dirty="ignore"/>
SM>                        </field>             
SM>            </class>
SM> 
SM><class name="EmployeeRole"
SM>            identity="employeeRoleId" key-generator="IDENTITY">
SM>            <description>EmployeeRole Class</description>
SM>                        <cache-type type="none"/>
SM>            <map-to table="Employee_Roles" xml="employee_role"/>
SM>            <field name="employeeRoleId" type="integer">
SM>                       <sql name="emp_Role_id" type="integer"
SM>dirty="check"/>
SM>            </field>
SM>            <field name="roleDescription" type="string">
SM>                        <sql name="emp_Role" type="char"
SM>dirty="ignore"/>
SM>            </field>
SM>  </class>

You're using db.setAutoStore() so any reachable objects (i.e. child
objects)
should be persisted. In the code example in your last message, what
happens if
you just move the call to db.update() before the call to
oppEmp.setRole()? 

I notice that the relationship between OpportunityEmployee and
EmployeeRole is
not bi-directional. For more info on bi-directionality, please see: 

    http://www.castor.org/jdo-faq.html#Technical-questions

Look for the question, 'Does Castor support both one-way and two-way
relationships?'

I not sure if this would affect your situation, but it's worth a try. 

Bruce
-- 
perl -e 'print
unpack("u30","<0G)U8V4\@4VYY9&5R\"F9E<G)E=\$\!F<FEI+F-O;0\`\`");'

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

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

Reply via email to