1. If you get exception after update or create that: StringBufferIndexOutOfBound exception, it mean that you try save to foreign key field an empty string value ("", but not null, becose for null it work correct).
2. If you get DatabaseNotFound exception, then it mean that maybe you have wrong mapping.xml.
3. If you turn cache-type to type="none", and yours object implement interface Timestample you get Timestampmismatch exception on db.update (update for long transaction), becose Castor (save timestamp labels of object in cache, but turning off the cache make inposible saving timestamps in cache, and Castor try compare timestamp of updating object with expected timestamp (myabe it 0 - zero) and, naturaly, get Timestamp mismatch error). If you turn cache to off, you can't use db.update.
4. If you try create object, for example, Person, with one of fielda as empty string (or null), create was succeseful but, both - and empty string and null stored into database as NULLs. It means that if you want to update created object, but for some field you set empty (but NOT null) string you get exception - ObjectModifiedException. It becose, by default Castor use dirty checking, what means that all field in UPDATE also used in WHERE query, for example lets udate name of Person from A to B, and SURNAME leave at EMPTY string (person.setName(""); person.set.LastName("")):
SQL of create and update are:
First we make insert:
INSERT INTO PERSON (ID, NAME, SURNAME) VALUES(1, "A", "");
after this database stored record:
ID NAME LASTNAME
--------------------------
1 "A" NULL
When update NAME:
UPDATE PERSON SET ID=1, NAME="B", LASTNAME="" WHERE ID=1 AND NAME="A" AND SURNAME = "";
And this update return:
Updated 0 row(s), becose ID = 1, NAME = "A", but SURNAME not equals to NULL. Empty string not equivalet to NULL.
Tip:
If you use two application servers, and each of them connected via Castor to same database, then you must know that Castor by default cache-type set to count-limited, and capacity="30". It means that if you make update on one of server, the result not apeared on second server, becose Castor that works on second server already cached updated on first server item and not suspect what item has changed outside.
To be continued :)
Good luck
Alexey Efimov - Software Engineer
Sputnik Labs
1st Kolobovsky per., 6/3
Moscow, 103051, Russia
Phone: +7 (095) 725 5444
Direct: +7 (501) 401 3217
Fax: +7 (095) 725 5443
E-Mail: mailto:[EMAIL PROTECTED]
http://www.spklabs.com
