|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.amazon.carbonado.spi.AbstractRepositoryBuilder
com.amazon.carbonado.repo.jdbc.JDBCRepositoryBuilder
public class JDBCRepositoryBuilder
Builds a repository instance backed by a JDBC accessible database.
JDBCRepository is not independent of the underlying database schema, and so
it requires matching tables and columns in the database. It will not alter
or create tables. Use the 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:
IndexInfoCapability
StorableInfoCapability
ShutdownCapability
SequenceCapability
JDBCConnectionCapability
| Constructor Summary | |
|---|---|
JDBCRepositoryBuilder()
|
|
| Method Summary | |
|---|---|
Repository |
build(AtomicReference<Repository> rootRef)
Builds a repository instance. |
void |
errorCheck(Collection<String> messages)
This method is called by assertReady, and subclasses must override to perform custom checks. |
String |
getCatalog()
Returns the optional catalog to search for metadata. |
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. |
Integer |
getDefaultFetchSize()
Returns the default fetch size when running queries, or null if driver default is used instead. |
String |
getDriverClassName()
Returns the driver class name, which may be null if a DataSource was provided. |
String |
getDriverURL()
Returns the connection URL, which may be null if a DataSource was provided. |
String |
getName()
Returns the name of the repository. |
String |
getPassword()
Returns the optional password to use with DataSource. |
String |
getSchema()
Returns the optional schema to search for metadata. |
String |
getSequenceSelectStatement()
Returns the native sequence select statement, which is null if the default is chosen. |
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,
String className)
By default, JDBCRepository assumes that version numbers are initialized and
incremented by triggers installed on the database. |
void |
setCatalog(String catalog)
Optionally set the catalog to search for metadata. |
void |
setDataSource(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(Integer size)
Set the default fetch size when running queries. |
void |
setDriverClassName(String driverClassName)
Set the JDBC driver class name, which is required if a DataSource was not provided. |
void |
setDriverURL(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(String name)
Set name for the repository, which is required. |
void |
setPassword(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(String schema)
Optionally set the schema to search for metadata. |
void |
setSequenceSelectStatement(String sequenceSelectStatement)
Override the default native sequence select statement with a printf. |
void |
setSuppressReload(boolean suppress,
String className)
By default, JDBCRepository reloads Storables after every insert or update. |
void |
setUserName(String username)
Optionally set the username to use with DataSource. |
| Methods inherited from class com.amazon.carbonado.spi.AbstractRepositoryBuilder |
|---|
addTriggerFactory, assertReady, build, getTriggerFactories, removeTriggerFactory |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public JDBCRepositoryBuilder()
| Method Detail |
|---|
public Repository build(AtomicReference<Repository> rootRef)
throws RepositoryException
RepositoryBuilderIf 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 built
ConfigurationException - if there is a problem in the builder's configuration
RepositoryException - if there is a general problem opening the repositorypublic String getName()
RepositoryBuilder
public void setName(String name)
RepositoryBuilder
public boolean isMaster()
RepositoryBuilderA 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.
ReplicatedRepositoryBuilderpublic void setMaster(boolean b)
RepositoryBuilderA 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.
ReplicatedRepositoryBuilderpublic void setDataSource(DataSource dataSource)
setDriverClassName(java.lang.String)
setDriverURL(java.lang.String)
setUserName(java.lang.String)
setPassword(java.lang.String)
public DataSource getDataSource()
throws ConfigurationException
ConfigurationException - if driver class wasn't foundpublic void setDataSourceCloseOnShutdown(boolean b)
public boolean getDataSourceCloseOnShutdown()
public void setDataSourceLogging(boolean b)
LoggingDataSourcepublic boolean getDataSourceLogging()
LoggingDataSourcepublic void setCatalog(String catalog)
public String getCatalog()
public void setSchema(String schema)
public String getSchema()
public void setDriverClassName(String driverClassName)
public String getDriverClassName()
public void setDriverURL(String url)
public String getDriverURL()
public void setUserName(String username)
public String getUserName()
public void setPassword(String password)
public String getPassword()
public void setDefaultFetchSize(Integer size)
public Integer getDefaultFetchSize()
public void setAutoVersioningEnabled(boolean enabled,
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 all
public void setSuppressReload(boolean suppress,
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 String getSequenceSelectStatement()
public void setSequenceSelectStatement(String sequenceSelectStatement)
public boolean isForceStoredSequence()
public void setForceStoredSequence(boolean forceStoredSequence)
public void setPrimaryKeyCheckDisabled(boolean primaryKeyCheckDisabled)
MismatchException.
public void errorCheck(Collection<String> messages)
throws ConfigurationException
AbstractRepositoryBuildersuper.errorCheck as well.
errorCheck in class AbstractRepositoryBuildermessages - add any error messages to this list
ConfigurationException - if error checking indirectly caused
another exception
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||