|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.gora.store.impl.DataStoreBase<K,T>
org.apache.gora.sql.store.SqlStore<K,T>
public class SqlStore<K,T extends Persistent>
A DataStore implementation for RDBMS with a SQL interface. SqlStore uses the JOOQ API and various JDBC drivers to communicate with the DB. Through use of the JOOQ API this SqlStore aims to support numerous SQL database stores namely; DB2 9.7 Derby 10.8 H2 1.3.161 HSQLDB 2.2.5 Ingres 10.1.0 MySQL 5.1.41 and 5.5.8 Oracle XE 10.2.0.1.0 and 11g PostgreSQL 9.0 SQLite with inofficial JDBC driver v056 SQL Server 2008 R8 Sybase Adaptive Server Enterprise 15.5 Sybase SQL Anywhere 12 This DataStore is currently in development, and requires a complete re-write as per GORA-86 Please see https://issues.apache.org/jira/browse/GORA-86
Nested Class Summary | |
---|---|
static class |
SqlStore.DBVendor
The vendor of the DB |
Field Summary | |
---|---|
protected static String |
DEFAULT_MAPPING_FILE
|
protected static String |
DRIVER_CLASS_PROPERTY
The JDBC Driver class name |
protected static String |
PASSWORD_PROPERTY
Password to access the database |
protected static String |
URL_PROPERTY
JDBC Database access URL |
protected static String |
USERNAME_PROPERTY
User name to access the database |
Fields inherited from class org.apache.gora.store.impl.DataStoreBase |
---|
autoCreateSchema, beanFactory, conf, datumReader, datumWriter, fieldMap, keyClass, persistentClass, properties, schema |
Constructor Summary | |
---|---|
SqlStore()
|
Method Summary | ||
---|---|---|
void |
close()
Close the DataStore. |
|
void |
createSchema()
Creates the optional schema or table (or similar) in the datastore to hold the objects. |
|
protected void |
createSqlTable()
|
|
boolean |
delete(K key)
Deletes the object with the given key |
|
long |
deleteByQuery(Query<K,T> query)
Deletes all the objects matching the query. |
|
void |
deleteSchema()
Deletes the underlying schema or table (or similar) in the datastore that holds the objects. |
|
Result<K,T> |
execute(Query<K,T> query)
Executes the given query and returns the results. |
|
void |
flush()
Forces the write caches to be flushed. |
|
T |
get(K key,
String[] requestFields)
Returns the object corresponding to the given key. |
|
protected byte[] |
getBytes()
|
|
protected Connection |
getConnection()
|
|
protected String |
getIdentifier()
|
|
List<PartitionQuery<K,T>> |
getPartitions(Query<K,T> query)
Partitions the given query and returns a list of PartitionQuery s,
which will execute on local data. |
|
String |
getSchemaName()
Returns the schema name given to this DataStore |
|
protected void |
initDbMetadata()
|
|
void |
initialize()
|
|
Query<K,T> |
newQuery()
Constructs and returns a new Query. |
|
void |
put(K key,
T persistent)
Inserts the persistent object with the given key. |
|
protected Object |
readField()
|
|
protected SqlMapping |
readMapping()
|
|
T |
readObject(ResultSet rs,
T persistent,
String[] requestFields)
|
|
K |
readPrimaryKey(ResultSet resultSet)
|
|
boolean |
schemaExists()
Returns whether the schema that holds the data exists in the datastore. |
|
protected void |
setBytes()
|
|
protected void |
setField()
Serializes the field using Avro to a BLOB field |
|
void |
setObject(PreparedStatement statement,
int index,
Object object,
org.apache.avro.Schema schema,
Column column)
Sets the object to the preparedStatement by it's schema |
|
protected
|
setObject(PreparedStatement statement,
int index,
V object,
int objectType,
Column column)
|
Methods inherited from class org.apache.gora.store.impl.DataStoreBase |
---|
equals, get, getBeanFactory, getConf, getFieldsToQuery, getKeyClass, getOrCreateConf, getPersistentClass, getSchemaName, initialize, newKey, newPersistent, readFields, setBeanFactory, setConf, setKeyClass, setPersistentClass, truncateSchema, write |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected static final String DRIVER_CLASS_PROPERTY
protected static final String URL_PROPERTY
protected static final String USERNAME_PROPERTY
protected static final String PASSWORD_PROPERTY
protected static final String DEFAULT_MAPPING_FILE
Constructor Detail |
---|
public SqlStore()
Method Detail |
---|
public void initialize() throws IOException
IOException
public String getSchemaName()
DataStore
public void close() throws IOException
DataStore
IOException
public void createSchema() throws IOException
DataStore
IOException
public void deleteSchema() throws IOException
DataStore
IOException
public boolean schemaExists() throws IOException
DataStore
IOException
public boolean delete(K key) throws IOException
DataStore
key
- the key of the object
IOException
public long deleteByQuery(Query<K,T> query) throws IOException
DataStore
query
- matching records to this query will be deleted
IOException
public void flush() throws IOException
DataStore
IOException
public T get(K key, String[] requestFields) throws IOException
DataStore
key
- the key of the objectrequestFields
- the fields required in the object. Pass null, to retrieve all fields
IOException
public Result<K,T> execute(Query<K,T> query) throws IOException
DataStore
query
- the query to execute.
Result
object.
IOException
public K readPrimaryKey(ResultSet resultSet) throws SQLException
SQLException
public T readObject(ResultSet rs, T persistent, String[] requestFields) throws SQLException, IOException
SQLException
IOException
protected byte[] getBytes() throws SQLException, IOException
SQLException
IOException
protected Object readField() throws SQLException, IOException
SQLException
IOException
public List<PartitionQuery<K,T>> getPartitions(Query<K,T> query) throws IOException
DataStore
PartitionQuery
s,
which will execute on local data.
query
- the base query to create the partitions for. If the query
is null, then the data store returns the partitions for the default query
(returning every object)
IOException
public Query<K,T> newQuery()
DataStore
public void put(K key, T persistent) throws IOException
DataStore
IOException
public void setObject(PreparedStatement statement, int index, Object object, org.apache.avro.Schema schema, Column column) throws SQLException, IOException
SQLException
IOException
protected <V> void setObject(PreparedStatement statement, int index, V object, int objectType, Column column) throws SQLException, IOException
SQLException
IOException
protected void setBytes() throws SQLException
SQLException
protected void setField() throws IOException, SQLException
IOException
SQLException
protected Connection getConnection() throws IOException
IOException
protected void initDbMetadata() throws IOException
IOException
protected String getIdentifier()
protected void createSqlTable()
protected SqlMapping readMapping() throws IOException
IOException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |