1/*- 2 * See the file LICENSE for redistribution information. 3 * 4 * Copyright (c) 2008-2009 Oracle. All rights reserved. 5 * 6 * $Id$ 7 */ 8 9package persist.gettingStarted; 10 11import java.io.File; 12 13import com.sleepycat.db.DatabaseException; 14import com.sleepycat.persist.EntityStore; 15import com.sleepycat.persist.PrimaryIndex; 16import com.sleepycat.persist.SecondaryIndex; 17import com.sleepycat.persist.EntityCursor; 18 19public class SimpleDA { 20 // Open the indices 21 public SimpleDA(EntityStore store) 22 throws DatabaseException { 23 24 // Primary key for SimpleEntityClass classes 25 pIdx = store.getPrimaryIndex( 26 String.class, SimpleEntityClass.class); 27 28 // Secondary key for SimpleEntityClass classes 29 // Last field in the getSecondaryIndex() method must be 30 // the name of a class member; in this case, an 31 // SimpleEntityClass.class data member. 32 sIdx = store.getSecondaryIndex( 33 pIdx, String.class, "sKey"); 34 35 sec_pcursor = pIdx.entities(); 36 sec_scursor = sIdx.subIndex("skeyone").entities(); 37 } 38 39 public void close() 40 throws DatabaseException { 41 sec_pcursor.close(); 42 sec_scursor.close(); 43 } 44 45 // Index Accessors 46 PrimaryIndex<String,SimpleEntityClass> pIdx; 47 SecondaryIndex<String,String,SimpleEntityClass> sIdx; 48 49 EntityCursor<SimpleEntityClass> sec_pcursor; 50 EntityCursor<SimpleEntityClass> sec_scursor; 51} 52