diff --git a/entitymanager/src/main/java/org/hibernate/ejb/Ejb3Configuration.java b/entitymanager/src/main/java/org/hibernate/ejb/Ejb3Configuration.java index 350892441b..46a76d774f 100644 --- a/entitymanager/src/main/java/org/hibernate/ejb/Ejb3Configuration.java +++ b/entitymanager/src/main/java/org/hibernate/ejb/Ejb3Configuration.java @@ -55,6 +55,7 @@ import javax.persistence.EntityManagerFactory; import javax.persistence.EntityNotFoundException; import javax.persistence.MappedSuperclass; import javax.persistence.PersistenceException; +import javax.persistence.ValidationMode; import javax.persistence.spi.PersistenceUnitInfo; import javax.persistence.spi.PersistenceUnitTransactionType; import javax.sql.DataSource; @@ -200,6 +201,12 @@ public class Ejb3Configuration implements Serializable, Referenceable { if ( metadata.getHbmfiles().size() > 0 ) { workingVars.put( HibernatePersistence.HBXML_FILES, metadata.getHbmfiles() ); } + if ( metadata.getValidationMode() != null) { + workingVars.put( HibernatePersistence.VALIDATION_MODE, metadata.getValidationMode() ); + } + if ( metadata.getSharedCacheMode() != null) { + workingVars.put( HibernatePersistence.SHARED_CACHE_MODE, metadata.getSharedCacheMode() ); + } Properties props = new Properties(); props.putAll( metadata.getProps() ); if ( overrides != null ) { @@ -476,6 +483,18 @@ public class Ejb3Configuration implements Serializable, Referenceable { workingVars.put( HibernatePersistence.XML_FILE_NAMES, xmlFiles ); if ( hbmFiles.size() > 0 ) workingVars.put( HibernatePersistence.HBXML_FILES, hbmFiles ); + //validation-mode + final Object validationMode = info.getValidationMode(); + if ( validationMode != null) { + workingVars.put( HibernatePersistence.VALIDATION_MODE, validationMode ); + } + + //shared-cache-mode + final Object sharedCacheMode = info.getSharedCacheMode(); + if ( sharedCacheMode != null) { + workingVars.put( HibernatePersistence.SHARED_CACHE_MODE, sharedCacheMode ); + } + //datasources Boolean isJTA = null; boolean overridenDatasource = false; diff --git a/entitymanager/src/main/java/org/hibernate/ejb/HibernatePersistence.java b/entitymanager/src/main/java/org/hibernate/ejb/HibernatePersistence.java index 9e301bef45..a0b65c8e07 100755 --- a/entitymanager/src/main/java/org/hibernate/ejb/HibernatePersistence.java +++ b/entitymanager/src/main/java/org/hibernate/ejb/HibernatePersistence.java @@ -55,6 +55,14 @@ public class HibernatePersistence implements javax.persistence.spi.PersistencePr * Non JTA datasource name */ public static final String NON_JTA_DATASOURCE = "javax.persistence.nonJtaDataSource"; + /** + * Validation mode + */ + public static final String VALIDATION_MODE = "javax.persistence.validation.mode"; + /** + * Shared cache mode + */ + public static final String SHARED_CACHE_MODE = "javax.persistence.sharedCache.mode"; /** * JAR autodetection artifacts class, hbm */ diff --git a/entitymanager/src/main/java/org/hibernate/ejb/packaging/PersistenceMetadata.java b/entitymanager/src/main/java/org/hibernate/ejb/packaging/PersistenceMetadata.java index 4ad95f8a25..9b9b876f6d 100644 --- a/entitymanager/src/main/java/org/hibernate/ejb/packaging/PersistenceMetadata.java +++ b/entitymanager/src/main/java/org/hibernate/ejb/packaging/PersistenceMetadata.java @@ -51,6 +51,17 @@ public class PersistenceMetadata { private List hbmfiles = new ArrayList(); private Properties props = new Properties(); private boolean excludeUnlistedClasses = false; + private String validationMode; + + public String getSharedCacheMode() { + return sharedCacheMode; + } + + public boolean isExcludeUnlistedClasses() { + return excludeUnlistedClasses; + } + + private String sharedCacheMode; public String getName() { return name; @@ -204,6 +215,13 @@ public class PersistenceMetadata { .append( hbmfiles != null ? hbmfiles.size() : 0 ).append("\n") .append("\tproperties[\n"); + if (validationMode != null) { + sb.append("\tvalidation-mode: ").append(validationMode).append("\n"); + } + if (sharedCacheMode != null) { + sb.append("\tshared-cache-mode: ").append(sharedCacheMode).append("\n"); + } + if (props != null) { for ( Map.Entry elt : props.entrySet()) { sb.append("\t\t").append( elt.getKey() ).append(": ").append( elt.getValue() ).append("\n"); @@ -213,4 +231,16 @@ public class PersistenceMetadata { return sb.toString(); } + + public void setValidationMode(String validationMode) { + this.validationMode = validationMode; + } + + public String getValidationMode() { + return validationMode; + } + + public void setSharedCacheMode(String sharedCacheMode) { + this.sharedCacheMode = sharedCacheMode; + } } diff --git a/entitymanager/src/main/java/org/hibernate/ejb/packaging/PersistenceXmlLoader.java b/entitymanager/src/main/java/org/hibernate/ejb/packaging/PersistenceXmlLoader.java index 554939f527..750b1a517a 100644 --- a/entitymanager/src/main/java/org/hibernate/ejb/packaging/PersistenceXmlLoader.java +++ b/entitymanager/src/main/java/org/hibernate/ejb/packaging/PersistenceXmlLoader.java @@ -212,6 +212,12 @@ public final class PersistenceXmlLoader { else if ( tag.equals( "delimited-identifiers" ) ) { metadata.setUseQuotedIdentifiers( true ); } + else if ( tag.equals( "validation-mode" ) ) { + metadata.setValidationMode( XmlHelper.getElementContent( element ) ); + } + else if ( tag.equals( "shared-cache-mode" ) ) { + metadata.setSharedCacheMode( XmlHelper.getElementContent( element ) ); + } else if ( tag.equals( "properties" ) ) { NodeList props = element.getChildNodes(); for ( int j = 0; j < props.getLength() ; j++ ) { diff --git a/entitymanager/src/main/java/org/hibernate/ejb/util/LogHelper.java b/entitymanager/src/main/java/org/hibernate/ejb/util/LogHelper.java index 4ca48627b5..017a1a06cd 100644 --- a/entitymanager/src/main/java/org/hibernate/ejb/util/LogHelper.java +++ b/entitymanager/src/main/java/org/hibernate/ejb/util/LogHelper.java @@ -63,6 +63,12 @@ public final class LogHelper { .append( "\n\t" ) .append( "PU root URL: " ) .append( unitInfo.getPersistenceUnitRootUrl() ) + .append( "\n\t" ) + .append( "Shared Cache Mode: " ) + .append( unitInfo.getSharedCacheMode() ) + .append( "\n\t" ) + .append( "Validation Mode: " ) + .append( unitInfo.getValidationMode() ) .append( "\n\t" ); sb.append( "Jar files URLs [" ); List jarFileUrls = unitInfo.getJarFileUrls();