Author: epbernard
Date: 2009-12-10 11:49:46 -0500 (Thu, 10 Dec 2009)
New Revision: 18200
Modified:
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/Ejb3Configuration.java
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/HibernatePersistence.java
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/packaging/PersistenceMetadata.java
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/packaging/PersistenceXmlLoader.java
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/util/LogHelper.java
Log:
HHH-4659 HHH-4668 add mapping support for validation-mode and shared-cache-mode
Modified: core/trunk/entitymanager/src/main/java/org/hibernate/ejb/Ejb3Configuration.java
===================================================================
---
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/Ejb3Configuration.java 2009-12-10
15:44:02 UTC (rev 18199)
+++
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/Ejb3Configuration.java 2009-12-10
16:49:46 UTC (rev 18200)
@@ -55,6 +55,7 @@
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 @@
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 @@
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;
Modified:
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/HibernatePersistence.java
===================================================================
---
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/HibernatePersistence.java 2009-12-10
15:44:02 UTC (rev 18199)
+++
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/HibernatePersistence.java 2009-12-10
16:49:46 UTC (rev 18200)
@@ -56,6 +56,14 @@
*/
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
*/
public static final String AUTODETECTION = "hibernate.archive.autodetection";
Modified:
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/packaging/PersistenceMetadata.java
===================================================================
---
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/packaging/PersistenceMetadata.java 2009-12-10
15:44:02 UTC (rev 18199)
+++
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/packaging/PersistenceMetadata.java 2009-12-10
16:49:46 UTC (rev 18200)
@@ -51,7 +51,18 @@
private List<NamedInputStream> hbmfiles = new
ArrayList<NamedInputStream>();
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 @@
.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 @@
return sb.toString();
}
+
+ public void setValidationMode(String validationMode) {
+ this.validationMode = validationMode;
+ }
+
+ public String getValidationMode() {
+ return validationMode;
+ }
+
+ public void setSharedCacheMode(String sharedCacheMode) {
+ this.sharedCacheMode = sharedCacheMode;
+ }
}
Modified:
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/packaging/PersistenceXmlLoader.java
===================================================================
---
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/packaging/PersistenceXmlLoader.java 2009-12-10
15:44:02 UTC (rev 18199)
+++
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/packaging/PersistenceXmlLoader.java 2009-12-10
16:49:46 UTC (rev 18200)
@@ -212,6 +212,12 @@
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++ ) {
Modified: core/trunk/entitymanager/src/main/java/org/hibernate/ejb/util/LogHelper.java
===================================================================
---
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/util/LogHelper.java 2009-12-10
15:44:02 UTC (rev 18199)
+++
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/util/LogHelper.java 2009-12-10
16:49:46 UTC (rev 18200)
@@ -63,6 +63,12 @@
.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<URL> jarFileUrls = unitInfo.getJarFileUrls();
Show replies by date