Thanks, Keith. It is a great workaround for now, but I can't live without the key generation long-term....My DB admin will kill me ;-)
-- Jacek
At 05:12 PM 11/21/2001 +1300, Keith Chew wrote:
Can you do a quick change to disable key generation on Company?Jacek Kruszelnicki
I recall having this problem, but it is supposed to be fixed in CVS. However, I have already disabled key generation for my class.
Just try that. It's worth a go.
- -----Original Message-----
- From: Jacek Kruszelnicki [mailto:[EMAIL PROTECTED]]
- Sent: Wednesday, 21 November 2001 5:03 p.m.
- To: [EMAIL PROTECTED]
- Subject: Re: [castor-dev] Castor behaves differently within JBoss
- Referring object (Test) does not use key generation, but referred object (Company) does use SEQUENCE.
- -- Jacek
- At 04:37 PM 11/21/2001 +1300, you wrote:
- I have had similar problems. Quick question. Are you using the key generator for your referenced object?
- Keith C
- -----Original Message-----
- From: Jacek Kruszelnicki [mailto:[EMAIL PROTECTED]]
- Sent: Wednesday, 21 November 2001 4:29 p.m.
- To: [EMAIL PROTECTED]
- Subject: [castor-dev] Castor behaves differently within JBoss
- Hi,
- I have just established that Castor, if used within JBoss, will not persist references to other objects.
- The same code/mapping will work just fine stand-alone.
- For example if we have an object of class Test reference an object of type Company, that reference will not be saved to the DB table if run in JBoss.
- I suspect that I may have something misconfigured. However, dependencies (not references) are persisted correctly.
- What do I need to do here? Any JBoss-Castor exeperts?
- Oleg Nitz, are you there?
- Thanks in advance,
- -- Jacek
- Environment:
- JBoss 2.4.3, Oracle 8.7.1 All transactions are bean-managed, set to "RequiresNew"
- This DOES NOT SAVE the reference to Company (JBOSS Session Bean)
- This is a session bean (remote) method:
- public Test createTest(Company c)
- throws InvalidArgumentException, ReflexServerException, RemoteException
- {
- Company co = null;
- Test t = null;
- if (c == null)
- throw new InvalidArgumentException("Argument cannot be null");
- try {
- co = (Company) pm.findByPrimaryKey(test.Company.class, new Integer(30));
- t = new Test(70);
- t.setOwnerCompany(co);
- System.out.println("Co " + co);
- System.out.println("test " + t);
- pm.create(t);
- }
- catch (Exception ex) {
- if (ex instanceof InvalidArgumentException)
- throw new InvalidArgumentException(ex.getMessage());
- else {
- ex.printStackTrace();
- throw new ReflexServerException(ex.getMessage());
- }
- }
- return t;
- }
- This WORKS:
- public void test() {
- Company co = null;
- Test t = null;
- Database db;
- try {
- db = jdo.getDatabase();
- db.setAutoStore(true);
- db.begin();
- writer.println("Begin transaction");
- co = (Company) db.load(test.Company.class, new Integer(30));
- t = new Test(70);
- t.setOwnerCompany(co);
- System.out.println("Co " + co);
- System.out.println("test " + t);
- db.create(t);
- db.commit();
- }
- catch (Exception ex) {
- ex.printStackTrace();
- System.out.println("Exception " + ex);
- }
- }
- Mapping:
- <class name="test.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="tests" type="test.Test" collection="arraylist">
- <sql many-key="ownerCompanyID" />
- </field>
- </class>
- <class name="test.Test" identity="testID">
- <cache-type type="count-limited" capacity="200"/>
- <map-to table="Tests"/>
- <field name="testID" type="long">
- <sql name="testID" type="numeric"/>
- </field>
- <field name="ownerCompany" type="test.Company">
- <sql name="ownerCompanyID"/>
- </field>
- </class>
- Jacek Kruszelnicki
- Numatica Corporation
- E-mail: [EMAIL PROTECTED]
- Phone: (781) 756 8064
Numatica Corporation
E-mail: [EMAIL PROTECTED]
Phone: (781) 756 8064
Numatica Corporation
E-mail: [EMAIL PROTECTED]
Phone: (781) 756 8064