Warning: session_start(): open(/var/lib/php/sessions/sess_9oke6tcpbhtf0o8pp7ohsivbi6, O_RDWR) failed: No space left on device (28) in /var/www/tb-usercake/models/config.php on line 51
Warning: session_start(): Failed to read session data: files (path: /var/lib/php/sessions) in /var/www/tb-usercake/models/config.php on line 51
!752
lib 1004017 // Berkeley DB
import com.sleepycat.je.DatabaseException;
import com.sleepycat.je.Environment;
import com.sleepycat.je.EnvironmentConfig;
import com.sleepycat.persist.EntityStore;
import com.sleepycat.persist.StoreConfig;
import com.sleepycat.persist.model.Entity;
import com.sleepycat.persist.model.PrimaryKey;
import com.sleepycat.persist.model.SecondaryKey;
import static com.sleepycat.persist.model.Relationship.MANY_TO_ONE;
import com.sleepycat.je.DatabaseException;
import com.sleepycat.persist.EntityStore;
import com.sleepycat.persist.PrimaryIndex;
import com.sleepycat.persist.SecondaryIndex;
public static class SimpleDA {
// Open the indices
public SimpleDA(EntityStore store)
throws DatabaseException {
// Primary key for ExampleEntity classes
pIdx = store.getPrimaryIndex(
String.class, ExampleEntity.class);
// Secondary key for ExampleEntity classes
// Last field in the getSecondaryIndex() method must be
// the name of a class member; in this case, an
// ExampleEntity.class data member.
sIdx = store.getSecondaryIndex(
pIdx, String.class, "aSecondaryKey");
}
// Index Accessors
PrimaryIndex pIdx;
SecondaryIndex sIdx;
}
@Entity
public static class ExampleEntity {
// The primary key must be unique in the database.
@PrimaryKey
private String aPrimaryKey;
@SecondaryKey(relate=MANY_TO_ONE)
private String aSecondaryKey;
void setPKey(S x) { aPrimaryKey = x; }
void setSKey(S x) { aSecondaryKey = x; }
}
p {
Environment myEnv;
EntityStore store;
bool readOnly = false;
File envHome = mkdir(getProgramDir());
print("Opening Berkely DB in " + envHome.getAbsolutePath());
EnvironmentConfig myEnvConfig = new EnvironmentConfig();
StoreConfig storeConfig = new StoreConfig();
myEnvConfig.setAllowCreate(!readOnly);
storeConfig.setAllowCreate(!readOnly);
// Open the environment and entity store
myEnv = new Environment(envHome, myEnvConfig);
store = new EntityStore(myEnv, "EntityStore", storeConfig);
print("Saving stuff");
SimpleDA da = new SimpleDA(store);
ExampleEntity sec1 = new ExampleEntity();
sec1.setPKey("keyone");
sec1.setSKey("skeyone");
da.pIdx.put(sec1);
print("Closing");
if (store != null)
store.close();
if (myEnv != null)
myEnv.close();
}