added openjpa.Id property, and put logic in PersistenceUnitInfoImpl to set the openjpa.Id property to the persistence unit name if no openjpa.Id property is discovered.

git-svn-id: https://svn.apache.org/repos/asf/incubator/openjpa/trunk@475084 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Patrick Linskey 2006-11-15 00:30:24 +00:00
parent 301580c069
commit bda2015398
4 changed files with 43 additions and 1 deletions

View File

@ -1383,4 +1383,22 @@ public interface OpenJPAConfiguration
* configuration. * configuration.
*/ */
public StoreFacadeTypeRegistry getStoreFacadeTypeRegistry(); public StoreFacadeTypeRegistry getStoreFacadeTypeRegistry();
/**
* An environment-specific identifier for this configuration. This
* might correspond to a JPA persistence-unit name, or to some other
* more-unique value available in the current environment.
*
* @since 0.9.7
*/
public String getId();
/**
* An environment-specific identifier for this configuration. This
* might correspond to a JPA persistence-unit name, or to some other
* more-unique value available in the current environment.
*
* @since 0.9.7
*/
public void setId(String id);
} }

View File

@ -127,6 +127,7 @@ public class OpenJPAConfigurationImpl
public ObjectValue orphanedKeyPlugin; public ObjectValue orphanedKeyPlugin;
public ObjectValue compatibilityPlugin; public ObjectValue compatibilityPlugin;
public QueryCompilationCacheValue queryCompilationCachePlugin; public QueryCompilationCacheValue queryCompilationCachePlugin;
public StringValue id;
// custom values // custom values
public BrokerFactoryValue brokerFactoryPlugin; public BrokerFactoryValue brokerFactoryPlugin;
@ -466,6 +467,8 @@ public class OpenJPAConfigurationImpl
"getQueryCompilationCacheInstance"); "getQueryCompilationCacheInstance");
addValue(queryCompilationCachePlugin); addValue(queryCompilationCachePlugin);
addString("Id");
// initialize supported options that some runtimes may not support // initialize supported options that some runtimes may not support
supportedOptions.add(OPTION_NONTRANS_READ); supportedOptions.add(OPTION_NONTRANS_READ);
supportedOptions.add(OPTION_OPTIMISTIC); supportedOptions.add(OPTION_OPTIMISTIC);
@ -1405,6 +1408,15 @@ public class OpenJPAConfigurationImpl
return _storeFacadeRegistry; return _storeFacadeRegistry;
} }
public String getId() {
return id.get();
}
public void setId(String id) {
assertNotReadOnly();
this.id.set(id);
}
public void instantiateAll() { public void instantiateAll() {
super.instantiateAll(); super.instantiateAll();
getMetaDataRepositoryInstance(); getMetaDataRepositoryInstance();

View File

@ -557,6 +557,15 @@ QueryCompilationCache-displayorder: 50
QueryCompilationCache-expert: true QueryCompilationCache-expert: true
QueryCompilationCache-interface: java.util.Map QueryCompilationCache-interface: java.util.Map
Id-name: Configuration ID
Id-desc: An environment-specific identifier for this configuration. This \
might correspond to a JPA persistence-unit name, or to some other \
more-unique value available in the current environment.
Id-type: General
Id-cat: Persistence
Id-displayorder: 50
Id-expert: true
no-named-cf: use a DataSource bound to JNDI no-named-cf: use a DataSource bound to JNDI
diff-specs: Attempt to configure for multiple specifications. Was configured \ diff-specs: Attempt to configure for multiple specifications. Was configured \
for "{0}". Attempt to now configure for "{1}". This attempt will be \ for "{0}". Attempt to now configure for "{1}". This attempt will be \

View File

@ -357,6 +357,9 @@ public class PersistenceUnitInfoImpl
map.remove(PersistenceProviderImpl.CLASS_TRANSFORMER_OPTIONS); map.remove(PersistenceProviderImpl.CLASS_TRANSFORMER_OPTIONS);
} }
if (!map.containsKey("openjpa.Id"))
map.put("openjpa.Id", info.getPersistenceUnitName());
Properties metaFactoryProps = new Properties(); Properties metaFactoryProps = new Properties();
if (info.getManagedClassNames() != null if (info.getManagedClassNames() != null
&& !info.getManagedClassNames().isEmpty()) { && !info.getManagedClassNames().isEmpty()) {