站内搜索: 请输入搜索关键词
当前页面: 在线文档首页 > Hibernate 2.1.8 正式版 API 英文文档

AbstractCollectionPersister (Hibernate API Documentation) - Hibernate 2.1.8 正式版 API 英文文档


net.sf.hibernate.collection
Class AbstractCollectionPersister

java.lang.Object
  extended bynet.sf.hibernate.collection.AbstractCollectionPersister
All Implemented Interfaces:
CollectionMetadata, CollectionPersister, Joinable, PropertyMapping, QueryableCollection
Direct Known Subclasses:
BasicCollectionPersister, OneToManyPersister

public abstract class AbstractCollectionPersister
extends Object
implements CollectionMetadata, QueryableCollection

Base implementation of the QueryableCollection interface.

Author:
Gavin King
See Also:
BasicCollectionPersister, OneToManyPersister

Field Summary
protected  int batchSize
           
protected  String[] elementColumnAliases
           
protected  String[] elementColumnNames
           
protected  ClassPersister elementPersister
           
protected  Type elementType
           
protected  boolean hasIdentifier
           
protected  boolean hasIndex
           
protected  boolean hasWhere
           
protected  String identifierColumnName
           
protected  String[] indexColumnAliases
           
protected  String[] indexColumnNames
           
protected  String[] keyColumnAliases
           
protected  String[] keyColumnNames
           
protected  String qualifiedTableName
           
protected  String[] rowSelectColumnNames
           
protected  String sqlWhereString
           
 
Constructor Summary
AbstractCollectionPersister(Collection collection, Configuration cfg, SessionFactoryImplementor factory)
           
 
Method Summary
protected  JDBCException convert(SQLException sqlException, String message)
           
protected abstract  CollectionInitializer createCollectionInitializer(SessionFactoryImplementor factory)
           
 void deleteRows(PersistentCollection collection, Serializable id, SessionImplementor session)
          Delete the persistent state of any elements that were removed from the collection
protected abstract  int doUpdateRows(Serializable key, PersistentCollection collection, SessionImplementor session)
           
 int enableJoinedFetch()
          Should we load this collection role by outerjoining?
protected abstract  String generateDeleteRowString()
           
protected abstract  String generateDeleteString()
           
protected abstract  String generateInsertRowString()
           
protected abstract  String generateUpdateRowString()
           
 CacheConcurrencyStrategy getCache()
          Get the cache
 CollectionMetadata getCollectionMetadata()
           
 Serializable getCollectionSpace()
          Get the "space" that holds the persistent state
 PersistentCollectionType getCollectionType()
          Get the associated Type
 Class getElementClass()
          Return the element class of an array, or null otherwise
 String[] getElementColumnNames()
          Get the names of the collection element columns (or the primary key columns in the case of a one-to-many association)
 ClassPersister getElementPersister()
          Get the persister of the element class, if this is a collection of entities (optional operation).
 Type getElementType()
          The collection element type
 IdentifierGenerator getIdentifierGenerator()
          Get the surrogate key generation strategy (optional operation)
 Type getIdentifierType()
          Get the type of the surrogate key
 String[] getIndexColumnNames()
          Get the names of the collection index columnsm if this is an indexed collection (optional operation)
 Type getIndexType()
          The collection index type (or null if the collection has no index)
 String[] getJoinKeyColumnNames()
          The columns to join on.
 String[] getKeyColumnNames()
          Get the names of the collection key columns
 Type getKeyType()
          The collection key type
 String getName()
          An identifying name; a class name or collection role name.
 Class getOwnerClass()
          Get the entity class that "owns" this collection
 String getRole()
          The name of this collection role
protected  String getSQLDeleteRowString()
           
protected  String getSQLDeleteString()
           
protected  String getSQLInsertRowString()
           
 String getSQLOrderByString(String alias)
          Get the order by SQL
protected  String getSQLUpdateRowString()
           
 String getSQLWhereString(String alias)
          Get the extra where clause filter SQL
 String getTableName()
          The table to join to.
 Type getType()
          Get the type of the thing containing the properties
 boolean hasCache()
          Is this collection role cacheable
 boolean hasIndex()
          Is this collection indexed?
 boolean hasOrdering()
          Is this an ordered collection? (An ordered collection is ordered by the initialization operation, not by sorting that happens in memory, as in the case of a sorted collection.)
 boolean hasOrphanDelete()
          Does this collection implement "orphan delete"?
 boolean hasWhere()
          Does this collection role have a where clause filter?
 void initialize(Serializable key, SessionImplementor session)
          Initialize the given collection with the given key
 void insertRows(PersistentCollection collection, Serializable id, SessionImplementor session)
          Insert the persistent state of any new collection elements
 boolean isArray()
          Is the collection an array?
 boolean isCollection()
          Is this instance actually a CollectionPersister?
 boolean isInverse()
          Is this collection "inverse", so state changes are not propogated to the database.
 boolean isLazy()
          Is the collection lazily initialized?
 boolean isPrimitiveArray()
          Is the collection a primitive array?
 Object readElement(ResultSet rs, Object owner, SessionImplementor session)
          Read the element from a row of the JDBC ResultSet
 Object readIdentifier(ResultSet rs, SessionImplementor session)
          Read the identifier from a row of the JDBC ResultSet
 Object readIndex(ResultSet rs, SessionImplementor session)
          Read the index from a row of the JDBC ResultSet
 Object readKey(ResultSet rs, SessionImplementor session)
          Read the key from a row of the JDBC ResultSet
 void recreate(PersistentCollection collection, Serializable id, SessionImplementor session)
          (Re)create the collection's persistent state
 void remove(Serializable id, SessionImplementor session)
          Completely remove the persistent state of the collection
 String selectFragment(String alias)
          Generate a list of collection index, key and element columns
 String[] toColumns(String alias, String propertyName)
          Given a query alias and a property path, return the qualified column name
 String toString()
           
 Type toType(String propertyName)
          Given a component path expression, get the type of the property
 void updateRows(PersistentCollection collection, Serializable id, SessionImplementor session)
          Update the persistent state of any elements that were modified
 void writeElement(PreparedStatement st, Object elt, boolean writeOrder, SessionImplementor session)
          Write the element to a JDBC PreparedStatement
 void writeIdentifier(PreparedStatement st, Object idx, boolean writeOrder, SessionImplementor session)
          Write the identifier to a JDBC PreparedStatement
 void writeIndex(PreparedStatement st, Object idx, boolean writeOrder, SessionImplementor session)
          Write the index to a JDBC PreparedStatement
 void writeKey(PreparedStatement st, Serializable id, boolean writeOrder, SessionImplementor session)
          Write the key to a JDBC PreparedStatement
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface net.sf.hibernate.persister.Joinable
consumesAlias, fromJoinFragment, isManyToMany, selectFragment, whereJoinFragment
 
Methods inherited from interface net.sf.hibernate.collection.CollectionPersister
isOneToMany
 

Field Detail

sqlWhereString

protected final String sqlWhereString

hasWhere

protected final boolean hasWhere

elementType

protected final Type elementType

keyColumnNames

protected final String[] keyColumnNames

indexColumnNames

protected final String[] indexColumnNames

elementColumnNames

protected final String[] elementColumnNames

rowSelectColumnNames

protected final String[] rowSelectColumnNames

indexColumnAliases

protected final String[] indexColumnAliases

elementColumnAliases

protected final String[] elementColumnAliases

keyColumnAliases

protected final String[] keyColumnAliases

qualifiedTableName

protected final String qualifiedTableName

hasIndex

protected final boolean hasIndex

batchSize

protected final int batchSize

hasIdentifier

protected final boolean hasIdentifier

identifierColumnName

protected final String identifierColumnName

elementPersister

protected final ClassPersister elementPersister
Constructor Detail

AbstractCollectionPersister

public AbstractCollectionPersister(Collection collection,
                                   Configuration cfg,
                                   SessionFactoryImplementor factory)
                            throws MappingException,
                                   CacheException
Method Detail

initialize

public void initialize(Serializable key,
                       SessionImplementor session)
                throws HibernateException
Description copied from interface: CollectionPersister
Initialize the given collection with the given key

Specified by:
initialize in interface CollectionPersister
Throws:
HibernateException

createCollectionInitializer

protected abstract CollectionInitializer createCollectionInitializer(SessionFactoryImplementor factory)
                                                              throws MappingException
Throws:
MappingException

getCache

public CacheConcurrencyStrategy getCache()
Description copied from interface: CollectionPersister
Get the cache

Specified by:
getCache in interface CollectionPersister

hasCache

public boolean hasCache()
Description copied from interface: CollectionPersister
Is this collection role cacheable

Specified by:
hasCache in interface CollectionPersister

getCollectionType

public PersistentCollectionType getCollectionType()
Description copied from interface: CollectionPersister
Get the associated Type

Specified by:
getCollectionType in interface CollectionPersister

getSQLWhereString

public String getSQLWhereString(String alias)
Description copied from interface: QueryableCollection
Get the extra where clause filter SQL

Specified by:
getSQLWhereString in interface QueryableCollection

getSQLOrderByString

public String getSQLOrderByString(String alias)
Description copied from interface: QueryableCollection
Get the order by SQL

Specified by:
getSQLOrderByString in interface QueryableCollection

enableJoinedFetch

public int enableJoinedFetch()
Description copied from interface: QueryableCollection
Should we load this collection role by outerjoining?

Specified by:
enableJoinedFetch in interface QueryableCollection

hasOrdering

public boolean hasOrdering()
Description copied from interface: CollectionPersister
Is this an ordered collection? (An ordered collection is ordered by the initialization operation, not by sorting that happens in memory, as in the case of a sorted collection.)

Specified by:
hasOrdering in interface CollectionPersister

hasWhere

public boolean hasWhere()
Description copied from interface: QueryableCollection
Does this collection role have a where clause filter?

Specified by:
hasWhere in interface QueryableCollection

getSQLDeleteString

protected String getSQLDeleteString()

getSQLInsertRowString

protected String getSQLInsertRowString()

getSQLUpdateRowString

protected String getSQLUpdateRowString()

getSQLDeleteRowString

protected String getSQLDeleteRowString()

getKeyType

public Type getKeyType()
Description copied from interface: CollectionMetadata
The collection key type

Specified by:
getKeyType in interface CollectionMetadata

getIndexType

public Type getIndexType()
Description copied from interface: CollectionMetadata
The collection index type (or null if the collection has no index)

Specified by:
getIndexType in interface CollectionMetadata

getElementType

public Type getElementType()
Description copied from interface: CollectionMetadata
The collection element type

Specified by:
getElementType in interface CollectionMetadata

getElementClass

public Class getElementClass()
Return the element class of an array, or null otherwise

Specified by:
getElementClass in interface CollectionPersister

readElement

public Object readElement(ResultSet rs,
                          Object owner,
                          SessionImplementor session)
                   throws HibernateException,
                          SQLException
Description copied from interface: CollectionPersister
Read the element from a row of the JDBC ResultSet

Specified by:
readElement in interface CollectionPersister
Throws:
HibernateException
SQLException

readIndex

public Object readIndex(ResultSet rs,
                        SessionImplementor session)
                 throws HibernateException,
                        SQLException
Description copied from interface: CollectionPersister
Read the index from a row of the JDBC ResultSet

Specified by:
readIndex in interface CollectionPersister
Throws:
HibernateException
SQLException

readIdentifier

public Object readIdentifier(ResultSet rs,
                             SessionImplementor session)
                      throws HibernateException,
                             SQLException
Description copied from interface: CollectionPersister
Read the identifier from a row of the JDBC ResultSet

Specified by:
readIdentifier in interface CollectionPersister
Throws:
HibernateException
SQLException

readKey

public Object readKey(ResultSet rs,
                      SessionImplementor session)
               throws HibernateException,
                      SQLException
Description copied from interface: CollectionPersister
Read the key from a row of the JDBC ResultSet

Specified by:
readKey in interface CollectionPersister
Throws:
HibernateException
SQLException

writeElement

public void writeElement(PreparedStatement st,
                         Object elt,
                         boolean writeOrder,
                         SessionImplementor session)
                  throws HibernateException,
                         SQLException
Description copied from interface: CollectionPersister
Write the element to a JDBC PreparedStatement

Specified by:
writeElement in interface CollectionPersister
Throws:
HibernateException
SQLException

writeIndex

public void writeIndex(PreparedStatement st,
                       Object idx,
                       boolean writeOrder,
                       SessionImplementor session)
                throws HibernateException,
                       SQLException
Description copied from interface: CollectionPersister
Write the index to a JDBC PreparedStatement

Specified by:
writeIndex in interface CollectionPersister
Throws:
HibernateException
SQLException

writeIdentifier

public void writeIdentifier(PreparedStatement st,
                            Object idx,
                            boolean writeOrder,
                            SessionImplementor session)
                     throws HibernateException,
                            SQLException
Description copied from interface: CollectionPersister
Write the identifier to a JDBC PreparedStatement

Specified by:
writeIdentifier in interface CollectionPersister
Throws:
HibernateException
SQLException

writeKey

public void writeKey(PreparedStatement st,
                     Serializable id,
                     boolean writeOrder,
                     SessionImplementor session)
              throws HibernateException,
                     SQLException
Description copied from interface: CollectionPersister
Write the key to a JDBC PreparedStatement

Specified by:
writeKey in interface CollectionPersister
Throws:
HibernateException
SQLException

isPrimitiveArray

public boolean isPrimitiveArray()
Description copied from interface: CollectionMetadata
Is the collection a primitive array?

Specified by:
isPrimitiveArray in interface CollectionMetadata

isArray

public boolean isArray()
Description copied from interface: CollectionMetadata
Is the collection an array?

Specified by:
isArray in interface CollectionMetadata

selectFragment

public String selectFragment(String alias)
Generate a list of collection index, key and element columns

Specified by:
selectFragment in interface QueryableCollection

getIndexColumnNames

public String[] getIndexColumnNames()
Description copied from interface: QueryableCollection
Get the names of the collection index columnsm if this is an indexed collection (optional operation)

Specified by:
getIndexColumnNames in interface QueryableCollection

getElementColumnNames

public String[] getElementColumnNames()
Description copied from interface: QueryableCollection
Get the names of the collection element columns (or the primary key columns in the case of a one-to-many association)

Specified by:
getElementColumnNames in interface QueryableCollection

getKeyColumnNames

public String[] getKeyColumnNames()
Description copied from interface: QueryableCollection
Get the names of the collection key columns

Specified by:
getKeyColumnNames in interface QueryableCollection

hasIndex

public boolean hasIndex()
Description copied from interface: CollectionMetadata
Is this collection indexed?

Specified by:
hasIndex in interface CollectionMetadata

isLazy

public boolean isLazy()
Description copied from interface: CollectionMetadata
Is the collection lazily initialized?

Specified by:
isLazy in interface CollectionMetadata

isInverse

public boolean isInverse()
Description copied from interface: CollectionPersister
Is this collection "inverse", so state changes are not propogated to the database.

Specified by:
isInverse in interface CollectionPersister

getTableName

public String getTableName()
Description copied from interface: Joinable
The table to join to.

Specified by:
getTableName in interface Joinable

remove

public void remove(Serializable id,
                   SessionImplementor session)
            throws HibernateException
Description copied from interface: CollectionPersister
Completely remove the persistent state of the collection

Specified by:
remove in interface CollectionPersister
Throws:
HibernateException

recreate

public void recreate(PersistentCollection collection,
                     Serializable id,
                     SessionImplementor session)
              throws HibernateException
Description copied from interface: CollectionPersister
(Re)create the collection's persistent state

Specified by:
recreate in interface CollectionPersister
Throws:
HibernateException

deleteRows

public void deleteRows(PersistentCollection collection,
                       Serializable id,
                       SessionImplementor session)
                throws HibernateException
Description copied from interface: CollectionPersister
Delete the persistent state of any elements that were removed from the collection

Specified by:
deleteRows in interface CollectionPersister
Throws:
HibernateException

insertRows

public void insertRows(PersistentCollection collection,
                       Serializable id,
                       SessionImplementor session)
                throws HibernateException
Description copied from interface: CollectionPersister
Insert the persistent state of any new collection elements

Specified by:
insertRows in interface CollectionPersister
Throws:
HibernateException

getRole

public String getRole()
Description copied from interface: CollectionMetadata
The name of this collection role

Specified by:
getRole in interface CollectionMetadata

getOwnerClass

public Class getOwnerClass()
Description copied from interface: CollectionPersister
Get the entity class that "owns" this collection

Specified by:
getOwnerClass in interface CollectionPersister

getIdentifierGenerator

public IdentifierGenerator getIdentifierGenerator()
Description copied from interface: CollectionPersister
Get the surrogate key generation strategy (optional operation)

Specified by:
getIdentifierGenerator in interface CollectionPersister

getIdentifierType

public Type getIdentifierType()
Description copied from interface: CollectionPersister
Get the type of the surrogate key

Specified by:
getIdentifierType in interface CollectionPersister

hasOrphanDelete

public boolean hasOrphanDelete()
Description copied from interface: CollectionPersister
Does this collection implement "orphan delete"?

Specified by:
hasOrphanDelete in interface CollectionPersister

toType

public Type toType(String propertyName)
            throws QueryException
Description copied from interface: PropertyMapping
Given a component path expression, get the type of the property

Specified by:
toType in interface PropertyMapping
Throws:
QueryException

toColumns

public String[] toColumns(String alias,
                          String propertyName)
                   throws QueryException
Description copied from interface: PropertyMapping
Given a query alias and a property path, return the qualified column name

Specified by:
toColumns in interface PropertyMapping
Throws:
QueryException

getType

public Type getType()
Description copied from interface: PropertyMapping
Get the type of the thing containing the properties

Specified by:
getType in interface PropertyMapping

getJoinKeyColumnNames

public String[] getJoinKeyColumnNames()
Description copied from interface: Joinable
The columns to join on.

Specified by:
getJoinKeyColumnNames in interface Joinable

getName

public String getName()
Description copied from interface: Joinable
An identifying name; a class name or collection role name.

Specified by:
getName in interface Joinable

getElementPersister

public ClassPersister getElementPersister()
Description copied from interface: QueryableCollection
Get the persister of the element class, if this is a collection of entities (optional operation). Note that for a one-to-many association, the returned persister must be OuterJoinLoadable.

Specified by:
getElementPersister in interface QueryableCollection

isCollection

public boolean isCollection()
Description copied from interface: Joinable
Is this instance actually a CollectionPersister?

Specified by:
isCollection in interface Joinable

getCollectionSpace

public Serializable getCollectionSpace()
Description copied from interface: CollectionPersister
Get the "space" that holds the persistent state

Specified by:
getCollectionSpace in interface CollectionPersister

generateDeleteString

protected abstract String generateDeleteString()

generateDeleteRowString

protected abstract String generateDeleteRowString()

generateUpdateRowString

protected abstract String generateUpdateRowString()

generateInsertRowString

protected abstract String generateInsertRowString()

updateRows

public void updateRows(PersistentCollection collection,
                       Serializable id,
                       SessionImplementor session)
                throws HibernateException
Description copied from interface: CollectionPersister
Update the persistent state of any elements that were modified

Specified by:
updateRows in interface CollectionPersister
Throws:
HibernateException

doUpdateRows

protected abstract int doUpdateRows(Serializable key,
                                    PersistentCollection collection,
                                    SessionImplementor session)
                             throws HibernateException
Throws:
HibernateException

getCollectionMetadata

public CollectionMetadata getCollectionMetadata()
Specified by:
getCollectionMetadata in interface CollectionPersister

convert

protected JDBCException convert(SQLException sqlException,
                                String message)

toString

public String toString()