Index: javax/jdo/datastore/SimpleSequenceFactory.java
===================================================================
--- javax/jdo/datastore/SimpleSequenceFactory.java (revision 0)
+++ javax/jdo/datastore/SimpleSequenceFactory.java (revision 0)
@@ -0,0 +1,103 @@
+/*
+ * Copyright 2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package javax.jdo.datastore;
+
+import java.util.Date;
+
+/*
+ * SimpleSequenceFactory.java
+ *
+ */
+public class SimpleSequenceFactory implements Sequence {
+
+ /** Nontransactional strategy.
+ */
+ public final static String NONTRANSACTIONAL = "nontransactional";
+
+ /** Default name.
+ */
+ public final static String DEFAULT_NAME = "SimpleSequenceFactory";
+
+ /** This is the value to be returned.
+ */
+ protected long value = new Date().getTime();
+
+ /** This is the name of the sequence.
+ */
+ protected String name;
+
+ /** This is the strategy of the sequence.
+ */
+ protected String strategy;
+
+ /** Creates a new instance of SimpleSequenceFactory */
+ protected SimpleSequenceFactory(String name, String strategy) {
+ this.name = name;
+ this.strategy = strategy;
+ }
+
+ /** Creates a new instance of SimpleSequenceFactory */
+ public static Sequence newInstance(String name, String strategy) {
+ return new SimpleSequenceFactory(name, strategy);
+ }
+
+ /** Creates a new instance of SimpleSequenceFactory */
+ public static Sequence newInstance(String name) {
+ return new SimpleSequenceFactory(name, NONTRANSACTIONAL);
+ }
+
+ /** Creates a new instance of SimpleSequenceFactory */
+ public static Sequence newInstance() {
+ return new SimpleSequenceFactory(DEFAULT_NAME, NONTRANSACTIONAL);
+ }
+
+ /** This method need not do anything.
+ */
+ public void allocate(int additional) {
+ }
+
+ /** Provide a non-mutating snapshot.
+ */
+ public Object current() {
+ return new Long(value);
+ }
+
+ /** Return the current value, which might have already been used.
+ */
+ public long currentValue() {
+ return value;
+ }
+
+ /** Return the name of this sequence.
+ */
+ public String getName() {
+ return name;
+ }
+
+ /** Increment the value and return it as an object.
+ */
+ public synchronized Object next() {
+ return new Long(++value);
+ }
+
+ /** Increment the value and return it.
+ */
+ public synchronized long nextValue() {
+ return ++value;
+ }
+
+}
Index: javax/jdo/PersistenceManager.java
===================================================================
--- javax/jdo/PersistenceManager.java (revision 331619)
+++ javax/jdo/PersistenceManager.java (working copy)
@@ -451,22 +451,27 @@
* reachable from persistent
* fields will be made persistent at commit. [This is known as
* persistence by reachability.]
+ * Detached instances will not be made persistent. Instead, a persistent
+ * instance with the same persistent identity is located in the
+ * cache and changes are applied to the persistent instance. The
+ * persistent instance is returned.
* @param pc a transient instance of a Class that implements
+ * @return the persistent instance
* PersistenceCapable
*/
- void makePersistent (Object pc);
+ Object makePersistent (Object pc);
/** Make an array of instances persistent.
* @param pcs an array of transient instances
* @see #makePersistent(Object pc)
*/
- void makePersistentAll (Object[] pcs);
+ Object[] makePersistentAll (Object[] pcs);
/** Make a Collection of instances persistent.
* @param pcs a Collection of transient instances
* @see #makePersistent(Object pc)
*/
- void makePersistentAll (Collection pcs);
+ Collection makePersistentAll (Collection pcs);
/** Delete the persistent instance from the data store.
* This method must be called in an active transaction.