Don't force an id generation strategy. The default is to assume the code will
provide one. Separate out logging for depot so that fine grained logging can be enabled if needed without turning on such logging for all of samskivert.
This commit is contained in:
@@ -38,7 +38,7 @@ import javax.persistence.Transient;
|
|||||||
import com.samskivert.jdbc.JDBCUtil;
|
import com.samskivert.jdbc.JDBCUtil;
|
||||||
import com.samskivert.util.StringUtil;
|
import com.samskivert.util.StringUtil;
|
||||||
|
|
||||||
import static com.samskivert.Log.log;
|
import static com.samskivert.jdbc.depot.Log.log;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handles the marshalling and unmarshalling of persistent instances to JDBC
|
* Handles the marshalling and unmarshalling of persistent instances to JDBC
|
||||||
@@ -171,6 +171,9 @@ public class DepotMarshaller<T>
|
|||||||
|
|
||||||
// now create the table for our persistent class if it does not exist
|
// now create the table for our persistent class if it does not exist
|
||||||
if (!JDBCUtil.tableExists(conn, getTableName())) {
|
if (!JDBCUtil.tableExists(conn, getTableName())) {
|
||||||
|
log.fine("Creating table " + getTableName() +
|
||||||
|
" (" + StringUtil.join(_columnDefinitions, ", ") + ") " +
|
||||||
|
_postamble);
|
||||||
JDBCUtil.createTableIfMissing(
|
JDBCUtil.createTableIfMissing(
|
||||||
conn, getTableName(), _columnDefinitions, _postamble);
|
conn, getTableName(), _columnDefinitions, _postamble);
|
||||||
// TODO: insert current version into version table
|
// TODO: insert current version into version table
|
||||||
|
|||||||
@@ -194,21 +194,19 @@ public abstract class FieldMarshaller
|
|||||||
|
|
||||||
// figure out how we're going to generate our primary key values
|
// figure out how we're going to generate our primary key values
|
||||||
GeneratedValue gv = field.getAnnotation(GeneratedValue.class);
|
GeneratedValue gv = field.getAnnotation(GeneratedValue.class);
|
||||||
GenerationType strat = GenerationType.AUTO;
|
|
||||||
if (gv != null) {
|
if (gv != null) {
|
||||||
strat = gv.strategy();
|
switch (gv.strategy()) {
|
||||||
}
|
case AUTO:
|
||||||
switch (strat) {
|
case IDENTITY:
|
||||||
case AUTO:
|
builder.append(" AUTO_INCREMENT");
|
||||||
case IDENTITY:
|
break;
|
||||||
builder.append(" AUTO_INCREMENT");
|
case SEQUENCE: // TODO
|
||||||
break;
|
throw new IllegalArgumentException(
|
||||||
case SEQUENCE: // TODO
|
"TABLE key generation strategy not yet supported.");
|
||||||
throw new IllegalArgumentException(
|
case TABLE: // TODO
|
||||||
"TABLE key generation strategy not yet supported.");
|
throw new IllegalArgumentException(
|
||||||
case TABLE: // TODO
|
"TABLE key generation strategy not yet supported.");
|
||||||
throw new IllegalArgumentException(
|
}
|
||||||
"TABLE key generation strategy not yet supported.");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,57 @@
|
|||||||
|
//
|
||||||
|
// $Id$
|
||||||
|
//
|
||||||
|
// samskivert library - useful routines for java programs
|
||||||
|
// Copyright (C) 2001-2006 Michael Bayne
|
||||||
|
//
|
||||||
|
// This library is free software; you can redistribute it and/or modify it
|
||||||
|
// under the terms of the GNU Lesser General Public License as published
|
||||||
|
// by the Free Software Foundation; either version 2.1 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This library is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
// Lesser General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Lesser General Public
|
||||||
|
// 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.jdbc.depot;
|
||||||
|
|
||||||
|
import java.util.logging.Level;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Contains a reference to the log object used by this package.
|
||||||
|
*/
|
||||||
|
public class Log
|
||||||
|
{
|
||||||
|
/** We dispatch our log messages through this logger. */
|
||||||
|
public static Logger log = Logger.getLogger("com.samskivert.jdbc.depot");
|
||||||
|
|
||||||
|
/** Convenience function. */
|
||||||
|
public static void debug (String message)
|
||||||
|
{
|
||||||
|
log.fine(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Convenience function. */
|
||||||
|
public static void info (String message)
|
||||||
|
{
|
||||||
|
log.info(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Convenience function. */
|
||||||
|
public static void warning (String message)
|
||||||
|
{
|
||||||
|
log.warning(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Convenience function. */
|
||||||
|
public static void logStackTrace (Throwable t)
|
||||||
|
{
|
||||||
|
log.log(Level.WARNING, t.getMessage(), t);
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user