Thursday, November 4, 2010

Hibernate testing for Transient entity

            try {
                Serializable id = session.getIdentifier(entity);
                if (id != null)
                    session.buildLockRequest(LockOptions.NONE).lock(entity);
            } catch (TransientObjectException e) {
                // Entity is a new object, nothing to reattach
            }

No comments:

Post a Comment