HHH-4659 HHH-4668 add mapping support for validation-mode and shared-cache-mode
git-svn-id: https://svn.jboss.org/repos/hibernate/core/trunk@18200 1b8cb986-b30d-0410-93ca-fae66ebed9b2
This commit is contained in:
parent
11d10450ce
commit
e183c40ee7
|
@ -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;
|
||||
|
|
|
@ -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
|
||||
*/
|
||||
|
|
|
@ -51,6 +51,17 @@ public class PersistenceMetadata {
|
|||
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 @@ 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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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++ ) {
|
||||
|
|
|
@ -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<URL> jarFileUrls = unitInfo.getJarFileUrls();
|
||||
|
|
Loading…
Reference in New Issue