net.ontopia.persistence.proxy
Class RDBMSAccess

java.lang.Object
  extended by net.ontopia.persistence.proxy.RDBMSAccess
All Implemented Interfaces:
StorageAccessIF

public class RDBMSAccess
extends java.lang.Object
implements StorageAccessIF

INTERNAL: A storage access implementation accessing relational databases using JDBC.


Field Summary
protected  boolean batch_updates
           
protected  boolean closed
           
protected  java.sql.Connection conn_
           
protected  java.util.Map<java.lang.Thread,java.sql.Connection> conn_map
           
protected  boolean debug
           
protected  java.util.Collection flushable
           
protected  java.util.Map handlers
           
protected  java.lang.String id
           
protected  RDBMSMapping mapping
           
protected  boolean readonly
           
protected  RDBMSStorage storage
           
 
Constructor Summary
RDBMSAccess(java.lang.String id, RDBMSStorage storage, boolean readonly)
           
 
Method Summary
 void abort()
          INTERNAL: Aborts all changes performed in the transaction.
 void close()
          INTERNAL: Closes the storage access, which allows it to free its resources.
 void commit()
          INTERNAL: Commits the changes performed in the transaction.
 void createObject(ObjectAccessIF oaccess, java.lang.Object object)
          INTERNAL: Called by the transaction when it requests the new object to be created in the data repository.
 QueryIF createQuery(JDOQuery jdoquery, ObjectAccessIF oaccess, AccessRegistrarIF registrar, boolean lookup_identities)
          INTERNAL: Build a QueryIF from the specified JDO query instance.
 QueryIF createQuery(java.lang.String name, ObjectAccessIF oaccess, AccessRegistrarIF registrar)
          INTERNAL: Creates a query instance for the given transaction.
 void deleteObject(ObjectAccessIF oaccess, java.lang.Object object)
          INTERNAL: Called by the transaction when it requests the object to be deleted in the data repository.
 void flush()
          INTERNAL: Called when the transaction requires the transaction changes to be stored by the storage access (i.e.
 IdentityIF generateIdentity(java.lang.Object type)
          INTERNAL: Called by the application when it requests a new object identity for a given object type.
protected  java.sql.Connection getConn()
           
 java.sql.Connection getConnection()
          INTERNAL: Returns the JDBC database connection used.
protected  ClassAccessIF getHandler(java.lang.Object type)
          INTERNAL: Gets up the handler class that is used to manage objects of the given class.
 java.lang.String getId()
          INTERNAL: Gets the storage access id.
 java.lang.String getProperty(java.lang.String property)
          INTERNAL: Gets the value of the specified property.
 StorageIF getStorage()
          INTERNAL: Returns the storage definition that the access uses.
 boolean isReadOnly()
          INTERNAL: Returns true if the storage access is read-only.
protected  boolean isSQLException(java.lang.Throwable e)
           
 java.lang.Object loadField(AccessRegistrarIF registrar, IdentityIF identity, int field)
          INTERNAL: Requests the loading of the specified field for the given object identity.
 java.lang.Object loadFieldMultiple(AccessRegistrarIF registrar, java.util.Collection identities, IdentityIF current, java.lang.Object type, int field)
          INTERNAL: Requests the loading of the specified field for all the given object identities.
 boolean loadObject(AccessRegistrarIF registrar, IdentityIF identity)
          INTERNAL: Check for the existence of the object identity in the data repository.
 java.sql.PreparedStatement prepareStatement(java.lang.String sql)
           
protected  void resetConnection()
           
protected  void setConn(java.sql.Connection conn)
           
 void storeDirty(ObjectAccessIF oaccess, java.lang.Object object)
          INTERNAL: Stores object fields that are dirty in the database.
 boolean validate()
          INTERNAL: Returns true if the storage access is valid.
protected  boolean validateConnection(java.sql.Connection conn)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

debug

protected boolean debug

id

protected java.lang.String id

readonly

protected boolean readonly

storage

protected RDBMSStorage storage

mapping

protected RDBMSMapping mapping

conn_

protected java.sql.Connection conn_

conn_map

protected java.util.Map<java.lang.Thread,java.sql.Connection> conn_map

closed

protected boolean closed

handlers

protected java.util.Map handlers

batch_updates

protected boolean batch_updates

flushable

protected java.util.Collection flushable
Constructor Detail

RDBMSAccess

public RDBMSAccess(java.lang.String id,
                   RDBMSStorage storage,
                   boolean readonly)
Method Detail

getId

public java.lang.String getId()
Description copied from interface: StorageAccessIF
INTERNAL: Gets the storage access id. This id is unique for a given StorageIF instance.

Specified by:
getId in interface StorageAccessIF

getStorage

public StorageIF getStorage()
Description copied from interface: StorageAccessIF
INTERNAL: Returns the storage definition that the access uses.

Specified by:
getStorage in interface StorageAccessIF

isReadOnly

public boolean isReadOnly()
Description copied from interface: StorageAccessIF
INTERNAL: Returns true if the storage access is read-only.

Specified by:
isReadOnly in interface StorageAccessIF

getProperty

public java.lang.String getProperty(java.lang.String property)
Description copied from interface: StorageAccessIF
INTERNAL: Gets the value of the specified property.

Specified by:
getProperty in interface StorageAccessIF

getConn

protected java.sql.Connection getConn()

setConn

protected void setConn(java.sql.Connection conn)

getConnection

public java.sql.Connection getConnection()
INTERNAL: Returns the JDBC database connection used. It is important that this connection is neither closed, nor commited or rolled back.


prepareStatement

public java.sql.PreparedStatement prepareStatement(java.lang.String sql)
                                            throws java.sql.SQLException
Throws:
java.sql.SQLException

resetConnection

protected void resetConnection()

isSQLException

protected boolean isSQLException(java.lang.Throwable e)

getHandler

protected ClassAccessIF getHandler(java.lang.Object type)
INTERNAL: Gets up the handler class that is used to manage objects of the given class.


validate

public boolean validate()
Description copied from interface: StorageAccessIF
INTERNAL: Returns true if the storage access is valid.

Specified by:
validate in interface StorageAccessIF

validateConnection

protected boolean validateConnection(java.sql.Connection conn)

commit

public void commit()
Description copied from interface: StorageAccessIF
INTERNAL: Commits the changes performed in the transaction.

Specified by:
commit in interface StorageAccessIF

abort

public void abort()
Description copied from interface: StorageAccessIF
INTERNAL: Aborts all changes performed in the transaction.

Specified by:
abort in interface StorageAccessIF

close

public void close()
Description copied from interface: StorageAccessIF
INTERNAL: Closes the storage access, which allows it to free its resources.

Specified by:
close in interface StorageAccessIF

flush

public void flush()
Description copied from interface: StorageAccessIF
INTERNAL: Called when the transaction requires the transaction changes to be stored by the storage access (i.e. written to the database).

This method exists mainly to allow storage access implementations to optimize its communication with data repositories. An example of this is writing transaction changes in batches to improve performance.

Note that the transaction will always call this method at the end of its store method. It will do this so that it is sure that the changes will be visible inside the data repository.

Specified by:
flush in interface StorageAccessIF

loadObject

public boolean loadObject(AccessRegistrarIF registrar,
                          IdentityIF identity)
Description copied from interface: StorageAccessIF
INTERNAL: Check for the existence of the object identity in the data repository. An exception will be thrown if the object does not exist. If it exists the access registrar will be notified.

Specified by:
loadObject in interface StorageAccessIF
Returns:
true if object was found in the data store, false otherwise.

loadField

public java.lang.Object loadField(AccessRegistrarIF registrar,
                                  IdentityIF identity,
                                  int field)
Description copied from interface: StorageAccessIF
INTERNAL: Requests the loading of the specified field for the given object identity. An exception will be thrown if the object does not exist. If it exists the access registrar will be notified.

Specified by:
loadField in interface StorageAccessIF
Returns:
The value loaded for the specific field. Note that if the field is a reference field the identity will be returned, not the actual object. This is because the storage system does not deal with persistent object instances directly.

loadFieldMultiple

public java.lang.Object loadFieldMultiple(AccessRegistrarIF registrar,
                                          java.util.Collection identities,
                                          IdentityIF current,
                                          java.lang.Object type,
                                          int field)
Description copied from interface: StorageAccessIF
INTERNAL: Requests the loading of the specified field for all the given object identities. An exception will be thrown if the current object does not exist. If it exists the access registrar will be notified.

Specified by:
loadFieldMultiple in interface StorageAccessIF
Returns:
The value loaded for the specific field. Note that if the field is a reference field the identity will be returned, not the actual object. This is because the storage system does not deal with persistent object instances directly.

createObject

public void createObject(ObjectAccessIF oaccess,
                         java.lang.Object object)
Description copied from interface: StorageAccessIF
INTERNAL: Called by the transaction when it requests the new object to be created in the data repository. The ObjectAccessIF object is used to access information about the object as needed.

Specified by:
createObject in interface StorageAccessIF

deleteObject

public void deleteObject(ObjectAccessIF oaccess,
                         java.lang.Object object)
Description copied from interface: StorageAccessIF
INTERNAL: Called by the transaction when it requests the object to be deleted in the data repository.

Specified by:
deleteObject in interface StorageAccessIF

storeDirty

public void storeDirty(ObjectAccessIF oaccess,
                       java.lang.Object object)
Description copied from interface: StorageAccessIF
INTERNAL: Stores object fields that are dirty in the database.

Specified by:
storeDirty in interface StorageAccessIF

createQuery

public QueryIF createQuery(java.lang.String name,
                           ObjectAccessIF oaccess,
                           AccessRegistrarIF registrar)
Description copied from interface: StorageAccessIF
INTERNAL: Creates a query instance for the given transaction.

Specified by:
createQuery in interface StorageAccessIF

createQuery

public QueryIF createQuery(JDOQuery jdoquery,
                           ObjectAccessIF oaccess,
                           AccessRegistrarIF registrar,
                           boolean lookup_identities)
Description copied from interface: StorageAccessIF
INTERNAL: Build a QueryIF from the specified JDO query instance.

Specified by:
createQuery in interface StorageAccessIF

generateIdentity

public IdentityIF generateIdentity(java.lang.Object type)
Description copied from interface: StorageAccessIF
INTERNAL: Called by the application when it requests a new object identity for a given object type.

Specified by:
generateIdentity in interface StorageAccessIF


Copyright © 2000-2012 Ontopia.