ObjectLock.invalidate() is called if anything goes wrong during a transaction to indicate that the entity should not be put back into cache as it may have an invalid state (at least as far as I understand this). To do so ObjectLock.invalidate() internally sets _invalidated flag. This flag is checked at ObjectLock.release() to set _object to null. But in contrast to my expectations the flag isn't checked at TypeInfo.release() to determine if the object should be put back into cache or not. Instead a CacheEntry with Object being null is put into cache.
On the other hand we have an mechanism to expire an entity. From my point of view the expiration is called by a user to tell Castor that the entity in cache is invalid which is about similar to the situation where Castor detects an invalid entity state itself.