diff --git a/src/java/com/samskivert/jdbc/depot/DepotMarshaller.java b/src/java/com/samskivert/jdbc/depot/DepotMarshaller.java index 0c80b4a..4186198 100644 --- a/src/java/com/samskivert/jdbc/depot/DepotMarshaller.java +++ b/src/java/com/samskivert/jdbc/depot/DepotMarshaller.java @@ -38,7 +38,7 @@ import javax.persistence.Transient; import com.samskivert.jdbc.JDBCUtil; 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 @@ -171,6 +171,9 @@ public class DepotMarshaller // now create the table for our persistent class if it does not exist if (!JDBCUtil.tableExists(conn, getTableName())) { + log.fine("Creating table " + getTableName() + + " (" + StringUtil.join(_columnDefinitions, ", ") + ") " + + _postamble); JDBCUtil.createTableIfMissing( conn, getTableName(), _columnDefinitions, _postamble); // TODO: insert current version into version table diff --git a/src/java/com/samskivert/jdbc/depot/FieldMarshaller.java b/src/java/com/samskivert/jdbc/depot/FieldMarshaller.java index 17fa10a..6d1fc29 100644 --- a/src/java/com/samskivert/jdbc/depot/FieldMarshaller.java +++ b/src/java/com/samskivert/jdbc/depot/FieldMarshaller.java @@ -194,21 +194,19 @@ public abstract class FieldMarshaller // figure out how we're going to generate our primary key values GeneratedValue gv = field.getAnnotation(GeneratedValue.class); - GenerationType strat = GenerationType.AUTO; if (gv != null) { - strat = gv.strategy(); - } - switch (strat) { - case AUTO: - case IDENTITY: - builder.append(" AUTO_INCREMENT"); - break; - case SEQUENCE: // TODO - throw new IllegalArgumentException( - "TABLE key generation strategy not yet supported."); - case TABLE: // TODO - throw new IllegalArgumentException( - "TABLE key generation strategy not yet supported."); + switch (gv.strategy()) { + case AUTO: + case IDENTITY: + builder.append(" AUTO_INCREMENT"); + break; + case SEQUENCE: // TODO + throw new IllegalArgumentException( + "TABLE key generation strategy not yet supported."); + case TABLE: // TODO + throw new IllegalArgumentException( + "TABLE key generation strategy not yet supported."); + } } } diff --git a/src/java/com/samskivert/jdbc/depot/Log.java b/src/java/com/samskivert/jdbc/depot/Log.java new file mode 100644 index 0000000..9ac4ad9 --- /dev/null +++ b/src/java/com/samskivert/jdbc/depot/Log.java @@ -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); + } +}