I've placed quite a few messages to this list in recent weeks and they rarely, if ever, get answered, I know I can't expect this list to be a substitute for support - but I believe at least most of my recent messages highly important/critical issues. This seems a real shame to me, since I believe Castor is a great product - with great potential. We're about to use it in what's probably the UK's largest ever web project in it's own industry sector, but I'm really concerned that the impression given is that really important issues are getting swept under the carpet. I realise the truth is probably far from that, and that the development team, like most dev. teams are probably working all hours to get things right. Sorry again to moan, but is anyone out there? Thanks again -----Original Message----- From: Tim Fox [mailto:[EMAIL PROTECTED]] Sent: 14 August 2001 17:29 To: [EMAIL PROTECTED] Subject: [castor-dev] Problem when using multiple database objects in an ejb server - transaction weirdness I'm using Castor (0.9.3) in an ejb container (JBoss). I am using container-managed-transactions, and have configured my database.xml to pick up the datasource from jndi. If I get multiple Database objects from the DataObjects object (supplied from JNDI) and perform updates on my business objects, then, when I commit, all updates are written successfully to the database, and if a EJBException occurs then all updates are rolled back (even though they were done on different Database objects), which is cool, and shows the db transactions are successfully being tied up to the transaction coordinator. For instance: public void foo() { //If an exception is thrown anyway in here - all updates are rolled back - //even though they are using different Database objects - this is ok DataObjects jdo = .... // get object from jndi Database db1 = jdo.getDatabase(); Foo a = (Foo)db1.load(Foo.class, "a"); a.setX(1); db1.close(); Database db2 = jdo.getDatabase(); Bar b = (Bar)db2.load(Bar.class, "b"); b.setY(1); db2.close(); } BUT!! If I load an object a using Database db1, and load another object b using Database db2, and then try and set an attribute of a with the value b, then, when attempting to commit the transaction, I get a SQLException as Castor attempts to set the attribute with NULL, rather than with the identity of b. An example should illustrate this better: public void foo() { DataObjects jdo = .... // get object from jndi Database db1 = jdo.getDatabase(); Foo a = (Foo)db1.load(Foo.class, "a"); db1.close(); Database db2 = jdo.getDatabase(); Bar b = (Bar)db2.load(Bar.class, "b"); b.setMyObjectAttribute(a); db2.close(); } All this works fine if I get the Databas object just once. Now, I can understand this should fail in a standalone Castor set-up, since the Database objects will be in different transactional contexts. But in an ejb environment, the call to getDatabase() should return the same connection according to the current thread. This appears not to be the case. A work-around is only to get one Database object per ejb method call, and pass it around to any helper methods, but it seems to me that this goes against the ejb paradigm of being to get a connection anywhere and knowing it's the same connection! Can anyway confirm, whether (this bit of) Castor was designed this way, or if it is a known bug. Thanks in advance and I look forward to hearing any replies Tim Fox Chief Technical Architect Blue Heath Direct Ltd. 132 Upper Street Islington London N1 1QP ----------------------------------------------------------- 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
