No, I am still stuck, I was actually thinking of getting the latest cvs version, but looks like it may not be necessary :-(.
However, your message gives me hope that this is something that used to work, and was just broken during one of the check-ins. My version is from Oct 20, I think.
Thomas? Can you help? Or could you tell me which Castor package/class to take a closer look at?
-- Jacek
At 10:26 AM 11/18/2001 -0800, Peter T. Brown wrote:
Did you guys every work out a solution?
I am having the exact same problem w/ a very recent CVS build. x->y->z all get created in the database but: y.zID = 0 instead of z.ID. I am not using JBOSS, have autoStore enabled, and it was working before I updated from CVS.
- -----Original Message-----
]- From: Jacek Kruszelnicki [mailto:
- Sent: Thursday, November 15, 2001 2:52 PM
- To: [EMAIL PROTECTED]
- Subject: Re: [castor-dev] Reference to an object not persisted
- Thomas,
- I am running Castor from within JBoss (2.4.3) and I have autostore set in the MBean config section
- (see below)
- The referenced object (MonitoringTool) already exists - I only need to look it up to point the Probe to it.
- It is the referring object (Probe) that I am trying to add to the BusinessUnit
- There is no exception, no lockup, nothing. Only the field in the database is not populated.
- <tx start>
- Company c = (Company) pm.findByPrimaryKey(...);
- BusinessUnit bunit = c.getBusinessUnit(bu.getCode());
- // create the new object (which will refer to a MOnitoringTool)
- Probe probe = new Probe(p);
- // Lookup the MonitoringTool object the new Probe will refer to
- MonitoringTool mt = (MonitoringTool) pm.findByPrimaryKey(...);
- // set the reference in memory, hopefully will be persisted
- probe.setMonitoringTool(mt);
- System.out.println("Assigned MT ID " + probe.getMonitoringTool().getMonitoringToolID());
- // Now the newly created probe to its parent
- bunit.addProbe(probe);
- return probe;
- <end of tx>
- <!-- ==================================================================== -->
- <!-- Add your custom MBeans here -->
- <!-- ==================================================================== -->
- <mbean code="org.jboss.jdo.castor.CastorJDOImpl" name="DefaultDomain:service=CastorJDO,name=castor">
- <attribute name="Configuration">file:../conf/default/database.xml</attribute>
- <attribute name="JndiName">CastorJDO</attribute>
- <attribute name="LockTimeout">100000</attribute>
- <attribute name="LoggingEnabled">true</attribute>
- <attribute name="CommonClassPath">false</attribute>
- <attribute name="AutoStore">true</attribute>
- </mbean>
- At 01:52 PM 11/15/2001 -0800, you wrote:
- Make sure you've enable db.setAutoStore()?
- Otherwise, only dependent object will be created automatically.
- Thomas
- -----Original Message-----
- >From: Jacek Kruszelnicki [mailto:[EMAIL PROTECTED]]
- >Sent: Thursday, November 15, 2001 11:42 AM
- >To: [EMAIL PROTECTED]
- >Subject: Re: [castor-dev] Reference to an object not persisted
- >
- >
- >Hi,
- >
- >No answer, so I will try again...
- >
- >My problem is that I when I create a new dependent object (Probe in the
- >example below) that has a reference to another
- >object (MonitoringTool), that reference does NOT get saved in the database
- >(I believe all pointers are set correctly in memory)
- >
- >Could anyone confirm that this is a bug? If it is, are there any
- >workarounds? Would it be easy to fix?
- >
- >I am sure other users must have come across a situation like that - I am
- >getting desperate.
- >
- >-- Jacek
- >
- >See below for more details.
- >
- >
- >
- >At 01:09 PM 11/14/2001 -0500, Jacek Kruszelnicki wrote:
- >>Hi,
- >>
- >>My object model is: Company has BusinessUnits. A BusinessUnit has Probes.
- >>I need to add a Probe to a BusinessUnit. A Probe must have a reference to
- >>a MonitoringTool.
- >>
- >> COMPANY
- >> |
- >> |
- >> depends
- >> |
- >> |
- >> BUSINESSUNIT
- >> |
- >> |
- >> depends
- >> |
- >> |
- >> PROBE ----- references -----> MONITORINGTOOL
- >>
- >>
- >>
- >>Here is the excerpt from the mapping file.
- >>
- >>
- >><class name="com.company.product.Company" identity="companyID"
- >> key-generator="SEQUENCE">
- >> <cache-type type="count-limited" capacity="200"/>
- >>
- >> <description>Company</description>
- >> <map-to table="Companies"/>
- >>
- >> <field name="companyID" type="integer">
- >> <sql name="companyID" type="numeric"/>
- >> </field>
- >>
- >> <field name="companyCode" type="string">
- >> <sql name="code" type="varchar"/>
- >> </field>
- >>
- >> [...]
- >>
- >> <field name="businessUnits"
- >> type="com.company.product.BusinessUnit" collection="arraylist">
- >> </field>
- >> </class>
- >>
- >>
- >>
- >> <class name="com.company.product.BusinessUnit"
- identity="businessUnitID"
- >> depends="com.company.product.Company"
- key-generator="SEQUENCE">
- >> <cache-type type="count-limited" capacity="200"/>
- >>
- >> <description>Business Unit</description>
- >> <map-to table="BusinessUnits"/>
- >>
- >> <field name="businessUnitID" type="integer">
- >> <sql name="businessUnitID" type="numeric"/>
- >> </field>
- >>
- >> <field name="company" type="com.company.product.Company"
- >> required="true">
- >> <sql name="companyID"/>
- >> </field>
- >>
- >> <field name="code" type="string">
- >> <sql name="code" type="varchar"/>
- >> </field>
- >>
- >> [...]
- >>
- >> <field name="probes" type="com.company.product.Probe"
- >> collection="arraylist">
- >> </field>
- >> </class>
- >>
- >>
- >> <class name="com.company.product.Probe" identity="probeID"
- >> depends="com.company.product.BusinessUnit"
- >> key-generator="SEQUENCE">
- >> <cache-type type="count-limited" capacity="200"/>
- >>
- >> <description>Probe</description>
- >> <map-to table="Probes"/>
- >>
- >> <field name="probeID" type="integer">
- >> <sql name="probeID" type="numeric"/>
- >> </field>
- >>
- >> <field name="businessUnit"
- >> type="com.company.product.BusinessUnit" required="true">
- >> <sql name="businessunitID"/>
- >> </field>
- >>
- >> [...]
- >>
- >> <field name="monitoringTool"
- >> type="com.company.product.MonitoringTool" check="ignore">
- >> <sql name="monitoringToolID"/>
- >> </field>
- >> </class>
- >>
- >>
- >> <class name="com.company.product.MonitoringTool"
- >> identity="monitoringToolID"
- >> key-generator="SEQUENCE">
- >> <cache-type type="count-limited" capacity="5"/>
- >>
- >> <description>Monitoring Tools</description>
- >> <map-to table="MonitoringTools"/>
- >>
- >> <field name="monitoringToolID" type="integer">
- >> <sql name="monitoringToolID" type="numeric"/>
- >> </field>
- >>
- >> <field name="description" type="string">
- >> <sql name="description" type="varchar"/>
- >> </field>
- >> </class>
- >>
- >>
- >>
- >>The following method is a SessionBean method (JBoss 2.4.3)
- >>
- >> public Probe addProbe(BusinessUnit bu, Probe p) throws ...
- >> {
- >> try {
- >>
- >> Company c = (Company)
- >> pm.findByPrimaryKey(com.company.product.Company.class, new
- >> Integer(bu.getCompany().getCompanyID()));
- >> BusinessUnit bunit = c.getBusinessUnit(bu.getCode());
- >>
- >> Probe probe = new Probe(p); // create server-side probe
- >>
- >> MonitoringTool mt = (MonitoringTool)
- >> pm.findByPrimaryKey(com.company.product.MonitoringTool.class,
- >> new
- >> Integer(p.getMonitoringTool().getMonitoringToolID()));
- >> System.out.println("MT found " + mt.getMonitoringToolID());
- >> probe.setMonitoringTool(mt);
- >> System.out.println("Assigned MT ID " +
- >> probe.getMonitoringTool().getMonitoringToolID());
- >>
- >> bunit.addProbe(probe);
- >> System.out.println("Probe added : " + probe);
- >> System.out.println("Whole BU " + bunit);
- >> return probe;
- >>
- >> }
- >> catch(...)
- >> }
- >>
- >>It seems that until the method returns (transactions are bean-managed,
- >>with tx ="Required"), everything is good :
- >>
- >>[Default] MT found 201
- >>[Default] Assigned MT ID 201
- >>[Default] Probe added : Probe 0 FDLT-PRB1 bU: FDLT-BUS1 MonitoringTool201
- >>[Default] Whole BU BU 286 has probes: 1
- >> Probe 0: Probe 0 FDLT-PRB1 bU: FDLT-BUS1 MonitoringTool
- >> 201 belongs to: FDLT
- >>
- >>What's more the object returned to the client contains the pointer to the
- >>right MonitoringTool.
- >>For some reason, the pointer to MonitoringTool does not get persisted.
- >>
- >>What am I missing?
- >>Any help is appreciated!
- >>
- >>
- >>-- Jacek
- >>
- >>
- >>
- >>Jacek Kruszelnicki
- >>Numatica Corporation
- >>E-mail: [EMAIL PROTECTED]
- >>Phone: (781) 756 8064
- >>
- >>----------------------------------------------------------- If you wish to
- >>unsubscribe from this mailing, send mail to
- >>[EMAIL PROTECTED] with a subject of:
- >> unsubscribe castor-dev
- >
- >Jacek Kruszelnicki
- >Numatica Corporation
- >E-mail: [EMAIL PROTECTED]
- >Phone: (781) 756 8064
- >
- >-----------------------------------------------------------
- >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 - Jacek Kruszelnicki
- Numatica Corporation
- E-mail: [EMAIL PROTECTED]
- Phone: (781) 756 8064
Numatica Corporation
E-mail: [EMAIL PROTECTED]
Phone: (781) 756 8064
