Moved things that are not part of the Depot public API into an impl package.
Also moved WhereClause into depot.clause since it really wanted to be there.
This commit is contained in:
@@ -141,7 +141,6 @@
|
||||
<pathelement location="${classes.dir}"/>
|
||||
<pathelement location="${basedir}"/> <!-- for rsrc/ -->
|
||||
<fileset dir="${deploy.dir}/lib" includes="*.jar"/>
|
||||
<fileset dir="lib/test" includes="*.jar"/>
|
||||
</classpath>
|
||||
<sysproperty key="test_dir" value="${basedir}"/>
|
||||
<formatter type="brief" usefile="false"/>
|
||||
@@ -187,10 +186,25 @@
|
||||
|
||||
<!-- generate a class hierarchy diagram -->
|
||||
<target name="hiergen" depends="prepare,compile">
|
||||
<taskdef name="viztool" classname="com.samskivert.viztool.DriverTask"/>
|
||||
<taskdef name="viztool" classname="com.samskivert.viztool.DriverTask">
|
||||
<classpath>
|
||||
<fileset dir="../viztool/dist" includes="*.jar"/>
|
||||
<fileset dir="../viztool/lib" includes="*.jar"/>
|
||||
</classpath>
|
||||
</taskdef>
|
||||
<viztool visualizer="com.samskivert.viztool.hierarchy.HierarchyVisualizer"
|
||||
pkgroot="com.samskivert" classes="com.samskivert.*" output="hierarchy.ps">
|
||||
pkgroot="com.samskivert" classes="com.samskivert.depot.*" output="hierarchy.ps">
|
||||
<classpath refid="classpath"/>
|
||||
</viztool>
|
||||
</target>
|
||||
|
||||
<!-- TEMP: runs our test that requires a repository (replace with HSQLDB unit test) -->
|
||||
<target name="repotest" depends="prepare,compile">
|
||||
<copy file="depot.properties" tofile="${classes.dir}/depot.properties"/>
|
||||
<java classpathref="classpath" fork="true" maxmemory="256M"
|
||||
classname="com.samskivert.depot.tests.TestRepository">
|
||||
<jvmarg value="-Dcom.samskivert.depot.cache_debug=true"/>
|
||||
</java>
|
||||
<delete file="${classes.dir}/depot.properties"/>
|
||||
</target>
|
||||
</project>
|
||||
|
||||
@@ -41,14 +41,23 @@ import com.samskivert.jdbc.ConnectionProvider;
|
||||
import com.samskivert.jdbc.DatabaseLiaison;
|
||||
import com.samskivert.jdbc.JDBCUtil;
|
||||
|
||||
import com.samskivert.depot.Modifier.*;
|
||||
import com.samskivert.depot.clause.DeleteClause;
|
||||
import com.samskivert.depot.clause.FieldOverride;
|
||||
import com.samskivert.depot.clause.InsertClause;
|
||||
import com.samskivert.depot.clause.QueryClause;
|
||||
import com.samskivert.depot.clause.UpdateClause;
|
||||
import com.samskivert.depot.clause.WhereClause;
|
||||
import com.samskivert.depot.expression.SQLExpression;
|
||||
import com.samskivert.depot.expression.ValueExp;
|
||||
import com.samskivert.depot.impl.DepotMarshaller;
|
||||
import com.samskivert.depot.impl.DepotMigrationHistoryRecord;
|
||||
import com.samskivert.depot.impl.DepotTypes;
|
||||
import com.samskivert.depot.impl.FindAllKeysQuery;
|
||||
import com.samskivert.depot.impl.FindAllQuery;
|
||||
import com.samskivert.depot.impl.FindOneQuery;
|
||||
import com.samskivert.depot.impl.Modifier;
|
||||
import com.samskivert.depot.impl.SQLBuilder;
|
||||
import com.samskivert.depot.impl.Modifier.*;
|
||||
|
||||
import static com.samskivert.depot.Log.log;
|
||||
|
||||
@@ -378,7 +387,8 @@ public abstract class DepotRepository
|
||||
throw new IllegalArgumentException("Can't update record with null primary key.");
|
||||
}
|
||||
|
||||
UpdateClause<T> update = new UpdateClause<T>(pClass, key, marsh._columnFields, record);
|
||||
UpdateClause<T> update =
|
||||
new UpdateClause<T>(pClass, key, marsh.getColumnFieldNames(), record);
|
||||
final SQLBuilder builder = _ctx.getSQLBuilder(DepotTypes.getDepotTypes(_ctx, update));
|
||||
builder.newQuery(update);
|
||||
|
||||
@@ -719,7 +729,7 @@ public abstract class DepotRepository
|
||||
final DepotMarshaller<T> marsh = _ctx.getMarshaller(pClass);
|
||||
Key<T> key = marsh.hasPrimaryKey() ? marsh.getPrimaryKey(record) : null;
|
||||
final UpdateClause<T> update =
|
||||
new UpdateClause<T>(pClass, key, marsh._columnFields, record);
|
||||
new UpdateClause<T>(pClass, key, marsh.getColumnFieldNames(), record);
|
||||
final SQLBuilder builder = _ctx.getSQLBuilder(DepotTypes.getDepotTypes(_ctx, update));
|
||||
|
||||
// if our primary key isn't null, we start by trying to update rather than insert
|
||||
|
||||
@@ -27,8 +27,11 @@ import java.util.Map;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
|
||||
import com.samskivert.depot.expression.ExpressionVisitor;
|
||||
import com.samskivert.depot.clause.WhereClause;
|
||||
import com.samskivert.depot.expression.SQLExpression;
|
||||
import com.samskivert.depot.impl.DepotMarshaller;
|
||||
import com.samskivert.depot.impl.DepotUtil;
|
||||
import com.samskivert.depot.impl.ExpressionVisitor;
|
||||
import com.samskivert.util.StringUtil;
|
||||
|
||||
/**
|
||||
|
||||
@@ -32,9 +32,11 @@ import com.google.common.base.Function;
|
||||
|
||||
import com.samskivert.util.StringUtil;
|
||||
|
||||
import com.samskivert.depot.expression.ExpressionVisitor;
|
||||
import com.samskivert.depot.clause.WhereClause;
|
||||
import com.samskivert.depot.expression.LiteralExp;
|
||||
import com.samskivert.depot.expression.SQLExpression;
|
||||
import com.samskivert.depot.impl.DepotUtil;
|
||||
import com.samskivert.depot.impl.ExpressionVisitor;
|
||||
import com.samskivert.depot.operator.Conditionals;
|
||||
import com.samskivert.depot.operator.Logic;
|
||||
|
||||
|
||||
@@ -27,8 +27,9 @@ import java.util.Map;
|
||||
import com.google.common.collect.Maps;
|
||||
|
||||
import com.samskivert.depot.clause.Where;
|
||||
import com.samskivert.depot.expression.ExpressionVisitor;
|
||||
import com.samskivert.depot.clause.WhereClause;
|
||||
import com.samskivert.depot.expression.SQLExpression;
|
||||
import com.samskivert.depot.impl.ExpressionVisitor;
|
||||
|
||||
/**
|
||||
* A special form of {@link Where} clause that specifies an explicit range of database rows. It
|
||||
|
||||
@@ -43,6 +43,15 @@ import com.samskivert.jdbc.MySQLLiaison;
|
||||
import com.samskivert.jdbc.PostgreSQLLiaison;
|
||||
|
||||
import com.samskivert.depot.annotation.TableGenerator;
|
||||
import com.samskivert.depot.impl.DepotMarshaller;
|
||||
import com.samskivert.depot.impl.DepotTypes;
|
||||
import com.samskivert.depot.impl.HSQLBuilder;
|
||||
import com.samskivert.depot.impl.Modifier;
|
||||
import com.samskivert.depot.impl.MySQLBuilder;
|
||||
import com.samskivert.depot.impl.Operation;
|
||||
import com.samskivert.depot.impl.PostgreSQLBuilder;
|
||||
import com.samskivert.depot.impl.Query;
|
||||
import com.samskivert.depot.impl.SQLBuilder;
|
||||
|
||||
import static com.samskivert.depot.Log.log;
|
||||
|
||||
|
||||
@@ -27,6 +27,8 @@ import java.util.Map;
|
||||
import com.samskivert.jdbc.ColumnDefinition;
|
||||
import com.samskivert.jdbc.DatabaseLiaison;
|
||||
import com.samskivert.depot.annotation.Column;
|
||||
import com.samskivert.depot.impl.FieldMarshaller;
|
||||
import com.samskivert.depot.impl.Modifier;
|
||||
|
||||
import static com.samskivert.depot.Log.log;
|
||||
|
||||
@@ -82,6 +84,17 @@ public abstract class SchemaMigration extends Modifier
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init (String tableName, Map<String, FieldMarshaller<?>> marshallers) {
|
||||
super.init(tableName, marshallers);
|
||||
FieldMarshaller<?> fm = marshallers.get(_newColumnName);
|
||||
if (fm == null) {
|
||||
throw new IllegalArgumentException(
|
||||
_tableName + " does not contain '" + _newColumnName + "' field.");
|
||||
}
|
||||
_newColumnDef = fm.getColumnDefinition();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int invoke (Connection conn, DatabaseLiaison liaison) throws SQLException {
|
||||
if (!liaison.tableContainsColumn(conn, _tableName, _oldColumnName)) {
|
||||
@@ -108,17 +121,6 @@ public abstract class SchemaMigration extends Modifier
|
||||
conn, _tableName, _oldColumnName, _newColumnName, _newColumnDef) ? 1 : 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void init (String tableName, Map<String, FieldMarshaller<?>> marshallers) {
|
||||
super.init(tableName, marshallers);
|
||||
FieldMarshaller<?> fm = marshallers.get(_newColumnName);
|
||||
if (fm == null) {
|
||||
throw new IllegalArgumentException(
|
||||
_tableName + " does not contain '" + _newColumnName + "' field.");
|
||||
}
|
||||
_newColumnDef = fm.getColumnDefinition();
|
||||
}
|
||||
|
||||
protected String _oldColumnName, _newColumnName;
|
||||
protected ColumnDefinition _newColumnDef;
|
||||
}
|
||||
@@ -139,6 +141,13 @@ public abstract class SchemaMigration extends Modifier
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init (String tableName, Map<String, FieldMarshaller<?>> marshallers) {
|
||||
super.init(tableName, marshallers);
|
||||
_columnName = marshallers.get(_fieldName).getColumnName();
|
||||
_newColumnDef = marshallers.get(_fieldName).getColumnDefinition();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int invoke (Connection conn, DatabaseLiaison liaison) throws SQLException {
|
||||
log.info("Updating type of '" + _fieldName + "' in " + _tableName);
|
||||
@@ -147,13 +156,6 @@ public abstract class SchemaMigration extends Modifier
|
||||
_newColumnDef.getDefaultValue()) ? 1 : 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void init (String tableName, Map<String, FieldMarshaller<?>> marshallers) {
|
||||
super.init(tableName, marshallers);
|
||||
_columnName = marshallers.get(_fieldName).getColumnName();
|
||||
_newColumnDef = marshallers.get(_fieldName).getColumnDefinition();
|
||||
}
|
||||
|
||||
protected String _fieldName, _columnName;
|
||||
protected ColumnDefinition _newColumnDef;
|
||||
}
|
||||
@@ -178,6 +180,13 @@ public abstract class SchemaMigration extends Modifier
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init (String tableName, Map<String, FieldMarshaller<?>> marshallers) {
|
||||
super.init(tableName, marshallers);
|
||||
_columnName = marshallers.get(_fieldName).getColumnName();
|
||||
_newColumnDef = marshallers.get(_fieldName).getColumnDefinition();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int invoke (Connection conn, DatabaseLiaison liaison) throws SQLException {
|
||||
// override the default value in the column definition with the one provided
|
||||
@@ -194,13 +203,6 @@ public abstract class SchemaMigration extends Modifier
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void init (String tableName, Map<String, FieldMarshaller<?>> marshallers) {
|
||||
super.init(tableName, marshallers);
|
||||
_columnName = marshallers.get(_fieldName).getColumnName();
|
||||
_newColumnDef = marshallers.get(_fieldName).getColumnDefinition();
|
||||
}
|
||||
|
||||
protected String _fieldName, _columnName, _defaultValue;
|
||||
protected ColumnDefinition _newColumnDef;
|
||||
}
|
||||
@@ -224,23 +226,23 @@ public abstract class SchemaMigration extends Modifier
|
||||
return (currentVersion < _targetVersion);
|
||||
}
|
||||
|
||||
protected SchemaMigration (int targetVersion)
|
||||
{
|
||||
super();
|
||||
_targetVersion = targetVersion;
|
||||
}
|
||||
|
||||
/**
|
||||
* This is called to provide the migration with the name of the entity table and access to its
|
||||
* field marshallers prior to being invoked. This will <em>only</em> be called after this
|
||||
* migration has been determined to be runnable so one cannot rely on this method having been
|
||||
* called in {@link #shouldRunMigration}.
|
||||
*/
|
||||
protected void init (String tableName, Map<String, FieldMarshaller<?>> marshallers)
|
||||
public void init (String tableName, Map<String, FieldMarshaller<?>> marshallers)
|
||||
{
|
||||
_tableName = tableName;
|
||||
}
|
||||
|
||||
protected SchemaMigration (int targetVersion)
|
||||
{
|
||||
super();
|
||||
_targetVersion = targetVersion;
|
||||
}
|
||||
|
||||
protected int _targetVersion;
|
||||
protected String _tableName;
|
||||
}
|
||||
|
||||
@@ -23,8 +23,7 @@ package com.samskivert.depot.clause;
|
||||
import java.util.Collection;
|
||||
|
||||
import com.samskivert.depot.PersistentRecord;
|
||||
import com.samskivert.depot.WhereClause;
|
||||
import com.samskivert.depot.expression.ExpressionVisitor;
|
||||
import com.samskivert.depot.impl.ExpressionVisitor;
|
||||
|
||||
/**
|
||||
* Builds actual SQL given a main persistent type and some {@link QueryClause} objects.
|
||||
|
||||
@@ -24,9 +24,9 @@ import java.util.Collection;
|
||||
|
||||
import com.samskivert.depot.PersistentRecord;
|
||||
import com.samskivert.depot.expression.ColumnExp;
|
||||
import com.samskivert.depot.expression.ExpressionVisitor;
|
||||
import com.samskivert.depot.expression.LiteralExp;
|
||||
import com.samskivert.depot.expression.SQLExpression;
|
||||
import com.samskivert.depot.impl.ExpressionVisitor;
|
||||
|
||||
/**
|
||||
* Supplies a definition for a computed field of the persistent object we're creating.
|
||||
|
||||
@@ -23,7 +23,7 @@ package com.samskivert.depot.clause;
|
||||
import java.util.Collection;
|
||||
|
||||
import com.samskivert.depot.PersistentRecord;
|
||||
import com.samskivert.depot.expression.ExpressionVisitor;
|
||||
import com.samskivert.depot.impl.ExpressionVisitor;
|
||||
|
||||
/**
|
||||
* Represents a FOR UPDATE clause.
|
||||
|
||||
@@ -25,9 +25,9 @@ import java.util.List;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import com.samskivert.depot.DepotUtil;
|
||||
import com.samskivert.depot.PersistentRecord;
|
||||
import com.samskivert.depot.expression.ExpressionVisitor;
|
||||
import com.samskivert.depot.impl.DepotUtil;
|
||||
import com.samskivert.depot.impl.ExpressionVisitor;
|
||||
|
||||
/**
|
||||
* Completely overrides the FROM clause, if it exists.
|
||||
|
||||
@@ -23,8 +23,8 @@ package com.samskivert.depot.clause;
|
||||
import java.util.Collection;
|
||||
|
||||
import com.samskivert.depot.PersistentRecord;
|
||||
import com.samskivert.depot.expression.ExpressionVisitor;
|
||||
import com.samskivert.depot.expression.SQLExpression;
|
||||
import com.samskivert.depot.impl.ExpressionVisitor;
|
||||
|
||||
/**
|
||||
* Represents a GROUP BY clause.
|
||||
|
||||
@@ -24,7 +24,7 @@ import java.util.Collection;
|
||||
import java.util.Set;
|
||||
|
||||
import com.samskivert.depot.PersistentRecord;
|
||||
import com.samskivert.depot.expression.ExpressionVisitor;
|
||||
import com.samskivert.depot.impl.ExpressionVisitor;
|
||||
|
||||
/**
|
||||
* Builds actual SQL given a main persistent type and some {@link QueryClause} objects.
|
||||
|
||||
@@ -22,11 +22,11 @@ package com.samskivert.depot.clause;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import com.samskivert.depot.DepotUtil;
|
||||
import com.samskivert.depot.PersistentRecord;
|
||||
import com.samskivert.depot.expression.ColumnExp;
|
||||
import com.samskivert.depot.expression.ExpressionVisitor;
|
||||
import com.samskivert.depot.expression.SQLExpression;
|
||||
import com.samskivert.depot.impl.DepotUtil;
|
||||
import com.samskivert.depot.impl.ExpressionVisitor;
|
||||
import com.samskivert.depot.operator.Conditionals.Equals;
|
||||
|
||||
/**
|
||||
|
||||
@@ -23,7 +23,7 @@ package com.samskivert.depot.clause;
|
||||
import java.util.Collection;
|
||||
|
||||
import com.samskivert.depot.PersistentRecord;
|
||||
import com.samskivert.depot.expression.ExpressionVisitor;
|
||||
import com.samskivert.depot.impl.ExpressionVisitor;
|
||||
|
||||
/**
|
||||
* Represents a LIMIT/OFFSET clause, for pagination.
|
||||
|
||||
@@ -23,9 +23,9 @@ package com.samskivert.depot.clause;
|
||||
import java.util.Collection;
|
||||
|
||||
import com.samskivert.depot.PersistentRecord;
|
||||
import com.samskivert.depot.expression.ExpressionVisitor;
|
||||
import com.samskivert.depot.expression.LiteralExp;
|
||||
import com.samskivert.depot.expression.SQLExpression;
|
||||
import com.samskivert.depot.impl.ExpressionVisitor;
|
||||
|
||||
/**
|
||||
* Represents an ORDER BY clause.
|
||||
|
||||
@@ -29,8 +29,7 @@ import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
|
||||
import com.samskivert.depot.PersistentRecord;
|
||||
import com.samskivert.depot.WhereClause;
|
||||
import com.samskivert.depot.expression.ExpressionVisitor;
|
||||
import com.samskivert.depot.impl.ExpressionVisitor;
|
||||
|
||||
/**
|
||||
* Builds actual SQL given a main persistent type and some {@link QueryClause} objects.
|
||||
|
||||
@@ -23,9 +23,8 @@ package com.samskivert.depot.clause;
|
||||
import java.util.Collection;
|
||||
|
||||
import com.samskivert.depot.PersistentRecord;
|
||||
import com.samskivert.depot.WhereClause;
|
||||
import com.samskivert.depot.expression.ExpressionVisitor;
|
||||
import com.samskivert.depot.expression.SQLExpression;
|
||||
import com.samskivert.depot.impl.ExpressionVisitor;
|
||||
|
||||
/**
|
||||
* Builds actual SQL given a main persistent type and some {@link QueryClause} objects.
|
||||
|
||||
@@ -23,11 +23,10 @@ package com.samskivert.depot.clause;
|
||||
import java.util.Collection;
|
||||
|
||||
import com.samskivert.depot.PersistentRecord;
|
||||
import com.samskivert.depot.WhereClause;
|
||||
import com.samskivert.depot.expression.ColumnExp;
|
||||
import com.samskivert.depot.expression.ExpressionVisitor;
|
||||
import com.samskivert.depot.expression.SQLExpression;
|
||||
import com.samskivert.depot.expression.ValueExp;
|
||||
import com.samskivert.depot.impl.ExpressionVisitor;
|
||||
import com.samskivert.depot.operator.Conditionals.Equals;
|
||||
import com.samskivert.depot.operator.Conditionals.IsNull;
|
||||
import com.samskivert.depot.operator.Logic.And;
|
||||
|
||||
+1
-2
@@ -18,9 +18,8 @@
|
||||
// License along with this library; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
package com.samskivert.depot;
|
||||
package com.samskivert.depot.clause;
|
||||
|
||||
import com.samskivert.depot.clause.QueryClause;
|
||||
import com.samskivert.depot.expression.SQLExpression;
|
||||
|
||||
/**
|
||||
@@ -23,6 +23,7 @@ package com.samskivert.depot.expression;
|
||||
import java.util.Collection;
|
||||
|
||||
import com.samskivert.depot.PersistentRecord;
|
||||
import com.samskivert.depot.impl.ExpressionVisitor;
|
||||
|
||||
/**
|
||||
* An expression that unambiguously identifies a field of a class, e.g. GameRecord.itemId.
|
||||
|
||||
@@ -23,6 +23,7 @@ package com.samskivert.depot.expression;
|
||||
import java.util.Collection;
|
||||
|
||||
import com.samskivert.depot.PersistentRecord;
|
||||
import com.samskivert.depot.impl.ExpressionVisitor;
|
||||
|
||||
/**
|
||||
* An expression for extracting the seconds since the epoch from a date expression.
|
||||
|
||||
@@ -23,6 +23,7 @@ package com.samskivert.depot.expression;
|
||||
import java.util.Collection;
|
||||
|
||||
import com.samskivert.depot.PersistentRecord;
|
||||
import com.samskivert.depot.impl.ExpressionVisitor;
|
||||
|
||||
/**
|
||||
* An expression for a function, e.g. FLOOR(blah).
|
||||
|
||||
@@ -23,6 +23,7 @@ package com.samskivert.depot.expression;
|
||||
import java.util.Collection;
|
||||
|
||||
import com.samskivert.depot.PersistentRecord;
|
||||
import com.samskivert.depot.impl.ExpressionVisitor;
|
||||
|
||||
/**
|
||||
* An expression for things we don't support natively, e.g. COUNT(*).
|
||||
|
||||
@@ -23,7 +23,8 @@ package com.samskivert.depot.expression;
|
||||
import java.util.Collection;
|
||||
|
||||
import com.samskivert.depot.PersistentRecord;
|
||||
import com.samskivert.depot.SQLBuilder;
|
||||
import com.samskivert.depot.impl.ExpressionVisitor;
|
||||
import com.samskivert.depot.impl.SQLBuilder;
|
||||
|
||||
/**
|
||||
* Represents an SQL expression, e.g. column name, function, or constant.
|
||||
|
||||
@@ -23,6 +23,7 @@ package com.samskivert.depot.expression;
|
||||
import java.util.Collection;
|
||||
|
||||
import com.samskivert.depot.PersistentRecord;
|
||||
import com.samskivert.depot.impl.ExpressionVisitor;
|
||||
|
||||
/**
|
||||
* A Java value that is bound as a parameter to the query, e.g. 1 or 'abc'.
|
||||
|
||||
+7
-2
@@ -18,7 +18,7 @@
|
||||
// License along with this library; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
package com.samskivert.depot;
|
||||
package com.samskivert.depot.impl;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.sql.Connection;
|
||||
@@ -27,6 +27,11 @@ import java.sql.SQLException;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import com.samskivert.depot.ByteEnum;
|
||||
import com.samskivert.depot.DatabaseException;
|
||||
import com.samskivert.depot.Key;
|
||||
import com.samskivert.depot.MultiKey;
|
||||
import com.samskivert.depot.PersistentRecord;
|
||||
import com.samskivert.depot.clause.DeleteClause;
|
||||
import com.samskivert.depot.clause.FieldDefinition;
|
||||
import com.samskivert.depot.clause.ForUpdate;
|
||||
@@ -38,9 +43,9 @@ import com.samskivert.depot.clause.Limit;
|
||||
import com.samskivert.depot.clause.OrderBy;
|
||||
import com.samskivert.depot.clause.SelectClause;
|
||||
import com.samskivert.depot.clause.UpdateClause;
|
||||
import com.samskivert.depot.clause.WhereClause;
|
||||
import com.samskivert.depot.expression.ColumnExp;
|
||||
import com.samskivert.depot.expression.EpochSeconds;
|
||||
import com.samskivert.depot.expression.ExpressionVisitor;
|
||||
import com.samskivert.depot.expression.FunctionExp;
|
||||
import com.samskivert.depot.expression.LiteralExp;
|
||||
import com.samskivert.depot.expression.SQLExpression;
|
||||
+5
-2
@@ -18,7 +18,7 @@
|
||||
// License along with this library; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
package com.samskivert.depot;
|
||||
package com.samskivert.depot.impl;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -26,6 +26,9 @@ import java.util.Set;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
|
||||
import com.samskivert.depot.Key;
|
||||
import com.samskivert.depot.MultiKey;
|
||||
import com.samskivert.depot.PersistentRecord;
|
||||
import com.samskivert.depot.annotation.Computed;
|
||||
import com.samskivert.depot.clause.DeleteClause;
|
||||
import com.samskivert.depot.clause.FieldDefinition;
|
||||
@@ -39,9 +42,9 @@ import com.samskivert.depot.clause.Limit;
|
||||
import com.samskivert.depot.clause.OrderBy;
|
||||
import com.samskivert.depot.clause.SelectClause;
|
||||
import com.samskivert.depot.clause.UpdateClause;
|
||||
import com.samskivert.depot.clause.WhereClause;
|
||||
import com.samskivert.depot.expression.ColumnExp;
|
||||
import com.samskivert.depot.expression.EpochSeconds;
|
||||
import com.samskivert.depot.expression.ExpressionVisitor;
|
||||
import com.samskivert.depot.expression.FunctionExp;
|
||||
import com.samskivert.depot.expression.LiteralExp;
|
||||
import com.samskivert.depot.expression.SQLExpression;
|
||||
+92
-86
@@ -18,7 +18,7 @@
|
||||
// License along with this library; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
package com.samskivert.depot;
|
||||
package com.samskivert.depot.impl;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
@@ -38,6 +38,12 @@ import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.common.collect.Sets;
|
||||
|
||||
import com.samskivert.depot.DatabaseException;
|
||||
import com.samskivert.depot.Key;
|
||||
import com.samskivert.depot.PersistenceContext;
|
||||
import com.samskivert.depot.PersistentRecord;
|
||||
import com.samskivert.depot.SchemaMigration;
|
||||
import com.samskivert.depot.Stats;
|
||||
import com.samskivert.depot.annotation.Computed;
|
||||
import com.samskivert.depot.annotation.Entity;
|
||||
import com.samskivert.depot.annotation.FullTextIndex;
|
||||
@@ -445,97 +451,13 @@ public class DepotMarshaller<T extends PersistentRecord>
|
||||
return _initialized;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a persistent object from the supplied result set. The result set must have come from
|
||||
* a properly constructed query (see {@link BuildVisitor}).
|
||||
*/
|
||||
public T createObject (ResultSet rs)
|
||||
throws SQLException
|
||||
{
|
||||
try {
|
||||
// first, build a set of the fields that we actually received
|
||||
Set<String> fields = Sets.newHashSet();
|
||||
ResultSetMetaData metadata = rs.getMetaData();
|
||||
for (int ii = 1; ii <= metadata.getColumnCount(); ii ++) {
|
||||
fields.add(metadata.getColumnName(ii));
|
||||
}
|
||||
|
||||
// then create and populate the persistent object
|
||||
T po = _pClass.newInstance();
|
||||
for (FieldMarshaller<?> fm : _fields.values()) {
|
||||
if (!fields.contains(fm.getColumnName())) {
|
||||
// this field was not in the result set, make sure that's OK
|
||||
if (fm.getComputed() != null && !fm.getComputed().required()) {
|
||||
continue;
|
||||
}
|
||||
throw new SQLException("ResultSet missing field: " + fm.getField().getName());
|
||||
}
|
||||
fm.getAndWriteToObject(rs, po);
|
||||
}
|
||||
return po;
|
||||
|
||||
} catch (SQLException sqe) {
|
||||
// pass this on through
|
||||
throw sqe;
|
||||
|
||||
} catch (Exception e) {
|
||||
String errmsg = "Failed to unmarshall persistent object [class=" +
|
||||
_pClass.getName() + "]";
|
||||
throw (SQLException)new SQLException(errmsg).initCause(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Go through the registered {@link ValueGenerator}s for our persistent object and run the ones
|
||||
* that match the current postFactum phase, filling in the fields on the supplied object while
|
||||
* we go.
|
||||
*
|
||||
* The return value is only non-empty for the !postFactum phase, in which case it is a set of
|
||||
* field names that are associated with {@link IdentityValueGenerator}, because these need
|
||||
* special handling in the INSERT (specifically, 'DEFAULT' must be supplied as a value in the
|
||||
* eventual SQL).
|
||||
*/
|
||||
public Set<String> generateFieldValues (
|
||||
Connection conn, DatabaseLiaison liaison, Object po, boolean postFactum)
|
||||
{
|
||||
Set<String> idFields = Sets.newHashSet();
|
||||
|
||||
for (ValueGenerator vg : _valueGenerators.values()) {
|
||||
if (!postFactum && vg instanceof IdentityValueGenerator) {
|
||||
idFields.add(vg.getFieldMarshaller().getField().getName());
|
||||
}
|
||||
if (vg.isPostFactum() != postFactum) {
|
||||
continue;
|
||||
}
|
||||
|
||||
try {
|
||||
int nextValue = vg.nextGeneratedValue(conn, liaison);
|
||||
vg.getFieldMarshaller().getField().set(po, nextValue);
|
||||
|
||||
} catch (Exception e) {
|
||||
throw new IllegalStateException(
|
||||
"Failed to assign primary key [type=" + _pClass + "]", e);
|
||||
}
|
||||
}
|
||||
return idFields;
|
||||
}
|
||||
|
||||
/**
|
||||
* This is called by the persistence context to register a migration for the entity managed by
|
||||
* this marshaller.
|
||||
*/
|
||||
protected void registerMigration (SchemaMigration migration)
|
||||
{
|
||||
_schemaMigs.add(migration);
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the table used by this marshaller. This is called automatically by the {@link
|
||||
* PersistenceContext} the first time an entity is used. If the table does not exist, it will
|
||||
* be created. If the schema version specified by the persistent object is newer than the
|
||||
* database schema, it will be migrated.
|
||||
*/
|
||||
protected void init (PersistenceContext ctx)
|
||||
public void init (PersistenceContext ctx)
|
||||
throws DatabaseException
|
||||
{
|
||||
if (_initialized) { // sanity check
|
||||
@@ -682,6 +604,90 @@ public class DepotMarshaller<T extends PersistentRecord>
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This is called by the persistence context to register a migration for the entity managed by
|
||||
* this marshaller.
|
||||
*/
|
||||
public void registerMigration (SchemaMigration migration)
|
||||
{
|
||||
_schemaMigs.add(migration);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a persistent object from the supplied result set. The result set must have come from
|
||||
* a properly constructed query (see {@link BuildVisitor}).
|
||||
*/
|
||||
public T createObject (ResultSet rs)
|
||||
throws SQLException
|
||||
{
|
||||
try {
|
||||
// first, build a set of the fields that we actually received
|
||||
Set<String> fields = Sets.newHashSet();
|
||||
ResultSetMetaData metadata = rs.getMetaData();
|
||||
for (int ii = 1; ii <= metadata.getColumnCount(); ii ++) {
|
||||
fields.add(metadata.getColumnName(ii));
|
||||
}
|
||||
|
||||
// then create and populate the persistent object
|
||||
T po = _pClass.newInstance();
|
||||
for (FieldMarshaller<?> fm : _fields.values()) {
|
||||
if (!fields.contains(fm.getColumnName())) {
|
||||
// this field was not in the result set, make sure that's OK
|
||||
if (fm.getComputed() != null && !fm.getComputed().required()) {
|
||||
continue;
|
||||
}
|
||||
throw new SQLException("ResultSet missing field: " + fm.getField().getName());
|
||||
}
|
||||
fm.getAndWriteToObject(rs, po);
|
||||
}
|
||||
return po;
|
||||
|
||||
} catch (SQLException sqe) {
|
||||
// pass this on through
|
||||
throw sqe;
|
||||
|
||||
} catch (Exception e) {
|
||||
String errmsg = "Failed to unmarshall persistent object [class=" +
|
||||
_pClass.getName() + "]";
|
||||
throw (SQLException)new SQLException(errmsg).initCause(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Go through the registered {@link ValueGenerator}s for our persistent object and run the ones
|
||||
* that match the current postFactum phase, filling in the fields on the supplied object while
|
||||
* we go.
|
||||
*
|
||||
* The return value is only non-empty for the !postFactum phase, in which case it is a set of
|
||||
* field names that are associated with {@link IdentityValueGenerator}, because these need
|
||||
* special handling in the INSERT (specifically, 'DEFAULT' must be supplied as a value in the
|
||||
* eventual SQL).
|
||||
*/
|
||||
public Set<String> generateFieldValues (
|
||||
Connection conn, DatabaseLiaison liaison, Object po, boolean postFactum)
|
||||
{
|
||||
Set<String> idFields = Sets.newHashSet();
|
||||
|
||||
for (ValueGenerator vg : _valueGenerators.values()) {
|
||||
if (!postFactum && vg instanceof IdentityValueGenerator) {
|
||||
idFields.add(vg.getFieldMarshaller().getField().getName());
|
||||
}
|
||||
if (vg.isPostFactum() != postFactum) {
|
||||
continue;
|
||||
}
|
||||
|
||||
try {
|
||||
int nextValue = vg.nextGeneratedValue(conn, liaison);
|
||||
vg.getFieldMarshaller().getField().set(po, nextValue);
|
||||
|
||||
} catch (Exception e) {
|
||||
throw new IllegalStateException(
|
||||
"Failed to assign primary key [type=" + _pClass + "]", e);
|
||||
}
|
||||
}
|
||||
return idFields;
|
||||
}
|
||||
|
||||
protected void createTable (PersistenceContext ctx, final SQLBuilder builder,
|
||||
final ColumnDefinition[] declarations)
|
||||
throws DatabaseException
|
||||
+3
-1
@@ -18,10 +18,12 @@
|
||||
// License along with this library; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
package com.samskivert.depot;
|
||||
package com.samskivert.depot.impl;
|
||||
|
||||
import java.sql.Timestamp;
|
||||
|
||||
import com.samskivert.depot.Key;
|
||||
import com.samskivert.depot.PersistentRecord;
|
||||
import com.samskivert.depot.annotation.Column;
|
||||
import com.samskivert.depot.annotation.Id;
|
||||
import com.samskivert.depot.expression.ColumnExp;
|
||||
+4
-1
@@ -18,7 +18,7 @@
|
||||
// License along with this library; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
package com.samskivert.depot;
|
||||
package com.samskivert.depot.impl;
|
||||
|
||||
import java.sql.SQLException;
|
||||
|
||||
@@ -30,6 +30,9 @@ import java.util.Set;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.common.collect.Sets;
|
||||
|
||||
import com.samskivert.depot.DatabaseException;
|
||||
import com.samskivert.depot.PersistenceContext;
|
||||
import com.samskivert.depot.PersistentRecord;
|
||||
import com.samskivert.depot.clause.QueryClause;
|
||||
import com.samskivert.depot.expression.SQLExpression;
|
||||
|
||||
+1
-1
@@ -18,7 +18,7 @@
|
||||
// License along with this library; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
package com.samskivert.depot;
|
||||
package com.samskivert.depot.impl;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.List;
|
||||
+7
-2
@@ -18,12 +18,11 @@
|
||||
// License along with this library; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
package com.samskivert.depot.expression;
|
||||
package com.samskivert.depot.impl;
|
||||
|
||||
import com.samskivert.depot.Key;
|
||||
import com.samskivert.depot.MultiKey;
|
||||
import com.samskivert.depot.PersistentRecord;
|
||||
import com.samskivert.depot.WhereClause;
|
||||
|
||||
import com.samskivert.depot.clause.DeleteClause;
|
||||
import com.samskivert.depot.clause.FieldDefinition;
|
||||
@@ -36,6 +35,12 @@ import com.samskivert.depot.clause.Limit;
|
||||
import com.samskivert.depot.clause.OrderBy;
|
||||
import com.samskivert.depot.clause.SelectClause;
|
||||
import com.samskivert.depot.clause.UpdateClause;
|
||||
import com.samskivert.depot.clause.WhereClause;
|
||||
import com.samskivert.depot.expression.ColumnExp;
|
||||
import com.samskivert.depot.expression.EpochSeconds;
|
||||
import com.samskivert.depot.expression.FunctionExp;
|
||||
import com.samskivert.depot.expression.LiteralExp;
|
||||
import com.samskivert.depot.expression.ValueExp;
|
||||
|
||||
import com.samskivert.depot.operator.Conditionals.Exists;
|
||||
import com.samskivert.depot.operator.Conditionals.In;
|
||||
+3
-1
@@ -18,7 +18,7 @@
|
||||
// License along with this library; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
package com.samskivert.depot;
|
||||
package com.samskivert.depot.impl;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
@@ -35,6 +35,8 @@ import java.sql.Time;
|
||||
import java.sql.Timestamp;
|
||||
|
||||
import com.samskivert.jdbc.ColumnDefinition;
|
||||
import com.samskivert.depot.ByteEnum;
|
||||
import com.samskivert.depot.DatabaseException;
|
||||
import com.samskivert.depot.annotation.Column;
|
||||
import com.samskivert.depot.annotation.Computed;
|
||||
import com.samskivert.depot.annotation.GeneratedValue;
|
||||
+6
-1
@@ -18,7 +18,7 @@
|
||||
// License along with this library; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
package com.samskivert.depot;
|
||||
package com.samskivert.depot.impl;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
@@ -33,6 +33,11 @@ import com.google.common.collect.Lists;
|
||||
import com.samskivert.jdbc.DatabaseLiaison;
|
||||
import com.samskivert.jdbc.JDBCUtil;
|
||||
|
||||
import com.samskivert.depot.DatabaseException;
|
||||
import com.samskivert.depot.Key;
|
||||
import com.samskivert.depot.PersistenceContext;
|
||||
import com.samskivert.depot.PersistentRecord;
|
||||
import com.samskivert.depot.Stats;
|
||||
import com.samskivert.depot.clause.QueryClause;
|
||||
import com.samskivert.depot.clause.SelectClause;
|
||||
|
||||
+9
-1
@@ -18,7 +18,7 @@
|
||||
// License along with this library; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
package com.samskivert.depot;
|
||||
package com.samskivert.depot.impl;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
@@ -38,6 +38,14 @@ import com.google.common.collect.Maps;
|
||||
import com.samskivert.jdbc.DatabaseLiaison;
|
||||
import com.samskivert.jdbc.JDBCUtil;
|
||||
|
||||
import com.samskivert.depot.DatabaseException;
|
||||
import com.samskivert.depot.DepotRepository;
|
||||
import com.samskivert.depot.Key;
|
||||
import com.samskivert.depot.KeySet;
|
||||
import com.samskivert.depot.PersistenceContext;
|
||||
import com.samskivert.depot.PersistentRecord;
|
||||
import com.samskivert.depot.SimpleCacheKey;
|
||||
import com.samskivert.depot.Stats;
|
||||
import com.samskivert.depot.clause.FieldOverride;
|
||||
import com.samskivert.depot.clause.QueryClause;
|
||||
import com.samskivert.depot.clause.SelectClause;
|
||||
+8
-1
@@ -18,7 +18,7 @@
|
||||
// License along with this library; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
package com.samskivert.depot;
|
||||
package com.samskivert.depot.impl;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
@@ -28,8 +28,15 @@ import java.sql.SQLException;
|
||||
import com.samskivert.jdbc.DatabaseLiaison;
|
||||
import com.samskivert.jdbc.JDBCUtil;
|
||||
|
||||
import com.samskivert.depot.CacheKey;
|
||||
import com.samskivert.depot.DatabaseException;
|
||||
import com.samskivert.depot.DepotRepository;
|
||||
import com.samskivert.depot.PersistenceContext;
|
||||
import com.samskivert.depot.PersistentRecord;
|
||||
import com.samskivert.depot.Stats;
|
||||
import com.samskivert.depot.clause.QueryClause;
|
||||
import com.samskivert.depot.clause.SelectClause;
|
||||
import com.samskivert.depot.clause.WhereClause;
|
||||
|
||||
import static com.samskivert.depot.Log.log;
|
||||
|
||||
+14
-12
@@ -18,7 +18,7 @@
|
||||
// License along with this library; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
package com.samskivert.depot;
|
||||
package com.samskivert.depot.impl;
|
||||
|
||||
import java.sql.Blob;
|
||||
import java.sql.Clob;
|
||||
@@ -33,21 +33,23 @@ import java.util.Set;
|
||||
|
||||
import com.samskivert.jdbc.JDBCUtil;
|
||||
|
||||
import com.samskivert.depot.FieldMarshaller.BooleanMarshaller;
|
||||
import com.samskivert.depot.FieldMarshaller.ByteArrayMarshaller;
|
||||
import com.samskivert.depot.FieldMarshaller.ByteEnumMarshaller;
|
||||
import com.samskivert.depot.FieldMarshaller.ByteMarshaller;
|
||||
import com.samskivert.depot.FieldMarshaller.DoubleMarshaller;
|
||||
import com.samskivert.depot.FieldMarshaller.FloatMarshaller;
|
||||
import com.samskivert.depot.FieldMarshaller.IntArrayMarshaller;
|
||||
import com.samskivert.depot.FieldMarshaller.IntMarshaller;
|
||||
import com.samskivert.depot.FieldMarshaller.LongMarshaller;
|
||||
import com.samskivert.depot.FieldMarshaller.ObjectMarshaller;
|
||||
import com.samskivert.depot.FieldMarshaller.ShortMarshaller;
|
||||
import com.samskivert.depot.DatabaseException;
|
||||
import com.samskivert.depot.PersistentRecord;
|
||||
import com.samskivert.depot.annotation.FullTextIndex;
|
||||
import com.samskivert.depot.clause.DeleteClause;
|
||||
import com.samskivert.depot.expression.ColumnExp;
|
||||
import com.samskivert.depot.expression.EpochSeconds;
|
||||
import com.samskivert.depot.impl.FieldMarshaller.BooleanMarshaller;
|
||||
import com.samskivert.depot.impl.FieldMarshaller.ByteArrayMarshaller;
|
||||
import com.samskivert.depot.impl.FieldMarshaller.ByteEnumMarshaller;
|
||||
import com.samskivert.depot.impl.FieldMarshaller.ByteMarshaller;
|
||||
import com.samskivert.depot.impl.FieldMarshaller.DoubleMarshaller;
|
||||
import com.samskivert.depot.impl.FieldMarshaller.FloatMarshaller;
|
||||
import com.samskivert.depot.impl.FieldMarshaller.IntArrayMarshaller;
|
||||
import com.samskivert.depot.impl.FieldMarshaller.IntMarshaller;
|
||||
import com.samskivert.depot.impl.FieldMarshaller.LongMarshaller;
|
||||
import com.samskivert.depot.impl.FieldMarshaller.ObjectMarshaller;
|
||||
import com.samskivert.depot.impl.FieldMarshaller.ShortMarshaller;
|
||||
import com.samskivert.depot.operator.Conditionals.FullTextMatch;
|
||||
|
||||
import static com.samskivert.Log.log;
|
||||
+1
-1
@@ -18,7 +18,7 @@
|
||||
// License along with this library; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
package com.samskivert.depot;
|
||||
package com.samskivert.depot.impl;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.SQLException;
|
||||
+6
-1
@@ -18,12 +18,17 @@
|
||||
// License along with this library; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
package com.samskivert.depot;
|
||||
package com.samskivert.depot.impl;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Statement;
|
||||
|
||||
import com.samskivert.depot.CacheInvalidator;
|
||||
import com.samskivert.depot.CacheKey;
|
||||
import com.samskivert.depot.PersistenceContext;
|
||||
import com.samskivert.depot.PersistentRecord;
|
||||
import com.samskivert.depot.Stats;
|
||||
import com.samskivert.jdbc.DatabaseLiaison;
|
||||
|
||||
/**
|
||||
+14
-12
@@ -18,7 +18,7 @@
|
||||
// License along with this library; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
package com.samskivert.depot;
|
||||
package com.samskivert.depot.impl;
|
||||
|
||||
import java.sql.Blob;
|
||||
import java.sql.Clob;
|
||||
@@ -33,21 +33,23 @@ import java.util.Set;
|
||||
|
||||
import com.samskivert.jdbc.JDBCUtil;
|
||||
|
||||
import com.samskivert.depot.FieldMarshaller.BooleanMarshaller;
|
||||
import com.samskivert.depot.FieldMarshaller.ByteArrayMarshaller;
|
||||
import com.samskivert.depot.FieldMarshaller.ByteEnumMarshaller;
|
||||
import com.samskivert.depot.FieldMarshaller.ByteMarshaller;
|
||||
import com.samskivert.depot.FieldMarshaller.DoubleMarshaller;
|
||||
import com.samskivert.depot.FieldMarshaller.FloatMarshaller;
|
||||
import com.samskivert.depot.FieldMarshaller.IntArrayMarshaller;
|
||||
import com.samskivert.depot.FieldMarshaller.IntMarshaller;
|
||||
import com.samskivert.depot.FieldMarshaller.LongMarshaller;
|
||||
import com.samskivert.depot.FieldMarshaller.ObjectMarshaller;
|
||||
import com.samskivert.depot.FieldMarshaller.ShortMarshaller;
|
||||
import com.samskivert.depot.DatabaseException;
|
||||
import com.samskivert.depot.PersistentRecord;
|
||||
import com.samskivert.depot.annotation.FullTextIndex;
|
||||
import com.samskivert.depot.clause.DeleteClause;
|
||||
import com.samskivert.depot.expression.ColumnExp;
|
||||
import com.samskivert.depot.expression.EpochSeconds;
|
||||
import com.samskivert.depot.impl.FieldMarshaller.BooleanMarshaller;
|
||||
import com.samskivert.depot.impl.FieldMarshaller.ByteArrayMarshaller;
|
||||
import com.samskivert.depot.impl.FieldMarshaller.ByteEnumMarshaller;
|
||||
import com.samskivert.depot.impl.FieldMarshaller.ByteMarshaller;
|
||||
import com.samskivert.depot.impl.FieldMarshaller.DoubleMarshaller;
|
||||
import com.samskivert.depot.impl.FieldMarshaller.FloatMarshaller;
|
||||
import com.samskivert.depot.impl.FieldMarshaller.IntArrayMarshaller;
|
||||
import com.samskivert.depot.impl.FieldMarshaller.IntMarshaller;
|
||||
import com.samskivert.depot.impl.FieldMarshaller.LongMarshaller;
|
||||
import com.samskivert.depot.impl.FieldMarshaller.ObjectMarshaller;
|
||||
import com.samskivert.depot.impl.FieldMarshaller.ShortMarshaller;
|
||||
import com.samskivert.depot.operator.Conditionals.FullTextMatch;
|
||||
|
||||
import static com.samskivert.Log.log;
|
||||
+3
-1
@@ -18,11 +18,13 @@
|
||||
// License along with this library; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
package com.samskivert.depot;
|
||||
package com.samskivert.depot.impl;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import com.samskivert.depot.PersistenceContext;
|
||||
import com.samskivert.depot.Stats;
|
||||
import com.samskivert.jdbc.DatabaseLiaison;
|
||||
|
||||
/**
|
||||
+14
-23
@@ -18,7 +18,7 @@
|
||||
// License along with this library; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
package com.samskivert.depot;
|
||||
package com.samskivert.depot.impl;
|
||||
|
||||
import java.sql.Blob;
|
||||
import java.sql.Clob;
|
||||
@@ -37,17 +37,8 @@ import com.samskivert.jdbc.LiaisonRegistry;
|
||||
import com.samskivert.util.ArrayUtil;
|
||||
import com.samskivert.util.StringUtil;
|
||||
|
||||
import com.samskivert.depot.FieldMarshaller.BooleanMarshaller;
|
||||
import com.samskivert.depot.FieldMarshaller.ByteArrayMarshaller;
|
||||
import com.samskivert.depot.FieldMarshaller.ByteEnumMarshaller;
|
||||
import com.samskivert.depot.FieldMarshaller.ByteMarshaller;
|
||||
import com.samskivert.depot.FieldMarshaller.DoubleMarshaller;
|
||||
import com.samskivert.depot.FieldMarshaller.FloatMarshaller;
|
||||
import com.samskivert.depot.FieldMarshaller.IntArrayMarshaller;
|
||||
import com.samskivert.depot.FieldMarshaller.IntMarshaller;
|
||||
import com.samskivert.depot.FieldMarshaller.LongMarshaller;
|
||||
import com.samskivert.depot.FieldMarshaller.ObjectMarshaller;
|
||||
import com.samskivert.depot.FieldMarshaller.ShortMarshaller;
|
||||
import com.samskivert.depot.DatabaseException;
|
||||
import com.samskivert.depot.PersistentRecord;
|
||||
import com.samskivert.depot.annotation.FullTextIndex;
|
||||
import com.samskivert.depot.expression.EpochSeconds;
|
||||
import com.samskivert.depot.operator.Conditionals.FullTextMatch;
|
||||
@@ -238,19 +229,19 @@ public class PostgreSQLBuilder
|
||||
@Override
|
||||
protected <T> String getColumnType (FieldMarshaller<?> fm, int length)
|
||||
{
|
||||
if (fm instanceof ByteMarshaller) {
|
||||
if (fm instanceof FieldMarshaller.ByteMarshaller) {
|
||||
return "SMALLINT";
|
||||
} else if (fm instanceof ShortMarshaller) {
|
||||
} else if (fm instanceof FieldMarshaller.ShortMarshaller) {
|
||||
return "SMALLINT";
|
||||
} else if (fm instanceof IntMarshaller) {
|
||||
} else if (fm instanceof FieldMarshaller.IntMarshaller) {
|
||||
return "INTEGER";
|
||||
} else if (fm instanceof LongMarshaller) {
|
||||
} else if (fm instanceof FieldMarshaller.LongMarshaller) {
|
||||
return "BIGINT";
|
||||
} else if (fm instanceof FloatMarshaller) {
|
||||
} else if (fm instanceof FieldMarshaller.FloatMarshaller) {
|
||||
return "REAL";
|
||||
} else if (fm instanceof DoubleMarshaller) {
|
||||
} else if (fm instanceof FieldMarshaller.DoubleMarshaller) {
|
||||
return "DOUBLE PRECISION";
|
||||
} else if (fm instanceof ObjectMarshaller) {
|
||||
} else if (fm instanceof FieldMarshaller.ObjectMarshaller) {
|
||||
Class<?> ftype = fm.getField().getType();
|
||||
if (ftype.equals(Byte.class)) {
|
||||
return "SMALLINT";
|
||||
@@ -283,13 +274,13 @@ public class PostgreSQLBuilder
|
||||
throw new IllegalArgumentException(
|
||||
"Don't know how to create SQL for " + ftype + ".");
|
||||
}
|
||||
} else if (fm instanceof ByteArrayMarshaller) {
|
||||
} else if (fm instanceof FieldMarshaller.ByteArrayMarshaller) {
|
||||
return "BYTEA";
|
||||
} else if (fm instanceof IntArrayMarshaller) {
|
||||
} else if (fm instanceof FieldMarshaller.IntArrayMarshaller) {
|
||||
return "BYTEA";
|
||||
} else if (fm instanceof ByteEnumMarshaller) {
|
||||
} else if (fm instanceof FieldMarshaller.ByteEnumMarshaller) {
|
||||
return "SMALLINT";
|
||||
} else if (fm instanceof BooleanMarshaller) {
|
||||
} else if (fm instanceof FieldMarshaller.BooleanMarshaller) {
|
||||
return "BOOLEAN";
|
||||
} else {
|
||||
throw new IllegalArgumentException("Unknown field marshaller type: " + fm.getClass());
|
||||
+3
-1
@@ -18,7 +18,9 @@
|
||||
// License along with this library; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
package com.samskivert.depot;
|
||||
package com.samskivert.depot.impl;
|
||||
|
||||
import com.samskivert.depot.PersistenceContext;
|
||||
|
||||
/**
|
||||
* The base of all read-only queries.
|
||||
+4
-2
@@ -18,7 +18,7 @@
|
||||
// License along with this library; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
package com.samskivert.depot;
|
||||
package com.samskivert.depot.impl;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.Set;
|
||||
@@ -28,11 +28,13 @@ import java.sql.PreparedStatement;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import com.samskivert.jdbc.ColumnDefinition;
|
||||
import com.samskivert.depot.ByteEnum;
|
||||
import com.samskivert.depot.PersistenceContext;
|
||||
import com.samskivert.depot.PersistentRecord;
|
||||
import com.samskivert.depot.annotation.Column;
|
||||
import com.samskivert.depot.annotation.FullTextIndex;
|
||||
import com.samskivert.depot.annotation.GeneratedValue;
|
||||
import com.samskivert.depot.clause.QueryClause;
|
||||
import com.samskivert.depot.expression.ExpressionVisitor;
|
||||
|
||||
import static com.samskivert.depot.Log.log;
|
||||
|
||||
+1
-1
@@ -18,7 +18,7 @@
|
||||
// License along with this library; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
package com.samskivert.depot;
|
||||
package com.samskivert.depot.impl;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
+1
-1
@@ -18,7 +18,7 @@
|
||||
// License along with this library; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
package com.samskivert.depot;
|
||||
package com.samskivert.depot.impl;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.ResultSet;
|
||||
@@ -25,8 +25,8 @@ import java.util.Collection;
|
||||
import com.samskivert.depot.PersistentRecord;
|
||||
import com.samskivert.depot.clause.SelectClause;
|
||||
import com.samskivert.depot.expression.ColumnExp;
|
||||
import com.samskivert.depot.expression.ExpressionVisitor;
|
||||
import com.samskivert.depot.expression.SQLExpression;
|
||||
import com.samskivert.depot.impl.ExpressionVisitor;
|
||||
|
||||
/**
|
||||
* A convenient container for implementations of conditional operators. Classes that value brevity
|
||||
|
||||
@@ -23,8 +23,8 @@ package com.samskivert.depot.operator;
|
||||
import java.util.Collection;
|
||||
|
||||
import com.samskivert.depot.PersistentRecord;
|
||||
import com.samskivert.depot.expression.ExpressionVisitor;
|
||||
import com.samskivert.depot.expression.SQLExpression;
|
||||
import com.samskivert.depot.impl.ExpressionVisitor;
|
||||
|
||||
/**
|
||||
* A convenient container for implementations of logical operators. Classes that value brevity
|
||||
|
||||
@@ -23,9 +23,9 @@ package com.samskivert.depot.operator;
|
||||
import java.util.Collection;
|
||||
|
||||
import com.samskivert.depot.PersistentRecord;
|
||||
import com.samskivert.depot.expression.ExpressionVisitor;
|
||||
import com.samskivert.depot.expression.SQLExpression;
|
||||
import com.samskivert.depot.expression.ValueExp;
|
||||
import com.samskivert.depot.impl.ExpressionVisitor;
|
||||
|
||||
/**
|
||||
* A common interface for operator hierarchies in SQL. The main purpose of breaking this out from
|
||||
|
||||
+1
-1
@@ -18,7 +18,7 @@
|
||||
// License along with this library; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
package com.samskivert.depot.util;
|
||||
package com.samskivert.depot.tests;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Collections;
|
||||
@@ -40,7 +40,6 @@ import com.samskivert.depot.annotation.Computed;
|
||||
import com.samskivert.depot.clause.Where;
|
||||
import com.samskivert.depot.expression.LiteralExp;
|
||||
import com.samskivert.depot.operator.Conditionals;
|
||||
import com.samskivert.depot.util.TestCacheAdapter;
|
||||
|
||||
/**
|
||||
* A test tool for the Depot repository services.
|
||||
|
||||
@@ -50,10 +50,10 @@ import org.apache.tools.ant.util.ClasspathUtils;
|
||||
import org.apache.velocity.VelocityContext;
|
||||
import org.apache.velocity.app.VelocityEngine;
|
||||
|
||||
import com.samskivert.depot.DepotUtil;
|
||||
import com.samskivert.depot.PersistentRecord;
|
||||
import com.samskivert.depot.annotation.Id;
|
||||
import com.samskivert.depot.annotation.Transient;
|
||||
import com.samskivert.depot.impl.DepotUtil;
|
||||
import com.samskivert.util.ClassUtil;
|
||||
import com.samskivert.util.GenUtil;
|
||||
import com.samskivert.util.StringUtil;
|
||||
|
||||
Reference in New Issue
Block a user