Created
August 12, 2011 15:08
-
-
Save hferentschik/1142243 to your computer and use it in GitHub Desktop.
extractPropertId
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private Serializable extractProperId(Work<T> work) { | |
T entity = work.getEntity(); | |
// 1) entity is null for purge operation, which requires to trust the work id | |
// 2) types mapped as provided id require to use the work id | |
// 3) when Hibernate identifier rollback is used && this identifier is our same id source, we need to get the value from work id | |
if ( entity == null | |
|| documentBuilder.requiresProvidedId() | |
|| ( work.isIdentifierWasRolledBack() && documentBuilder.isIdMatchingJpaId() ) ) { | |
return work.getId(); | |
} | |
else { | |
// return documentBuilder.getId( entity ); | |
Serializable id = documentBuilder.getId( entity ); | |
if ( id != null ) { | |
return id; | |
} | |
else { | |
return work.getId(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment