public class JDBCRepositoryBuilder extends AbstractRepositoryBuilder
Alias
annotation to control precisely which tables and columns must be matched up.
Note: The current JDBC repository implementation makes certain assumptions about the database it is accessing. It must support transactions and multiple statements per connection. If it doesn't support savepoints, then nested transactions are faked -- rollback of inner transaction will appear to do nothing.
The following extra capabilities are supported:
Constructor and Description |
---|
JDBCRepositoryBuilder() |
Modifier and Type | Method and Description |
---|---|
Repository |
build(java.util.concurrent.atomic.AtomicReference<Repository> rootRef)
Builds a repository instance.
|
void |
errorCheck(java.util.Collection<java.lang.String> messages)
This method is called by assertReady, and subclasses must override to
perform custom checks.
|
java.lang.String |
getCatalog()
Returns the optional catalog to search for metadata.
|
javax.sql.DataSource |
getDataSource()
Returns the source of JDBC connections, which defaults to a non-pooling
source if driver class, driver URL, username, and password are all
supplied.
|
boolean |
getDataSourceCloseOnShutdown()
Returns true if DataSource is closed when the repository is closed or
shutdown.
|
boolean |
getDataSourceLogging()
Returns true if debug logging is enabled.
|
java.lang.Integer |
getDefaultFetchSize()
Returns the default fetch size when running queries, or null if driver
default is used instead.
|
java.lang.String |
getDriverClassName()
Returns the driver class name, which may be null if a DataSource was provided.
|
java.lang.String |
getDriverURL()
Returns the connection URL, which may be null if a DataSource was
provided.
|
java.lang.String |
getName()
Returns the name of the repository.
|
java.lang.String |
getPassword()
Returns the optional password to use with DataSource.
|
java.lang.String |
getSchema()
Returns the optional schema to search for metadata.
|
java.lang.String |
getSequenceSelectStatement()
Returns the native sequence select statement, which is null if the
default is chosen.
|
java.lang.String |
getUserName()
Returns the optional username to use with DataSource.
|
boolean |
isForceStoredSequence()
Returns true if native sequences should not be used.
|
boolean |
isMaster()
Returns true if repository should assume the role of master, which is
true by default.
|
void |
setAutoVersioningEnabled(boolean enabled,
java.lang.String className)
By default, JDBCRepository assumes that
version numbers are initialized and
incremented by triggers installed on the database. |
void |
setCatalog(java.lang.String catalog)
Optionally set the catalog to search for metadata.
|
void |
setDataSource(javax.sql.DataSource dataSource)
Set the source of JDBC connections, overriding any configuration
supported by these methods:
setDriverClassName(java.lang.String)
setDriverURL(java.lang.String)
setUserName(java.lang.String)
setPassword(java.lang.String)
|
void |
setDataSourceCloseOnShutdown(boolean b)
Pass true to cause the DataSource to be closed when the repository is
closed or shutdown.
|
void |
setDataSourceLogging(boolean b)
Pass true to enable debug logging.
|
void |
setDefaultFetchSize(java.lang.Integer size)
Set the default fetch size when running queries.
|
void |
setDriverClassName(java.lang.String driverClassName)
Set the JDBC driver class name, which is required if a DataSource was not provided.
|
void |
setDriverURL(java.lang.String url)
Set the JDBC connection URL, which is required if a DataSource was not
provided.
|
void |
setForceStoredSequence(boolean forceStoredSequence)
By default, native sequences are used if supported.
|
void |
setMaster(boolean b)
Set to false if repository should not assume the role of master.
|
void |
setName(java.lang.String name)
Set name for the repository, which is required.
|
void |
setPassword(java.lang.String password)
Optionally set the password to use with DataSource.
|
void |
setPrimaryKeyCheckDisabled(boolean primaryKeyCheckDisabled)
By default, JDBCRepository makes sure that every declared primary key
in the database table for a Storable lines up with a declared
PrimaryKey or AlternateKey.
|
void |
setSchema(java.lang.String schema)
Optionally set the schema to search for metadata.
|
void |
setSequenceSelectStatement(java.lang.String sequenceSelectStatement)
Override the default native sequence select statement with a printf.
|
void |
setSuppressReload(boolean suppress,
java.lang.String className)
By default, JDBCRepository reloads Storables after every insert or
update.
|
void |
setUserName(java.lang.String username)
Optionally set the username to use with DataSource.
|
addTriggerFactory, assertReady, build, getTriggerFactories, removeTriggerFactory
public Repository build(java.util.concurrent.atomic.AtomicReference<Repository> rootRef) throws RepositoryException
RepositoryBuilder
If the repository is being wrapped by a parent repository, the child repository will need to know this fact for some operations to work correctly. Since the parent repository is not built yet, a reference is used instead.
rootRef
- reference to root parent repository, to be set by
parent repository upon being builtConfigurationException
- if there is a problem in the builder's configurationRepositoryException
- if there is a general problem opening the repositorypublic java.lang.String getName()
RepositoryBuilder
public void setName(java.lang.String name)
RepositoryBuilder
public boolean isMaster()
RepositoryBuilder
A master repository is responsible for version
and
sequence
properties. For insert operations, a master
repository must set these properties if they are uninitialized. For
updates, the version property is checked to see if an OptimisticLockException
should be thrown.
ReplicatedRepositoryBuilder
public void setMaster(boolean b)
RepositoryBuilder
A master repository is responsible for version
and
sequence
properties. For insert operations, a master
repository must set these properties if they are uninitialized. For
updates, the version property is checked to see if an OptimisticLockException
should be thrown.
ReplicatedRepositoryBuilder
public void setDataSource(javax.sql.DataSource dataSource)
public javax.sql.DataSource getDataSource() throws ConfigurationException
ConfigurationException
- if driver class wasn't foundpublic void setDataSourceCloseOnShutdown(boolean b)
public boolean getDataSourceCloseOnShutdown()
public void setDataSourceLogging(boolean b)
LoggingDataSource
public boolean getDataSourceLogging()
LoggingDataSource
public void setCatalog(java.lang.String catalog)
public java.lang.String getCatalog()
public void setSchema(java.lang.String schema)
public java.lang.String getSchema()
public void setDriverClassName(java.lang.String driverClassName)
public java.lang.String getDriverClassName()
public void setDriverURL(java.lang.String url)
public java.lang.String getDriverURL()
public void setUserName(java.lang.String username)
public java.lang.String getUserName()
public void setPassword(java.lang.String password)
public java.lang.String getPassword()
public void setDefaultFetchSize(java.lang.Integer size)
public java.lang.Integer getDefaultFetchSize()
public void setAutoVersioningEnabled(boolean enabled, java.lang.String className)
version numbers
are initialized and
incremented by triggers installed on the database. Enabling automatic
versioning here causes the JDBCRepository to manage these operations
itself.enabled
- true to enable, false to disableclassName
- name of Storable type to enable automatic version
management on; pass null to enable allpublic void setSuppressReload(boolean suppress, java.lang.String className)
Note: If Storable has a version property and auto versioning is not enabled, or if the Storable has any automatic properties, the Storable might still be reloaded.
suppress
- true to suppress, false to unsuppressclassName
- name of Storable type to suppress reload for; pass null
to suppress allpublic java.lang.String getSequenceSelectStatement()
public void setSequenceSelectStatement(java.lang.String sequenceSelectStatement)
public boolean isForceStoredSequence()
public void setForceStoredSequence(boolean forceStoredSequence)
public void setPrimaryKeyCheckDisabled(boolean primaryKeyCheckDisabled)
MismatchException
.public void errorCheck(java.util.Collection<java.lang.String> messages) throws ConfigurationException
AbstractRepositoryBuilder
super.errorCheck
as well.errorCheck
in class AbstractRepositoryBuilder
messages
- add any error messages to this listConfigurationException
- if error checking indirectly caused
another exceptionCopyright © 2006-2013 Amazon Technologies, Inc.. All Rights Reserved.