|
From: <one...@us...> - 2002-11-26 03:36:14
|
Update of /cvsroot/hibernate/Hibernate/cirrus/hibernate/engine
In directory sc8-pr-cvs1:/tmp/cvs-serv20166/cirrus/hibernate/engine
Modified Files:
Batcher.java Key.java SessionFactoryImplementor.java
Versioning.java
Log Message:
fixed broken line-endings and added a test
Index: Batcher.java
===================================================================
RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/engine/Batcher.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** Batcher.java 31 Oct 2002 16:58:16 -0000 1.3
--- Batcher.java 26 Nov 2002 03:35:41 -0000 1.4
***************
*** 1,62 ****
! //$Id$
! package cirrus.hibernate.engine;
!
! import java.sql.PreparedStatement;
! import java.sql.SQLException;
!
! import cirrus.hibernate.HibernateException;
!
! /**
! * Manages <tt>PreparedStatement</tt>s for a session. Abstracts JDBC
! * batching to maintain the illusion that a single logical batch
! * exists for the whole session, even when batching is disabled.
! * Provides transparent <tt>PreparedStatement</tt> caching.
! * @see java.sql.PreparedStatement
! * @see cirrus.hibernate.impl.SessionImpl
! */
! public interface Batcher {
! /**
! * Get a prepared statement for use in loading / querying. If not explicitly
! * released by <tt>closeQueryStatement()</tt>, it will be released when the
! * session is closed or disconnected.
! */
! public PreparedStatement prepareQueryStatement(String sql, boolean scrollable) throws SQLException, HibernateException;
! /**
! * Close a prepared statement opened with <tt>prepareQueryStatement()</tt>
! */
! public void closeQueryStatement(PreparedStatement ps) throws SQLException;
!
! /**
! * Get a non-batchable prepared statement to use for inserting / deleting / updating.
! * Must be explicitly released by <tt>closeStatement()</tt>
! */
! public PreparedStatement prepareStatement(String sql) throws SQLException, HibernateException;
! /**
! * Close a prepared statement opened using <tt>prepareStatement()</tt>
! */
! public void closeStatement(PreparedStatement ps) throws SQLException;
! /**
! * Get a batchable prepared statement to use for inserting / deleting / updating
! * (might be called many times before a single call to <tt>executeBatch()</tt>).
! * After setting parameters, call <tt>addToBatch</tt> - do not execute the
! * statement explicitly.
! * @see Batcher#addToBatch(int)
! */
! public PreparedStatement prepareBatchStatement(String sql) throws SQLException, HibernateException;
! /**
! * Add an insert / delete / update to the current batch (might be called multiple times
! * for single <tt>prepareBatchStatement()</tt>)
! */
! public void addToBatch(int expectedRowCount) throws SQLException, HibernateException;
!
! /**
! * Execute the batch
! */
! public void executeBatch() throws SQLException, HibernateException;
!
! /**
! * Close any query statements that were left lying around
! */
! public void closeStatements();
!
! }
--- 1,62 ----
! //$Id$
! package cirrus.hibernate.engine;
!
! import java.sql.PreparedStatement;
! import java.sql.SQLException;
!
! import cirrus.hibernate.HibernateException;
!
! /**
! * Manages <tt>PreparedStatement</tt>s for a session. Abstracts JDBC
! * batching to maintain the illusion that a single logical batch
! * exists for the whole session, even when batching is disabled.
! * Provides transparent <tt>PreparedStatement</tt> caching.
! * @see java.sql.PreparedStatement
! * @see cirrus.hibernate.impl.SessionImpl
! */
! public interface Batcher {
! /**
! * Get a prepared statement for use in loading / querying. If not explicitly
! * released by <tt>closeQueryStatement()</tt>, it will be released when the
! * session is closed or disconnected.
! */
! public PreparedStatement prepareQueryStatement(String sql, boolean scrollable) throws SQLException, HibernateException;
! /**
! * Close a prepared statement opened with <tt>prepareQueryStatement()</tt>
! */
! public void closeQueryStatement(PreparedStatement ps) throws SQLException;
!
! /**
! * Get a non-batchable prepared statement to use for inserting / deleting / updating.
! * Must be explicitly released by <tt>closeStatement()</tt>
! */
! public PreparedStatement prepareStatement(String sql) throws SQLException, HibernateException;
! /**
! * Close a prepared statement opened using <tt>prepareStatement()</tt>
! */
! public void closeStatement(PreparedStatement ps) throws SQLException;
! /**
! * Get a batchable prepared statement to use for inserting / deleting / updating
! * (might be called many times before a single call to <tt>executeBatch()</tt>).
! * After setting parameters, call <tt>addToBatch</tt> - do not execute the
! * statement explicitly.
! * @see Batcher#addToBatch(int)
! */
! public PreparedStatement prepareBatchStatement(String sql) throws SQLException, HibernateException;
! /**
! * Add an insert / delete / update to the current batch (might be called multiple times
! * for single <tt>prepareBatchStatement()</tt>)
! */
! public void addToBatch(int expectedRowCount) throws SQLException, HibernateException;
!
! /**
! * Execute the batch
! */
! public void executeBatch() throws SQLException, HibernateException;
!
! /**
! * Close any query statements that were left lying around
! */
! public void closeStatements();
!
! }
Index: Key.java
===================================================================
RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/engine/Key.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** Key.java 5 Nov 2002 06:46:06 -0000 1.2
--- Key.java 26 Nov 2002 03:35:41 -0000 1.3
***************
*** 1,49 ****
! //$Id$
! package cirrus.hibernate.engine;
!
! import java.io.Serializable;
!
! import cirrus.hibernate.impl.CollectionPersister;
! import cirrus.hibernate.persister.ClassPersister;
!
! /**
! * A globally unique identifier of an instance, consisting of the
! * user-visible identifier and the identifier space (eg. tablename).
! */
! public final class Key implements Serializable {
! private final Serializable id;
! private final Serializable identifierSpace;
!
! private Key(Serializable id, Serializable identifierSpace) {
! this.id=id;
! this.identifierSpace = identifierSpace;
! }
!
! /**
! * Construct a unique identifier for an entity class instance
! */
! public Key(Serializable id, ClassPersister p) {
! this( id, p.getIdentifierSpace() );
! }
!
! /**
! * Construct a unique identifier for a collection instance
! */
! public Key(Serializable id, CollectionPersister p) {
! this( id, p.getQualifiedTableName() );
! }
!
! /**
! * Get the user-visible identifier
! */
! public Serializable getIdentifier() {
! return id;
! }
!
! public boolean equals(Object other) {
! Key otherKey = (Key) other;
! return otherKey.identifierSpace.equals(this.identifierSpace) && otherKey.id.equals(this.id);
! }
!
! public int hashCode() { return id.hashCode(); }
! }
--- 1,49 ----
! //$Id$
! package cirrus.hibernate.engine;
!
! import java.io.Serializable;
!
! import cirrus.hibernate.impl.CollectionPersister;
! import cirrus.hibernate.persister.ClassPersister;
!
! /**
! * A globally unique identifier of an instance, consisting of the
! * user-visible identifier and the identifier space (eg. tablename).
! */
! public final class Key implements Serializable {
! private final Serializable id;
! private final Serializable identifierSpace;
!
! private Key(Serializable id, Serializable identifierSpace) {
! this.id=id;
! this.identifierSpace = identifierSpace;
! }
!
! /**
! * Construct a unique identifier for an entity class instance
! */
! public Key(Serializable id, ClassPersister p) {
! this( id, p.getIdentifierSpace() );
! }
!
! /**
! * Construct a unique identifier for a collection instance
! */
! public Key(Serializable id, CollectionPersister p) {
! this( id, p.getQualifiedTableName() );
! }
!
! /**
! * Get the user-visible identifier
! */
! public Serializable getIdentifier() {
! return id;
! }
!
! public boolean equals(Object other) {
! Key otherKey = (Key) other;
! return otherKey.identifierSpace.equals(this.identifierSpace) && otherKey.id.equals(this.id);
! }
!
! public int hashCode() { return id.hashCode(); }
! }
Index: SessionFactoryImplementor.java
===================================================================
RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/engine/SessionFactoryImplementor.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** SessionFactoryImplementor.java 31 Oct 2002 16:58:20 -0000 1.4
--- SessionFactoryImplementor.java 26 Nov 2002 03:35:41 -0000 1.5
***************
*** 1,92 ****
! //$Id$
! package cirrus.hibernate.engine;
!
! import java.sql.Connection;
! import java.sql.PreparedStatement;
! import java.sql.SQLException;
!
! import cirrus.hibernate.HibernateException;
! import cirrus.hibernate.MappingException;
! import cirrus.hibernate.impl.CollectionPersister;
! import cirrus.hibernate.persister.ClassPersister;
! import cirrus.hibernate.sql.Dialect;
! import cirrus.hibernate.type.Type;
!
! /**
! * Defines the internal contract between the <tt>SessionFactory</tt> and other parts of
! * Hibernate such as implementors of <tt>Type</tt>.
! * @see cirrus.hibernate.SessionFactory
! * @see cirrus.hibernate.impl.SessionFactoryImpl
! */
! public interface SessionFactoryImplementor extends Mapping {
! /**
! * Get the persister for a class
! */
public ClassPersister getPersister(Class clazz) throws MappingException;
! /**
! * Get the persister for the named class
! */
! public ClassPersister getPersister(String className) throws MappingException;
! /**
! * Get the persister object for a collection role
! */
! public CollectionPersister getCollectionPersister(String role) throws MappingException;
!
! /**
! * Is outerjoin fetching enabled?
! */
! public boolean enableJoinedFetch();
! /**
! * Are scrollable <tt>ResultSet</tt>s supported?
! */
! public boolean useScrollableResultSets();
! /**
! * Get the database schema specified in <tt>hibernate.default_schema</tt>
! */
public String getDefaultSchema();
! /**
! * Get the SQL <tt>Dialect</tt>
! */
! public Dialect getDialect();
!
! /**
! * Get the return types of a query
! */
! public Type[] getReturnTypes(String queryString) throws HibernateException;
!
! /**
! * Obtain a JDBC connection
! */
! public Connection openConnection() throws SQLException;
! /**
! * Release a JDBC connection
! */
! public void closeConnection(Connection conn) throws SQLException;
! /**
! * Get the names of all persistent classes that implement/extend the given interface/class
! */
! public String[] getImplementors(Class clazz);
! /**
! * Get the list of query imports
! */
! public String[] getImports();
!
! /**
! * Dispose of a prepared statement
! */
! public void closePreparedStatement(PreparedStatement ps) throws SQLException;
!
! /**
! * Obtain a prepared statement
! */
! public PreparedStatement getPreparedStatement(final Connection conn, final String sql, boolean scrollable) throws SQLException;
!
! /**
! * Get the JDBC batch size
! */
! public int getJdbcBatchSize();
!
! /**
! * Set the fetch size
! */
! public void setFetchSize(PreparedStatement statement) throws SQLException;
! }
--- 1,92 ----
! //$Id$
! package cirrus.hibernate.engine;
!
! import java.sql.Connection;
! import java.sql.PreparedStatement;
! import java.sql.SQLException;
!
! import cirrus.hibernate.HibernateException;
! import cirrus.hibernate.MappingException;
! import cirrus.hibernate.impl.CollectionPersister;
! import cirrus.hibernate.persister.ClassPersister;
! import cirrus.hibernate.sql.Dialect;
! import cirrus.hibernate.type.Type;
!
! /**
! * Defines the internal contract between the <tt>SessionFactory</tt> and other parts of
! * Hibernate such as implementors of <tt>Type</tt>.
! * @see cirrus.hibernate.SessionFactory
! * @see cirrus.hibernate.impl.SessionFactoryImpl
! */
! public interface SessionFactoryImplementor extends Mapping {
! /**
! * Get the persister for a class
! */
public ClassPersister getPersister(Class clazz) throws MappingException;
! /**
! * Get the persister for the named class
! */
! public ClassPersister getPersister(String className) throws MappingException;
! /**
! * Get the persister object for a collection role
! */
! public CollectionPersister getCollectionPersister(String role) throws MappingException;
!
! /**
! * Is outerjoin fetching enabled?
! */
! public boolean enableJoinedFetch();
! /**
! * Are scrollable <tt>ResultSet</tt>s supported?
! */
! public boolean useScrollableResultSets();
! /**
! * Get the database schema specified in <tt>hibernate.default_schema</tt>
! */
public String getDefaultSchema();
! /**
! * Get the SQL <tt>Dialect</tt>
! */
! public Dialect getDialect();
!
! /**
! * Get the return types of a query
! */
! public Type[] getReturnTypes(String queryString) throws HibernateException;
!
! /**
! * Obtain a JDBC connection
! */
! public Connection openConnection() throws SQLException;
! /**
! * Release a JDBC connection
! */
! public void closeConnection(Connection conn) throws SQLException;
! /**
! * Get the names of all persistent classes that implement/extend the given interface/class
! */
! public String[] getImplementors(Class clazz);
! /**
! * Get the list of query imports
! */
! public String[] getImports();
!
! /**
! * Dispose of a prepared statement
! */
! public void closePreparedStatement(PreparedStatement ps) throws SQLException;
!
! /**
! * Obtain a prepared statement
! */
! public PreparedStatement getPreparedStatement(final Connection conn, final String sql, boolean scrollable) throws SQLException;
!
! /**
! * Get the JDBC batch size
! */
! public int getJdbcBatchSize();
!
! /**
! * Set the fetch size
! */
! public void setFetchSize(PreparedStatement statement) throws SQLException;
! }
Index: Versioning.java
===================================================================
RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/engine/Versioning.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** Versioning.java 1 Oct 2002 01:25:29 -0000 1.1
--- Versioning.java 26 Nov 2002 03:35:41 -0000 1.2
***************
*** 1,71 ****
! //$Id$
! package cirrus.hibernate.engine;
!
! import org.apache.commons.logging.Log;
! import org.apache.commons.logging.LogFactory;
!
! import cirrus.hibernate.HibernateException;
! import cirrus.hibernate.persister.ClassPersister;
! import cirrus.hibernate.type.VersionType;
!
! /**
! * Utility methods for managing versions and timestamps
! */
! public final class Versioning {
!
! private static final Log log = LogFactory.getLog(Versioning.class);
!
! /**
! * Increment the given version number
! */
! public static Object increment(Object version, VersionType versionType) {
! Object next = versionType.next(version);
! if ( log.isTraceEnabled() ) log.trace("Incrementing: " + version + " to " + next);
! return next;
! }
!
! /**
! * Create an initial version number
! */
! private static Object seed(VersionType versionType) {
! Object seed = versionType.seed();
! if ( log.isTraceEnabled() ) log.trace("Seeding: " + seed);
! return seed;
! }
!
! /**
! * Seed the given instance state snapshot with an initial version number
! */
! public static boolean seedVersion(Object[] fields, int versionProperty, VersionType versionType) {
! if ( fields[versionProperty]==null ) {
! fields[versionProperty] = seed(versionType);
! return true;
! }
! else {
! return false;
! }
! }
!
! private static Object getVersion(Object[] fields, int versionProperty, VersionType versionType) throws HibernateException {
! return fields[versionProperty];
! }
!
! private static void setVersion(Object[] fields, Object version, int versionProperty, VersionType versionType) throws HibernateException {
! fields[versionProperty] = version;
! }
!
! /**
! * Set the version number of the given instance state snapshot
! */
! public static void setVersion(Object[] fields, Object version, ClassPersister persister) throws HibernateException {
! setVersion( fields, version, persister.getVersionProperty(), persister.getVersionType() );
! }
!
! /**
! * Get the version number of the given instance state snapshot
! */
! public static Object getVersion(Object[] fields, ClassPersister persister) throws HibernateException {
! return persister.isVersioned() ? getVersion( fields, persister.getVersionProperty(), persister.getVersionType() ) : null;
! }
!
! }
--- 1,71 ----
! //$Id$
! package cirrus.hibernate.engine;
!
! import org.apache.commons.logging.Log;
! import org.apache.commons.logging.LogFactory;
!
! import cirrus.hibernate.HibernateException;
! import cirrus.hibernate.persister.ClassPersister;
! import cirrus.hibernate.type.VersionType;
!
! /**
! * Utility methods for managing versions and timestamps
! */
! public final class Versioning {
!
! private static final Log log = LogFactory.getLog(Versioning.class);
!
! /**
! * Increment the given version number
! */
! public static Object increment(Object version, VersionType versionType) {
! Object next = versionType.next(version);
! if ( log.isTraceEnabled() ) log.trace("Incrementing: " + version + " to " + next);
! return next;
! }
!
! /**
! * Create an initial version number
! */
! private static Object seed(VersionType versionType) {
! Object seed = versionType.seed();
! if ( log.isTraceEnabled() ) log.trace("Seeding: " + seed);
! return seed;
! }
!
! /**
! * Seed the given instance state snapshot with an initial version number
! */
! public static boolean seedVersion(Object[] fields, int versionProperty, VersionType versionType) {
! if ( fields[versionProperty]==null ) {
! fields[versionProperty] = seed(versionType);
! return true;
! }
! else {
! return false;
! }
! }
!
! private static Object getVersion(Object[] fields, int versionProperty, VersionType versionType) throws HibernateException {
! return fields[versionProperty];
! }
!
! private static void setVersion(Object[] fields, Object version, int versionProperty, VersionType versionType) throws HibernateException {
! fields[versionProperty] = version;
! }
!
! /**
! * Set the version number of the given instance state snapshot
! */
! public static void setVersion(Object[] fields, Object version, ClassPersister persister) throws HibernateException {
! setVersion( fields, version, persister.getVersionProperty(), persister.getVersionType() );
! }
!
! /**
! * Get the version number of the given instance state snapshot
! */
! public static Object getVersion(Object[] fields, ClassPersister persister) throws HibernateException {
! return persister.isVersioned() ? getVersion( fields, persister.getVersionProperty(), persister.getVersionType() ) : null;
! }
!
! }
|