This might be a bug of castor, please try on your project to see if it would 
happen.

I'm using mysql and my mapping file contains something like this:
-------------------------------------
 <key-generator name="HIGH-LOW">
  <param name="table" value="sequence"/>
  <param name="key-column" value="tablename"/>
  <param name="value-column" value="currentid"/>
  <param name="same-connection" value="true"/>
  <param name="grab-size" value="1"/>
 </key-generator>

 <class identity="id" key-generator="HIGH-LOW" name="model.User">
  <map-to xml="user" table="user" />
  <field name="id" type="integer">
   <sql name="id" type="integer" />
  </field>
  <field name="name" type="string">
   <sql name="name" type="varchar" />
  </field>
 </class>

Suppose that current MAX id of user table is 1000, and the following statments:
-------------------------------------
Integer id = new Integer(1001);
User user = database.load(User.class, id);

will throw an exception:
-------------------------------------
org.exolab.castor.jdo.ObjectNotFoundException: The object of type model.User 
with identity 1,001 was not found in persistent storage

After this, new user object could never be created:
-------------------------------------
User user = new User();
user.setName("Sean");
database.create(user);

throws an exception:
-------------------------------------
org.exolab.castor.jdo.LockNotGrantedException: Lock is already existed for the 
new oid.
 at org.exolab.castor.persist.LockEngine$TypeInfo.rename(LockEngine.java:1357)
 at 
org.exolab.castor.persist.LockEngine$TypeInfo.access$400(LockEngine.java:1038)
 at org.exolab.castor.persist.LockEngine.create(LockEngine.java:496)
 at 
org.exolab.castor.persist.TransactionContext.create(TransactionContext.java:907)
 at org.exolab.castor.jdo.engine.DatabaseImpl.create(DatabaseImpl.java:374)
 ...
org.exolab.castor.jdo.PersistenceException: Nested error: Key Generator 
Failure. Duplicated Identity is generated!


I searched the Internet and can't find any solution to the exception. Do you 
have any suggestion?
http://hypermail.linklord.com/castor-dev/2004/Apr/4119.html

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

Reply via email to