org.exolab.castor.persist.spi
Interface PersistenceFactory

All Known Implementing Classes:
BaseFactory, DB2Factory, DerbyFactory, GenericFactory, HsqlFactory, InformixFactory, InstantDBFactory, InterbaseFactory, MySQLFactory, OracleFactory, PointbaseFactory, PostgreSQLFactory, ProgressFactory, SapDbFactory, SQLServerFactory, SybaseFactory

public interface PersistenceFactory

Factory for producing new persistence implementations. Used for constructing a persistence service provider (see Persistence) as well as for constructing new query expressions (see QueryExpression).

The factory is specified in the JDO configuration file for the database and is configured through Bean-like accessor methods.

Version:
$Revision: 8994 $ $Date: 2011-08-02 01:40:59 +0200 (Di, 02 Aug 2011) $
Author:
Assaf Arkin, Bruce Snyder
See Also:
Persistence

Method Summary
 java.lang.Class<?> adjustSqlType(java.lang.Class<?> sqlType)
          Some databases has some problems with some SQL types.
 Visitor createQueryVisitor()
          Method to create an instance of database specific visitor to be used to construct statement.
 PersistenceQuery getCallQuery(java.lang.String call, java.lang.Class<?>[] paramTypes, java.lang.Class<?> javaClass, java.lang.String[] fields, int[] sqlTypes)
          Needed to process OQL queries of "CALL" type (using stored procedure call).
 java.lang.String getFactoryName()
          Returns the name of this factory.
 java.lang.String getIdentitySelectString(java.lang.String tableName, java.lang.String columnName)
          Returns the database specific query string for retrieving last identity value.
 KeyGenerator getKeyGenerator(ClassDescriptor clsDesc)
          Returns a key generator as specified in the given class descriptor.
 Persistence getPersistence(ClassDescriptor clsDesc)
          Returns a persistence implementation for the specified object type (given its descriptor) on behalf of the specified cache engine.
 QueryExpression getQueryExpression()
          Returns a new empty query expression suitable for the underlying SQL engine.
 java.lang.String getSequenceAfterSelectString(java.lang.String seqName, java.lang.String tableName)
          Returns the database specific SELECT query string for fetching identity after the INSERT statement executed.
 java.lang.String getSequenceBeforeSelectString(java.lang.String seqName, java.lang.String tableName, int increment)
          Returns the database specific SELECT query string for fetching identity before the next INSERT statement gets executed.
 boolean isKeyGeneratorIdentitySupported()
          Does persistence factory support generation of unique keys with identity key generator?
 boolean isKeyGeneratorIdentityTypeSupported(int type)
          Does identity key generator support generation of unique keys for the given SQL type?
 boolean isKeyGeneratorSequenceSupported(boolean returning, boolean trigger)
          Does persistence factory support generation of new key at the time of new object creation with sequence key generator?
 boolean isKeyGeneratorSequenceTypeSupported(int type)
          Does Sequence key generator support generation of key for the given SQL type?
 java.lang.String quoteName(java.lang.String name)
          Returns the quoted identifier suitable for preventing conflicts between database identifiers and reserved keywords.
 

Method Detail

getFactoryName

java.lang.String getFactoryName()
Returns the name of this factory. A descriptive name that indicates the type of supported database server or SQL syntax.

Returns:
The name of this factory

createQueryVisitor

Visitor createQueryVisitor()
Method to create an instance of database specific visitor to be used to construct statement.

Returns:
Database specific visitor instance to be used.

getKeyGenerator

KeyGenerator getKeyGenerator(ClassDescriptor clsDesc)
                             throws MappingException
Returns a key generator as specified in the given class descriptor.

Parameters:
clsDesc - The class descriptor.
Returns:
A suitable key generator or null.
Throws:
MappingException - If creation of key generator fails.

getPersistence

Persistence getPersistence(ClassDescriptor clsDesc)
                           throws MappingException
Returns a persistence implementation for the specified object type (given its descriptor) on behalf of the specified cache engine. Return null if no persistence support is available for the specified object type.

Parameters:
clsDesc - The class descriptor.
Returns:
A suitable persistence implementation or null.
Throws:
MappingException - Indicates that the object type is not supported by the persistence engine due to improper mapping.

getQueryExpression

QueryExpression getQueryExpression()
Returns a new empty query expression suitable for the underlying SQL engine. The implementation will construct SQL query statements in the preferred syntax.

Returns:
New empty query expression

quoteName

java.lang.String quoteName(java.lang.String name)
Returns the quoted identifier suitable for preventing conflicts between database identifiers and reserved keywords.

Parameters:
name - The identifier (table, column, etc)
Returns:
The quoted identifier

adjustSqlType

java.lang.Class<?> adjustSqlType(java.lang.Class<?> sqlType)
Some databases has some problems with some SQL types. Usually it is enough to merely replace one SQL type by another.

Parameters:
sqlType - The correspondent Java class for the SQL type in mapping.xml
Returns:
The correspondent Java class for the SQL type that should be used instead.

getCallQuery

PersistenceQuery getCallQuery(java.lang.String call,
                              java.lang.Class<?>[] paramTypes,
                              java.lang.Class<?> javaClass,
                              java.lang.String[] fields,
                              int[] sqlTypes)
Needed to process OQL queries of "CALL" type (using stored procedure call). This feature is specific for JDO.

Parameters:
call - Stored procedure call (without "{call")
paramTypes - The types of the query parameters
javaClass - The Java class of the query results
fields - The field names
sqlTypes - The field SQL types
Returns:
null if this feature is not supported.

isKeyGeneratorIdentitySupported

boolean isKeyGeneratorIdentitySupported()
Does persistence factory support generation of unique keys with identity key generator?

Returns:
true if persistence factory is able to generate unique keys with identity key generator, false otherwise.

isKeyGeneratorIdentityTypeSupported

boolean isKeyGeneratorIdentityTypeSupported(int type)
Does identity key generator support generation of unique keys for the given SQL type?

Parameters:
type - SQL type to check for support by identity key generator.
Returns:
true if persistence factory is able to generate unique keys of given SQL type with identity key generator, false otherwise.

getIdentitySelectString

java.lang.String getIdentitySelectString(java.lang.String tableName,
                                         java.lang.String columnName)
Returns the database specific query string for retrieving last identity value.

Parameters:
tableName - Name of the table from which identity needs to be fetched.
columnName - Name of the column from which identity needs to be fetched.
Returns:
SQL Query string for fetching the identity value.

isKeyGeneratorSequenceSupported

boolean isKeyGeneratorSequenceSupported(boolean returning,
                                        boolean trigger)
Does persistence factory support generation of new key at the time of new object creation with sequence key generator?

Parameters:
returning - Return generated key value with insert statement?
trigger - Use a database trigger to generate key?
Returns:
true if persistence factory is able to generate key with sequence key generator, false otherwise.

isKeyGeneratorSequenceTypeSupported

boolean isKeyGeneratorSequenceTypeSupported(int type)
Does Sequence key generator support generation of key for the given SQL type?

Parameters:
type - SQL type to check for support by sequence key generator.
Returns:
true if persistence factory is able to generate key of given SQL type with sequence key generator, false otherwise.

getSequenceBeforeSelectString

java.lang.String getSequenceBeforeSelectString(java.lang.String seqName,
                                               java.lang.String tableName,
                                               int increment)
Returns the database specific SELECT query string for fetching identity before the next INSERT statement gets executed.

Parameters:
seqName - Name of sequence.
tableName - Name of the table from which identity will be fetched.
increment - Increment value used in Interbase database engine.
Returns:
SELECT sql string

getSequenceAfterSelectString

java.lang.String getSequenceAfterSelectString(java.lang.String seqName,
                                              java.lang.String tableName)
Returns the database specific SELECT query string for fetching identity after the INSERT statement executed.

Parameters:
seqName - Name of sequence.
tableName - Name of the table from which identity will be fetched.
Returns:
SELECT sql string


Intalio Inc. (C) 1999-2008. All rights reserved http://www.intalio.com