I'm having a weird (at least to me) issue when trying to do a rollback.
Basically during my tests I'm trying to insert a duplicate key, I catch and throw that 
error just fine, but I have a section of code later on that looks like:
                try{
                if(db.isActive())
                    db.rollback();                    
            }catch(TransactionNotInProgressException tnpe){
                logger.debug("Transaction Error:", tnpe);
            }
And when it gets to the db.rollback part I always get an the following error thrown:
java.lang.NullPointerException: Adding null value is not allowed
        at org.exolab.castor.persist.FieldMolder.addValue(FieldMolder.java:274)
        at 
org.exolab.castor.persist.CollectionProxy$ColProxy.add(ClassMolder.java:3150)
        at org.exolab.castor.persist.ClassMolder.revertObject(ClassMolder.java:2565)
        at org.exolab.castor.persist.LockEngine.revertObject(LockEngine.java:852)
        at 
org.exolab.castor.persist.TransactionContext.rollback(TransactionContext.java:1720)
        at org.exolab.castor.jdo.engine.DatabaseImpl.rollback(DatabaseImpl.java:554)
        ....

Is this what is supposed to happen, am I'm not supposed to try and do a rollback if I 
have a duplicate key error thrown? I can check for that easily enough, but I though 
this was a more standard procedure.

BTW, my commit code and everything is as follows:

        try{
            db.begin();            
            db.update(user.getDepartment());
            db.create(user);
            db.commit();
        }catch (DuplicateIdentityException de){
            logger.error("There is already a user with this username in the 
database.");
            throw new CommandException("Employee already exists.", de);
        }catch(PersistenceException pe){
            logger.error("There was a problem saving the user." + pe.getMessage());
            logger.debug("StackTrace:", pe);
            throw new CommandException(pe);
        }

Thanks for any assistance!
-Nick

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.619 / Virus Database: 398 - Release Date: 3/10/2004
 

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

Reply via email to