summaryrefslogtreecommitdiff
path: root/examples_java/src/persist/gettingStarted
diff options
context:
space:
mode:
Diffstat (limited to 'examples_java/src/persist/gettingStarted')
-rw-r--r--examples_java/src/persist/gettingStarted/SimpleDA.java51
-rw-r--r--examples_java/src/persist/gettingStarted/SimpleEntityClass.java42
-rw-r--r--examples_java/src/persist/gettingStarted/SimpleStoreGet.java112
-rw-r--r--examples_java/src/persist/gettingStarted/SimpleStorePut.java116
4 files changed, 0 insertions, 321 deletions
diff --git a/examples_java/src/persist/gettingStarted/SimpleDA.java b/examples_java/src/persist/gettingStarted/SimpleDA.java
deleted file mode 100644
index ab4c6e9..0000000
--- a/examples_java/src/persist/gettingStarted/SimpleDA.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*-
- * See the file LICENSE for redistribution information.
- *
- * Copyright (c) 2008-2009 Oracle. All rights reserved.
- *
- * $Id$
- */
-
-package persist.gettingStarted;
-
-import java.io.File;
-
-import com.sleepycat.db.DatabaseException;
-import com.sleepycat.persist.EntityStore;
-import com.sleepycat.persist.PrimaryIndex;
-import com.sleepycat.persist.SecondaryIndex;
-import com.sleepycat.persist.EntityCursor;
-
-public class SimpleDA {
- // Open the indices
- public SimpleDA(EntityStore store)
- throws DatabaseException {
-
- // Primary key for SimpleEntityClass classes
- pIdx = store.getPrimaryIndex(
- String.class, SimpleEntityClass.class);
-
- // Secondary key for SimpleEntityClass classes
- // Last field in the getSecondaryIndex() method must be
- // the name of a class member; in this case, an
- // SimpleEntityClass.class data member.
- sIdx = store.getSecondaryIndex(
- pIdx, String.class, "sKey");
-
- sec_pcursor = pIdx.entities();
- sec_scursor = sIdx.subIndex("skeyone").entities();
- }
-
- public void close()
- throws DatabaseException {
- sec_pcursor.close();
- sec_scursor.close();
- }
-
- // Index Accessors
- PrimaryIndex<String,SimpleEntityClass> pIdx;
- SecondaryIndex<String,String,SimpleEntityClass> sIdx;
-
- EntityCursor<SimpleEntityClass> sec_pcursor;
- EntityCursor<SimpleEntityClass> sec_scursor;
-}
diff --git a/examples_java/src/persist/gettingStarted/SimpleEntityClass.java b/examples_java/src/persist/gettingStarted/SimpleEntityClass.java
deleted file mode 100644
index c4c0d81..0000000
--- a/examples_java/src/persist/gettingStarted/SimpleEntityClass.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*-
- * See the file LICENSE for redistribution information.
- *
- * Copyright (c) 2008-2009 Oracle. All rights reserved.
- *
- * $Id$
- */
-
-package persist.gettingStarted;
-
-import com.sleepycat.persist.model.Entity;
-import com.sleepycat.persist.model.PrimaryKey;
-import static com.sleepycat.persist.model.Relationship.*;
-import com.sleepycat.persist.model.SecondaryKey;
-
-@Entity
-public class SimpleEntityClass {
-
- // Primary key is pKey
- @PrimaryKey
- private String pKey;
-
- // Secondary key is the sKey
- @SecondaryKey(relate=MANY_TO_ONE)
- private String sKey;
-
- public void setpKey(String data) {
- pKey = data;
- }
-
- public void setsKey(String data) {
- sKey = data;
- }
-
- public String getpKey() {
- return pKey;
- }
-
- public String getsKey() {
- return sKey;
- }
-}
diff --git a/examples_java/src/persist/gettingStarted/SimpleStoreGet.java b/examples_java/src/persist/gettingStarted/SimpleStoreGet.java
deleted file mode 100644
index 44ac2dc..0000000
--- a/examples_java/src/persist/gettingStarted/SimpleStoreGet.java
+++ /dev/null
@@ -1,112 +0,0 @@
-/*-
- * See the file LICENSE for redistribution information.
- *
- * Copyright (c) 2008-2009 Oracle. All rights reserved.
- *
- * $Id$
- */
-
-package persist.gettingStarted;
-
-import java.io.File;
-
-import com.sleepycat.db.DatabaseException;
-import com.sleepycat.db.Environment;
-import com.sleepycat.db.EnvironmentConfig;
-
-import com.sleepycat.persist.EntityStore;
-import com.sleepycat.persist.StoreConfig;
-
-import java.io.FileNotFoundException;
-
-public class SimpleStoreGet {
-
- private static File envHome = new File("./JEDB");
-
- private Environment envmnt;
- private EntityStore store;
- private SimpleDA sda;
-
- // The setup() method opens the environment and store
- // for us.
- public void setup()
- throws DatabaseException {
-
- try {
- EnvironmentConfig envConfig = new EnvironmentConfig();
- StoreConfig storeConfig = new StoreConfig();
-
- // Open the environment and entity store
- envmnt = new Environment(envHome, envConfig);
- store = new EntityStore(envmnt, "EntityStore", storeConfig);
- } catch (FileNotFoundException fnfe) {
- System.err.println("setup(): " + fnfe.toString());
- System.exit(-1);
- }
- }
-
- public void shutdown()
- throws DatabaseException {
-
- store.close();
- envmnt.close();
- }
-
-
- private void run()
- throws DatabaseException {
-
- setup();
-
- // Open the data accessor. This is used to store
- // persistent objects.
- sda = new SimpleDA(store);
-
- // Instantiate and store some entity classes
- SimpleEntityClass sec1 = sda.pIdx.get("keyone");
- SimpleEntityClass sec2 = sda.pIdx.get("keytwo");
-
- SimpleEntityClass sec4 = sda.sIdx.get("skeythree");
-
- System.out.println("sec1: " + sec1.getpKey());
- System.out.println("sec2: " + sec2.getpKey());
- System.out.println("sec4: " + sec4.getpKey());
-
- System.out.println("############ Doing pcursor ##########");
- for (SimpleEntityClass seci : sda.sec_pcursor ) {
- System.out.println("sec from pcursor : " + seci.getpKey() );
- }
-
- sda.pIdx.delete("keyone");
- System.out.println("############ Doing pcursor ##########");
- System.out.println("sec from pcursor : " + sda.sec_pcursor.first().getpKey());
- for (SimpleEntityClass seci : sda.sec_pcursor ) {
- System.out.println("sec from pcursor : " + seci.getpKey() );
- }
-
- System.out.println("############ Doing scursor ##########");
- for (SimpleEntityClass seci : sda.sec_scursor ) {
- System.out.println("sec from scursor : " + seci.getpKey() );
- }
-
-
-
- sda.close();
- shutdown();
- }
-
- public static void main(String args[]) {
- SimpleStoreGet ssg = new SimpleStoreGet();
- try {
- ssg.run();
- } catch (DatabaseException dbe) {
- System.err.println("SimpleStoreGet: " + dbe.toString());
- dbe.printStackTrace();
- } catch (Exception e) {
- System.out.println("Exception: " + e.toString());
- e.printStackTrace();
- }
- System.out.println("All done.");
- }
-
-}
diff --git a/examples_java/src/persist/gettingStarted/SimpleStorePut.java b/examples_java/src/persist/gettingStarted/SimpleStorePut.java
deleted file mode 100644
index 0e48a5b..0000000
--- a/examples_java/src/persist/gettingStarted/SimpleStorePut.java
+++ /dev/null
@@ -1,116 +0,0 @@
-/*-
- * See the file LICENSE for redistribution information.
- *
- * Copyright (c) 2008-2009 Oracle. All rights reserved.
- *
- * $Id$
- */
-
-package persist.gettingStarted;
-
-import java.io.File;
-
-import com.sleepycat.db.DatabaseException;
-import com.sleepycat.db.Environment;
-import com.sleepycat.db.EnvironmentConfig;
-
-import com.sleepycat.persist.EntityStore;
-import com.sleepycat.persist.StoreConfig;
-
-import java.io.FileNotFoundException;
-
-public class SimpleStorePut {
-
- private static File envHome = new File("./JEDB");
-
- private Environment envmnt;
- private EntityStore store;
- private SimpleDA sda;
-
- // The setup() method opens the environment and store
- // for us.
- public void setup()
- throws DatabaseException {
-
- EnvironmentConfig envConfig = new EnvironmentConfig();
- StoreConfig storeConfig = new StoreConfig();
-
- envConfig.setAllowCreate(true);
- storeConfig.setAllowCreate(true);
-
- try {
- // Open the environment and entity store
- envmnt = new Environment(envHome, envConfig);
- store = new EntityStore(envmnt, "EntityStore", storeConfig);
- } catch (FileNotFoundException fnfe) {
- System.err.println("setup(): " + fnfe.toString());
- System.exit(-1);
- }
- }
-
- // Close our environment and store.
- public void shutdown()
- throws DatabaseException {
-
- store.close();
- envmnt.close();
- }
-
-
- private void run()
- throws DatabaseException {
-
- setup();
-
- // Open the data accessor. This is used to store
- // persistent objects.
- sda = new SimpleDA(store);
-
- // Instantiate and store some entity classes
- SimpleEntityClass sec1 = new SimpleEntityClass();
- SimpleEntityClass sec2 = new SimpleEntityClass();
- SimpleEntityClass sec3 = new SimpleEntityClass();
- SimpleEntityClass sec4 = new SimpleEntityClass();
- SimpleEntityClass sec5 = new SimpleEntityClass();
-
- sec1.setpKey("keyone");
- sec1.setsKey("skeyone");
-
- sec2.setpKey("keytwo");
- sec2.setsKey("skeyone");
-
- sec3.setpKey("keythree");
- sec3.setsKey("skeytwo");
-
- sec4.setpKey("keyfour");
- sec4.setsKey("skeythree");
-
- sec5.setpKey("keyfive");
- sec5.setsKey("skeyfour");
-
- sda.pIdx.put(sec1);
- sda.pIdx.put(sec2);
- sda.pIdx.put(sec3);
- sda.pIdx.put(sec4);
- sda.pIdx.put(sec5);
-
- sda.close();
-
- shutdown();
- }
-
- public static void main(String args[]) {
- SimpleStorePut ssp = new SimpleStorePut();
- try {
- ssp.run();
- } catch (DatabaseException dbe) {
- System.err.println("SimpleStorePut: " + dbe.toString());
- dbe.printStackTrace();
- } catch (Exception e) {
- System.out.println("Exception: " + e.toString());
- e.printStackTrace();
- }
- System.out.println("All done.");
- }
-
-}