Update of /cvsroot/hibernate/Hibernate/cirrus/hibernate In directory sc8-pr-cvs1:/tmp/cvs-serv20166/cirrus/hibernate Modified Files: Interceptor.java LockMode.java QueryException.java ScrollableResults.java Validatable.java ValidationFailure.java Log Message: fixed broken line-endings and added a test Index: Interceptor.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/Interceptor.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** Interceptor.java 18 Oct 2002 11:02:19 -0000 1.2 --- Interceptor.java 26 Nov 2002 03:35:40 -0000 1.3 *************** *** 1,64 **** ! //$Id$ ! package cirrus.hibernate; ! ! import java.io.Serializable; ! import java.util.Iterator; ! ! import cirrus.hibernate.type.Type; ! ! /** ! * Allows user code to inspect and / or change property values before they are written and after they are read ! * from the database.<br> ! * <br> ! * There might be a single instance of <tt>Interceptor</tt> for a <tt>SessionFactory</tt>, or a new instance ! * might be specified for each <tt>Session</tt>. Whichever approach is used, the interceptor must be ! * serializable if the <tt>Session</tt> is to be serializable. This means that <tt>SessionFactory</tt>-scoped ! * interceptors should implement <tt>readResolve()</tt>.<br> ! * <br> ! * The <tt>Session</tt> may not be invoked from a callback (nor may a callback cause a collection or proxy to ! * be lazily initialized).<br> ! * ! * @see SessionFactory#openSession(Interceptor) ! * @see Datastore#buildSessionFactory(Interceptor) ! */ ! public interface Interceptor { ! /** ! * Called just before an object is initialized. The interceptor may change the <tt>state</tt>, which will ! * be propagated to the persistent object. Note that when this method is called, <tt>entity</tt> will be ! * an empty uninitialized instance of the class. ! * ! * @return <tt>true</tt> if the user modified the <tt>state</tt> in any way. ! */ ! public boolean onLoad(Object entity, Serializable id, Object[] state, String[] propertyNames, Type[] types); ! /** ! * Called when an object is detected to be dirty, during a flush. The interceptor may modify the detected ! * <tt>currentState</tt>, which will be propagated to both the database and the persistent object. ! * Note that not all flushes end in actual synchronization with the database, in which case the ! * new <tt>currentState</tt> will be propagated to the object, but not necessarily (immediately) to ! * the database. It is strongly recommended that the interceptor <b>not</b> modify the <tt>previousState</tt>. ! * ! * @return <tt>true</tt> if the user modified the <tt>currentState</tt> in any way. ! */ ! public boolean onFlushDirty(Object entity, Serializable id, Object[] currentState, Object[] previousState, String[] propertyNames, Type[] types); ! //public void onPostFlush(Object entity, Serializable id, Object[] currentState, String[] propertyNames, Type[] types); ! /** ! * Called before an object is saved. The interceptor may modify the <tt>state</tt>, which will be used for ! * the SQL <tt>INSERT</tt> and propagated to the persistent object. ! * ! * @return <tt>true</tt> if the user modified the <tt>state</tt> in any way. ! */ ! public boolean onSave(Object entity, Serializable id, Object[] state, String[] propertyNames, Type[] types); ! /** ! * Called before an object is deleted. It is not recommended that the interceptor modify the <tt>state</tt>. ! */ ! public void onDelete(Object entity, Serializable id, Object[] state, String[] propertyNames, Type[] types); ! /** ! * Called before a flush ! */ ! public void preFlush(Iterator entities); ! /** ! * Called after a flush that actually ends in execution of the SQL statements required to synchronize ! * in-memory state with the database. ! */ ! public void postFlush(Iterator entities); ! } --- 1,64 ---- ! //$Id$ ! package cirrus.hibernate; ! ! import java.io.Serializable; ! import java.util.Iterator; ! ! import cirrus.hibernate.type.Type; ! ! /** ! * Allows user code to inspect and / or change property values before they are written and after they are read ! * from the database.<br> ! * <br> ! * There might be a single instance of <tt>Interceptor</tt> for a <tt>SessionFactory</tt>, or a new instance ! * might be specified for each <tt>Session</tt>. Whichever approach is used, the interceptor must be ! * serializable if the <tt>Session</tt> is to be serializable. This means that <tt>SessionFactory</tt>-scoped ! * interceptors should implement <tt>readResolve()</tt>.<br> ! * <br> ! * The <tt>Session</tt> may not be invoked from a callback (nor may a callback cause a collection or proxy to ! * be lazily initialized).<br> ! * ! * @see SessionFactory#openSession(Interceptor) ! * @see Datastore#buildSessionFactory(Interceptor) ! */ ! public interface Interceptor { ! /** ! * Called just before an object is initialized. The interceptor may change the <tt>state</tt>, which will ! * be propagated to the persistent object. Note that when this method is called, <tt>entity</tt> will be ! * an empty uninitialized instance of the class. ! * ! * @return <tt>true</tt> if the user modified the <tt>state</tt> in any way. ! */ ! public boolean onLoad(Object entity, Serializable id, Object[] state, String[] propertyNames, Type[] types); ! /** ! * Called when an object is detected to be dirty, during a flush. The interceptor may modify the detected ! * <tt>currentState</tt>, which will be propagated to both the database and the persistent object. ! * Note that not all flushes end in actual synchronization with the database, in which case the ! * new <tt>currentState</tt> will be propagated to the object, but not necessarily (immediately) to ! * the database. It is strongly recommended that the interceptor <b>not</b> modify the <tt>previousState</tt>. ! * ! * @return <tt>true</tt> if the user modified the <tt>currentState</tt> in any way. ! */ ! public boolean onFlushDirty(Object entity, Serializable id, Object[] currentState, Object[] previousState, String[] propertyNames, Type[] types); ! //public void onPostFlush(Object entity, Serializable id, Object[] currentState, String[] propertyNames, Type[] types); ! /** ! * Called before an object is saved. The interceptor may modify the <tt>state</tt>, which will be used for ! * the SQL <tt>INSERT</tt> and propagated to the persistent object. ! * ! * @return <tt>true</tt> if the user modified the <tt>state</tt> in any way. ! */ ! public boolean onSave(Object entity, Serializable id, Object[] state, String[] propertyNames, Type[] types); ! /** ! * Called before an object is deleted. It is not recommended that the interceptor modify the <tt>state</tt>. ! */ ! public void onDelete(Object entity, Serializable id, Object[] state, String[] propertyNames, Type[] types); ! /** ! * Called before a flush ! */ ! public void preFlush(Iterator entities); ! /** ! * Called after a flush that actually ends in execution of the SQL statements required to synchronize ! * in-memory state with the database. ! */ ! public void postFlush(Iterator entities); ! } Index: LockMode.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/LockMode.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** LockMode.java 3 Oct 2002 05:53:02 -0000 1.4 --- LockMode.java 26 Nov 2002 03:35:40 -0000 1.5 *************** *** 1,67 **** ! //$Id$ ! package cirrus.hibernate; ! ! import java.io.Serializable; ! ! /** ! * Instances represent a lock mode for a row of a relational ! * database table. It is not intended that users spend much ! * time worrying about locking since Hibernate usually ! * obtains exactly the right lock level automatically. ! * Some "advanced" users may wish to explicitly specify lock ! * levels. ! * ! * @see Session#lock(Object,LockMode) ! */ ! public final class LockMode implements Serializable { ! private final int level; ! private final String name; ! private LockMode(int level, String name) { ! this.level=level; ! this.name=name; ! } ! public String toString() { ! return name; ! } ! /** ! * Is this lock mode more restrictive than the given lock mode? ! */ ! public boolean greaterThan(LockMode mode) { ! return level > mode.level; ! } ! /** ! * Is this lock mode less restrictive than the given lock mode? ! */ ! public boolean lessThan(LockMode mode) { ! return level < mode.level; ! } ! /** ! * No lock required. If an object is requested with this lock ! * mode, a <tt>READ</tt> lock might be obtained if necessary. ! */ ! public static final LockMode NONE = new LockMode(0, "NONE"); ! /** ! * A shared lock. Objects are loaded in <tt>READ</tt> mode ! * by default. ! */ ! public static final LockMode READ = new LockMode(5, "READ"); ! /** ! * An upgrade lock. Objects loaded in this lock mode are ! * materialized using an SQL <tt>select ... for update</tt>. ! */ ! public static final LockMode UPGRADE = new LockMode(10, "UPGRADE"); ! /** ! * Attempt to obtain an upgrade lock, using an Oracle-style ! * <tt>select ... for update nowait</tt>. The semantics of ! * this lock mode, once obtained, are the same as ! * <tt>UPGRADE</tt>.<br> ! */ ! public static final LockMode UPGRADE_NOWAIT = new LockMode(10, "UPGRADE_NOWAIT"); ! /** ! * A <tt>WRITE</tt> lock is obtained when an object is updated ! * or inserted. This is not a valid mode for <tt>load()</tt> ! * or <tt>lock()</tt>. ! */ ! public static final LockMode WRITE = new LockMode(10, "WRITE"); ! ! } --- 1,67 ---- ! //$Id$ ! package cirrus.hibernate; ! ! import java.io.Serializable; ! ! /** ! * Instances represent a lock mode for a row of a relational ! * database table. It is not intended that users spend much ! * time worrying about locking since Hibernate usually ! * obtains exactly the right lock level automatically. ! * Some "advanced" users may wish to explicitly specify lock ! * levels. ! * ! * @see Session#lock(Object,LockMode) ! */ ! public final class LockMode implements Serializable { ! private final int level; ! private final String name; ! private LockMode(int level, String name) { ! this.level=level; ! this.name=name; ! } ! public String toString() { ! return name; ! } ! /** ! * Is this lock mode more restrictive than the given lock mode? ! */ ! public boolean greaterThan(LockMode mode) { ! return level > mode.level; ! } ! /** ! * Is this lock mode less restrictive than the given lock mode? ! */ ! public boolean lessThan(LockMode mode) { ! return level < mode.level; ! } ! /** ! * No lock required. If an object is requested with this lock ! * mode, a <tt>READ</tt> lock might be obtained if necessary. ! */ ! public static final LockMode NONE = new LockMode(0, "NONE"); ! /** ! * A shared lock. Objects are loaded in <tt>READ</tt> mode ! * by default. ! */ ! public static final LockMode READ = new LockMode(5, "READ"); ! /** ! * An upgrade lock. Objects loaded in this lock mode are ! * materialized using an SQL <tt>select ... for update</tt>. ! */ ! public static final LockMode UPGRADE = new LockMode(10, "UPGRADE"); ! /** ! * Attempt to obtain an upgrade lock, using an Oracle-style ! * <tt>select ... for update nowait</tt>. The semantics of ! * this lock mode, once obtained, are the same as ! * <tt>UPGRADE</tt>.<br> ! */ ! public static final LockMode UPGRADE_NOWAIT = new LockMode(10, "UPGRADE_NOWAIT"); ! /** ! * A <tt>WRITE</tt> lock is obtained when an object is updated ! * or inserted. This is not a valid mode for <tt>load()</tt> ! * or <tt>lock()</tt>. ! */ ! public static final LockMode WRITE = new LockMode(10, "WRITE"); ! ! } Index: QueryException.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/QueryException.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** QueryException.java 28 Oct 2002 15:41:53 -0000 1.3 --- QueryException.java 26 Nov 2002 03:35:40 -0000 1.4 *************** *** 31,33 **** } ! --- 31,33 ---- } ! Index: ScrollableResults.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/ScrollableResults.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** ScrollableResults.java 21 Nov 2002 09:03:09 -0000 1.5 --- ScrollableResults.java 26 Nov 2002 03:35:40 -0000 1.6 *************** *** 1,153 **** ! //$Id$ ! package cirrus.hibernate; ! ! import java.math.BigDecimal; ! import java.sql.SQLException; ! import java.util.Calendar; ! import java.util.Date; ! import java.util.Locale; ! import java.util.TimeZone; ! ! import cirrus.hibernate.type.Type; ! ! /** ! * A result iterator that allows moving around within the results ! * by arbitrary increments. The <tt>Query</tt> / <tt>ScrollableResults</tt> ! * pattern is very similar to the JDBC <tt>PreparedStatement</tt>/ ! * <tt>ResultSet</tt> pattern and the semantics of methods of this interface ! * are similar to the similarly named methods on <tt>ResultSet</tt>.<br> ! * <br> ! * Contrary to JDBC, columns of results are numbered from zero. ! * ! * @see Query#scroll() ! */ ! public interface ScrollableResults { ! /** ! * Advance to the next result ! * @param i ! * @return <tt>true</tt> if there is another result ! */ ! public boolean next() throws SQLException, HibernateException; ! /** ! * Retreat to the previous result ! * @param i ! * @return <tt>true</tt> if there is a previous result ! */ ! public boolean previous() throws SQLException, HibernateException; ! /** ! * Scroll an arbitrary number of locations ! * @param i a positive (forward) or negative (backward) number of rows ! * @return <tt>true</tt> if there is a result at the new location ! */ ! public boolean scroll(int i) throws SQLException, HibernateException; ! /** ! * Go to the last result ! * @return <tt>true</tt> if there are any results ! */ ! public boolean last() throws SQLException, HibernateException; ! /** ! * Go to the first result ! * @return <tt>true</tt> if there are any results ! */ ! public boolean first() throws SQLException, HibernateException; ! /** ! * Go to a location just before first result (this is the initial location) ! * @return <tt>true</tt> if there are any results ! */ ! public void beforeFirst() throws SQLException, HibernateException; ! /** ! * Go to a location just after the last result ! * @return <tt>true</tt> if there are any results ! */ ! public void afterLast() throws SQLException, HibernateException; ! /** ! * Release resources immediately. ! */ ! public void close() throws SQLException, HibernateException; ! /** ! * Get the current row of results ! * @return an object or array ! */ ! public Object[] get() throws SQLException, HibernateException; ! /** ! * Get the <tt>i</tt>th object in the current row of results, without ! * initializing any other results in the row. This method may be used ! * safely, regardless of the type of the column (ie. even for scalar ! * results). ! * @param i the column, numbered from zero ! * @return an object of any Hibernate type or <tt>null</tt> ! */ ! public Object get(int i) throws SQLException, HibernateException; ! ! /** ! * Get the type of the <tt>i</tt>th column of results ! * @param i the column, numbered from zero ! * @return the Hibernate type ! */ ! public Type getType(int i); ! ! /** ! * Convenience method to read an integer ! */ ! public Integer getInteger(int col) throws SQLException, HibernateException; ! /** ! * Convenience method to read a long ! */ ! public Long getLong(int col) throws SQLException, HibernateException; ! /** ! * Convenience method to read a float ! */ ! public Float getFloat(int col) throws SQLException, HibernateException; ! /** ! * Convenience method to read a boolean ! */ ! public Boolean getBoolean(int col) throws SQLException, HibernateException; ! /** ! * Convenience method to read a double ! */ ! public Double getDouble(int col) throws SQLException, HibernateException; ! /** ! * Convenience method to read a short ! */ ! public Short getShort(int col) throws SQLException, HibernateException; ! /** ! * Convenience method to read a byte ! */ ! public Byte getByte(int col) throws SQLException, HibernateException; ! /** ! * Convenience method to read a character ! */ ! public Character getCharacter(int col) throws SQLException, HibernateException; ! /** ! * Convenience method to read a binary ! */ ! public byte[] getBinary(int col) throws SQLException, HibernateException; ! /** ! * Convenience method to read a string ! */ ! public String getString(int col) throws SQLException, HibernateException; ! /** ! * Convenience method to read a big_decimal ! */ ! public BigDecimal getBigDecimal(int col) throws SQLException, HibernateException; ! /** ! * Convenience method to read a date, time or timestamp ! */ ! public Date getDate(int col) throws SQLException, HibernateException; ! /** ! * Convenience method to read a locale ! */ ! public Locale getLocale(int col) throws SQLException, HibernateException; ! /** ! * Convenience method to read a calendar or calendar date ! */ ! public Calendar getCalendar(int col) throws SQLException, HibernateException; ! /** ! * Convenience method to read a currency ! */ ! //public Currency getCurrency(int col) throws SQLException, HibernateException; ! /** ! * Convenience method to read a timezone ! */ ! public TimeZone getTimeZone(int col) throws SQLException, HibernateException; ! } --- 1,153 ---- ! //$Id$ ! package cirrus.hibernate; ! ! import java.math.BigDecimal; ! import java.sql.SQLException; ! import java.util.Calendar; ! import java.util.Date; ! import java.util.Locale; ! import java.util.TimeZone; ! ! import cirrus.hibernate.type.Type; ! ! /** ! * A result iterator that allows moving around within the results ! * by arbitrary increments. The <tt>Query</tt> / <tt>ScrollableResults</tt> ! * pattern is very similar to the JDBC <tt>PreparedStatement</tt>/ ! * <tt>ResultSet</tt> pattern and the semantics of methods of this interface ! * are similar to the similarly named methods on <tt>ResultSet</tt>.<br> ! * <br> ! * Contrary to JDBC, columns of results are numbered from zero. ! * ! * @see Query#scroll() ! */ ! public interface ScrollableResults { ! /** ! * Advance to the next result ! * @param i ! * @return <tt>true</tt> if there is another result ! */ ! public boolean next() throws SQLException, HibernateException; ! /** ! * Retreat to the previous result ! * @param i ! * @return <tt>true</tt> if there is a previous result ! */ ! public boolean previous() throws SQLException, HibernateException; ! /** ! * Scroll an arbitrary number of locations ! * @param i a positive (forward) or negative (backward) number of rows ! * @return <tt>true</tt> if there is a result at the new location ! */ ! public boolean scroll(int i) throws SQLException, HibernateException; ! /** ! * Go to the last result ! * @return <tt>true</tt> if there are any results ! */ ! public boolean last() throws SQLException, HibernateException; ! /** ! * Go to the first result ! * @return <tt>true</tt> if there are any results ! */ ! public boolean first() throws SQLException, HibernateException; ! /** ! * Go to a location just before first result (this is the initial location) ! * @return <tt>true</tt> if there are any results ! */ ! public void beforeFirst() throws SQLException, HibernateException; ! /** ! * Go to a location just after the last result ! * @return <tt>true</tt> if there are any results ! */ ! public void afterLast() throws SQLException, HibernateException; ! /** ! * Release resources immediately. ! */ ! public void close() throws SQLException, HibernateException; ! /** ! * Get the current row of results ! * @return an object or array ! */ ! public Object[] get() throws SQLException, HibernateException; ! /** ! * Get the <tt>i</tt>th object in the current row of results, without ! * initializing any other results in the row. This method may be used ! * safely, regardless of the type of the column (ie. even for scalar ! * results). ! * @param i the column, numbered from zero ! * @return an object of any Hibernate type or <tt>null</tt> ! */ ! public Object get(int i) throws SQLException, HibernateException; ! ! /** ! * Get the type of the <tt>i</tt>th column of results ! * @param i the column, numbered from zero ! * @return the Hibernate type ! */ ! public Type getType(int i); ! ! /** ! * Convenience method to read an integer ! */ ! public Integer getInteger(int col) throws SQLException, HibernateException; ! /** ! * Convenience method to read a long ! */ ! public Long getLong(int col) throws SQLException, HibernateException; ! /** ! * Convenience method to read a float ! */ ! public Float getFloat(int col) throws SQLException, HibernateException; ! /** ! * Convenience method to read a boolean ! */ ! public Boolean getBoolean(int col) throws SQLException, HibernateException; ! /** ! * Convenience method to read a double ! */ ! public Double getDouble(int col) throws SQLException, HibernateException; ! /** ! * Convenience method to read a short ! */ ! public Short getShort(int col) throws SQLException, HibernateException; ! /** ! * Convenience method to read a byte ! */ ! public Byte getByte(int col) throws SQLException, HibernateException; ! /** ! * Convenience method to read a character ! */ ! public Character getCharacter(int col) throws SQLException, HibernateException; ! /** ! * Convenience method to read a binary ! */ ! public byte[] getBinary(int col) throws SQLException, HibernateException; ! /** ! * Convenience method to read a string ! */ ! public String getString(int col) throws SQLException, HibernateException; ! /** ! * Convenience method to read a big_decimal ! */ ! public BigDecimal getBigDecimal(int col) throws SQLException, HibernateException; ! /** ! * Convenience method to read a date, time or timestamp ! */ ! public Date getDate(int col) throws SQLException, HibernateException; ! /** ! * Convenience method to read a locale ! */ ! public Locale getLocale(int col) throws SQLException, HibernateException; ! /** ! * Convenience method to read a calendar or calendar date ! */ ! public Calendar getCalendar(int col) throws SQLException, HibernateException; ! /** ! * Convenience method to read a currency ! */ ! //public Currency getCurrency(int col) throws SQLException, HibernateException; ! /** ! * Convenience method to read a timezone ! */ ! public TimeZone getTimeZone(int col) throws SQLException, HibernateException; ! } Index: Validatable.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/Validatable.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** Validatable.java 3 Sep 2002 02:10:02 -0000 1.1 --- Validatable.java 26 Nov 2002 03:35:40 -0000 1.2 *************** *** 1,17 **** ! //$Id$ ! package cirrus.hibernate; ! ! /** ! * Implemented by persistent classes with invariants that must ! * be checked before inserting into or updating the database. ! */ ! public interface Validatable { ! /** ! * Validate the state of the object before persisting it. ! * If a violation occurs, throw a <tt>ValidationFailure</tt>. ! * This method must not change the state of the object by ! * side-effect. ! * @throws ValidationFailure if an invariant is violated ! */ ! public void validate() throws ValidationFailure; ! } --- 1,17 ---- ! //$Id$ ! package cirrus.hibernate; ! ! /** ! * Implemented by persistent classes with invariants that must ! * be checked before inserting into or updating the database. ! */ ! public interface Validatable { ! /** ! * Validate the state of the object before persisting it. ! * If a violation occurs, throw a <tt>ValidationFailure</tt>. ! * This method must not change the state of the object by ! * side-effect. ! * @throws ValidationFailure if an invariant is violated ! */ ! public void validate() throws ValidationFailure; ! } Index: ValidationFailure.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/ValidationFailure.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** ValidationFailure.java 27 Oct 2002 04:05:20 -0000 1.2 --- ValidationFailure.java 26 Nov 2002 03:35:40 -0000 1.3 *************** *** 1,23 **** ! //$Id$ ! package cirrus.hibernate; ! ! /** ! * Thrown from <tt>Validatable.validate()</tt> when an invariant ! * was violated. Some applications might subclass this exception ! * in order to provide more information about the violation. ! */ ! public class ValidationFailure extends HibernateException { ! ! public ValidationFailure(String message) { ! super(message); ! } ! ! public ValidationFailure(String message, Exception e) { ! super(message, e); ! } ! ! public ValidationFailure(Exception e) { ! super("A validation failure occurred", e); ! } ! ! } --- 1,23 ---- ! //$Id$ ! package cirrus.hibernate; ! ! /** ! * Thrown from <tt>Validatable.validate()</tt> when an invariant ! * was violated. Some applications might subclass this exception ! * in order to provide more information about the violation. ! */ ! public class ValidationFailure extends HibernateException { ! ! public ValidationFailure(String message) { ! super(message); ! } ! ! public ValidationFailure(String message, Exception e) { ! super(message, e); ! } ! ! public ValidationFailure(Exception e) { ! super("A validation failure occurred", e); ! } ! ! } |