本文整理汇总了Java中com.sleepycat.je.SecondaryConfig.setForeignKeyDatabase方法的典型用法代码示例。如果您正苦于以下问题:Java SecondaryConfig.setForeignKeyDatabase方法的具体用法?Java SecondaryConfig.setForeignKeyDatabase怎么用?Java SecondaryConfig.setForeignKeyDatabase使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.sleepycat.je.SecondaryConfig
的用法示例。
在下文中一共展示了SecondaryConfig.setForeignKeyDatabase方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: openSecondaryDb
import com.sleepycat.je.SecondaryConfig; //导入方法依赖的package包/类
private SecondaryDatabase openSecondaryDb(TupleSerialFactory factory,
String keyName,
Database primary,
String file,
Database foreignStore)
throws Exception {
TupleSerialMarshalledKeyCreator keyCreator =
factory.getKeyCreator(MarshalledObject.class, keyName);
SecondaryConfig secConfig = new SecondaryConfig();
secConfig.setTransactional(testEnv.isTxnMode());
secConfig.setAllowCreate(true);
secConfig.setKeyCreator(keyCreator);
if (foreignStore != null) {
secConfig.setForeignKeyDatabase(foreignStore);
secConfig.setForeignKeyDeleteAction(onDelete);
secConfig.setForeignKeyNullifier(keyCreator);
}
return DbCompat.openSecondaryDatabase(env, null, file, null,
primary, secConfig);
}
示例2: openSecondaryDb
import com.sleepycat.je.SecondaryConfig; //导入方法依赖的package包/类
private SecondaryDatabase openSecondaryDb(TupleSerialFactory factory,
String keyName,
Database primary,
String file,
Database foreignStore)
throws Exception {
SecondaryConfig secConfig = new SecondaryConfig();
secConfig.setTransactional(testEnv.isTxnMode());
secConfig.setAllowCreate(true);
secConfig.setKeyCreator(factory.getKeyCreator(MarshalledObject.class,
keyName));
if (foreignStore != null) {
secConfig.setForeignKeyDatabase(foreignStore);
secConfig.setForeignKeyDeleteAction(
ForeignKeyDeleteAction.CASCADE);
}
return DbCompat.openSecondaryDatabase(env, null,
file, null,
primary, secConfig);
}
示例3: openSecondary
import com.sleepycat.je.SecondaryConfig; //导入方法依赖的package包/类
private SecondaryDatabase openSecondary(Database priDb, String dbName,
Database foreignDb,
ForeignKeyDeleteAction onDelete)
throws DatabaseException {
SecondaryConfig dbConfig = new SecondaryConfig();
dbConfig.setTransactional(isTransactional);
dbConfig.setAllowCreate(true);
dbConfig.setSortedDuplicates(true);
MyKeyCreator keyCreator = new MyKeyCreator();
if (useMultiKey) {
dbConfig.setMultiKeyCreator(new SimpleMultiKeyCreator(keyCreator));
} else {
dbConfig.setKeyCreator(keyCreator);
}
if (foreignDb != null) {
if (useMultiKey) {
dbConfig.setForeignMultiKeyNullifier(keyCreator);
} else {
dbConfig.setForeignKeyNullifier(keyCreator);
}
dbConfig.setForeignKeyDatabase(foreignDb);
dbConfig.setForeignKeyDeleteAction(onDelete);
}
Transaction txn = txnBegin();
try {
return env.openSecondaryDatabase(txn, dbName, priDb, dbConfig);
} finally {
txnCommit(txn);
}
}
示例4: SorcerDatabase
import com.sleepycat.je.SecondaryConfig; //导入方法依赖的package包/类
/**
* Open all storage containers, indices, and catalogs.
*/
public SorcerDatabase(String homeDirectory)
throws DatabaseException {
// Open the Berkeley DB environment in transactional mode.
//System.out.println("Opening environment in: " + homeDirectory);
EnvironmentConfig envConfig = new EnvironmentConfig();
envConfig.setLockTimeout(LOCK_TIMEOUT, TimeUnit.MILLISECONDS);
envConfig.setTransactional(true);
envConfig.setAllowCreate(true);
envConfig.setSharedCache(true);
env = new Environment(new File(homeDirectory), envConfig);
// Set the Berkeley DB config for opening all stores.
DatabaseConfig dbConfig = new DatabaseConfig();
dbConfig.setTransactional(true);
dbConfig.setAllowCreate(true);
// Create the Serial class catalog. This holds the serialized class
// format for all database records of serial format.
//
Database catalogDb = env.openDatabase(null, CLASS_CATALOG, dbConfig);
javaCatalog = new StoredClassCatalog(catalogDb);
// Open the Berkeley DB database, the stores are opened
// with no duplicate keys allowed.
runtimeDb = env.openDatabase(null, RUNTIME_STORE, dbConfig);
exertionDb = env.openDatabase(null, EXERTION_STORE, dbConfig);
contextDb = env.openDatabase(null, CONTEXT_STORE, dbConfig);
tableDb = env.openDatabase(null, TABLE_STORE, dbConfig);
varDb = env.openDatabase(null, VAR_STORE, dbConfig);
varModelDb = env.openDatabase(null, VAR_MODEL_STORE, dbConfig);
uuidObjectDb = env.openDatabase(null, OBJECT_STORE, dbConfig);
// Open the SecondaryDatabase for the name index of the provider in the runtime store.
// Duplicate keys are allowed since more than one provider may be in
// the same exertion. A foreign key constraint is defined for the
// name indices to ensure that a runtime only refers to
// existing provider keys. The CASCADE delete action means
// that shipments will be deleted if their associated part or supplier
// is deleted.
//
SecondaryConfig secConfig = new SecondaryConfig();
secConfig.setTransactional(true);
secConfig.setAllowCreate(true);
secConfig.setSortedDuplicates(true);
secConfig.setKeyCreator(new RuntimeByProviderNameKeyCreator(javaCatalog,
ProviderRuntime.class));
runtimeByProviderNameDb = env.openSecondaryDatabase(null, RUNTIME_PROVIDER_NAME_INDEX,
runtimeDb, secConfig);
secConfig.setForeignKeyDatabase(runtimeDb);
secConfig.setForeignKeyDeleteAction(ForeignKeyDeleteAction.CASCADE);
secConfig.setKeyCreator(new ExertionByRuntimeKeyCreator(javaCatalog,
ServiceExertion.class));
}
示例5: SampleDatabase
import com.sleepycat.je.SecondaryConfig; //导入方法依赖的package包/类
/**
* Open all storage containers, indices, and catalogs.
*/
public SampleDatabase(String homeDirectory)
throws DatabaseException, FileNotFoundException {
// Open the Berkeley DB environment in transactional mode.
//
System.out.println("Opening environment in: " + homeDirectory);
EnvironmentConfig envConfig = new EnvironmentConfig();
envConfig.setTransactional(true);
envConfig.setAllowCreate(true);
env = new Environment(new File(homeDirectory), envConfig);
// Set the Berkeley DB config for opening all stores.
//
DatabaseConfig dbConfig = new DatabaseConfig();
dbConfig.setTransactional(true);
dbConfig.setAllowCreate(true);
// Create the Serial class catalog. This holds the serialized class
// format for all database records of serial format.
//
Database catalogDb = env.openDatabase(null, CLASS_CATALOG, dbConfig);
javaCatalog = new StoredClassCatalog(catalogDb);
// Open the Berkeley DB database for the part, supplier and shipment
// stores. The stores are opened with no duplicate keys allowed.
//
partDb = env.openDatabase(null, PART_STORE, dbConfig);
supplierDb = env.openDatabase(null, SUPPLIER_STORE, dbConfig);
shipmentDb = env.openDatabase(null, SHIPMENT_STORE, dbConfig);
// Open the SecondaryDatabase for the city index of the supplier store,
// and for the part and supplier indices of the shipment store.
// Duplicate keys are allowed since more than one supplier may be in
// the same city, and more than one shipment may exist for the same
// supplier or part. A foreign key constraint is defined for the
// supplier and part indices to ensure that a shipment only refers to
// existing part and supplier keys. The CASCADE delete action means
// that shipments will be deleted if their associated part or supplier
// is deleted.
//
SecondaryConfig secConfig = new SecondaryConfig();
secConfig.setTransactional(true);
secConfig.setAllowCreate(true);
secConfig.setSortedDuplicates(true);
secConfig.setKeyCreator(new SupplierByCityKeyCreator(javaCatalog,
SupplierData.class));
supplierByCityDb = env.openSecondaryDatabase(null, SUPPLIER_CITY_INDEX,
supplierDb, secConfig);
secConfig.setForeignKeyDatabase(partDb);
secConfig.setForeignKeyDeleteAction(ForeignKeyDeleteAction.CASCADE);
secConfig.setKeyCreator(new ShipmentByPartKeyCreator(javaCatalog,
ShipmentData.class));
shipmentByPartDb = env.openSecondaryDatabase(null, SHIPMENT_PART_INDEX,
shipmentDb, secConfig);
secConfig.setForeignKeyDatabase(supplierDb);
secConfig.setForeignKeyDeleteAction(ForeignKeyDeleteAction.CASCADE);
secConfig.setKeyCreator(new ShipmentBySupplierKeyCreator(javaCatalog,
ShipmentData.class));
shipmentBySupplierDb = env.openSecondaryDatabase(null,
SHIPMENT_SUPPLIER_INDEX,
shipmentDb, secConfig);
}
示例6: SampleDatabase
import com.sleepycat.je.SecondaryConfig; //导入方法依赖的package包/类
/**
* Open all storage containers, indices, and catalogs.
*/
public SampleDatabase(String homeDirectory)
throws DatabaseException, FileNotFoundException {
// Open the Berkeley DB environment in transactional mode.
//
System.out.println("Opening environment in: " + homeDirectory);
EnvironmentConfig envConfig = new EnvironmentConfig();
envConfig.setTransactional(true);
envConfig.setAllowCreate(true);
env = new Environment(new File(homeDirectory), envConfig);
// Set the Berkeley DB config for opening all stores.
//
DatabaseConfig dbConfig = new DatabaseConfig();
dbConfig.setTransactional(true);
dbConfig.setAllowCreate(true);
// Create the Serial class catalog. This holds the serialized class
// format for all database records of serial format.
//
Database catalogDb = env.openDatabase(null, CLASS_CATALOG, dbConfig);
javaCatalog = new StoredClassCatalog(catalogDb);
// Use the TupleSerialDbFactory for a Serial/Tuple-based database
// where marshalling interfaces are used.
//
factory = new TupleSerialFactory(javaCatalog);
// Open the Berkeley DB database for the part, supplier and shipment
// stores. The stores are opened with no duplicate keys allowed.
//
partDb = env.openDatabase(null, PART_STORE, dbConfig);
supplierDb = env.openDatabase(null, SUPPLIER_STORE, dbConfig);
shipmentDb = env.openDatabase(null, SHIPMENT_STORE, dbConfig);
// Open the SecondaryDatabase for the city index of the supplier store,
// and for the part and supplier indices of the shipment store.
// Duplicate keys are allowed since more than one supplier may be in
// the same city, and more than one shipment may exist for the same
// supplier or part. A foreign key constraint is defined for the
// supplier and part indices to ensure that a shipment only refers to
// existing part and supplier keys. The CASCADE delete action means
// that shipments will be deleted if their associated part or supplier
// is deleted.
//
SecondaryConfig secConfig = new SecondaryConfig();
secConfig.setTransactional(true);
secConfig.setAllowCreate(true);
secConfig.setSortedDuplicates(true);
secConfig.setKeyCreator(factory.getKeyCreator(Supplier.class,
Supplier.CITY_KEY));
supplierByCityDb = env.openSecondaryDatabase(null, SUPPLIER_CITY_INDEX,
supplierDb, secConfig);
secConfig.setForeignKeyDatabase(partDb);
secConfig.setForeignKeyDeleteAction(ForeignKeyDeleteAction.CASCADE);
secConfig.setKeyCreator(factory.getKeyCreator(Shipment.class,
Shipment.PART_KEY));
shipmentByPartDb = env.openSecondaryDatabase(null, SHIPMENT_PART_INDEX,
shipmentDb, secConfig);
secConfig.setForeignKeyDatabase(supplierDb);
secConfig.setForeignKeyDeleteAction(ForeignKeyDeleteAction.CASCADE);
secConfig.setKeyCreator(factory.getKeyCreator(Shipment.class,
Shipment.SUPPLIER_KEY));
shipmentBySupplierDb = env.openSecondaryDatabase(null,
SHIPMENT_SUPPLIER_INDEX,
shipmentDb, secConfig);
}
示例7: SampleDatabase
import com.sleepycat.je.SecondaryConfig; //导入方法依赖的package包/类
/**
* Open all storage containers, indices, and catalogs.
*/
public SampleDatabase(String homeDirectory)
throws DatabaseException, FileNotFoundException {
// Open the Berkeley DB environment in transactional mode.
//
System.out.println("Opening environment in: " + homeDirectory);
EnvironmentConfig envConfig = new EnvironmentConfig();
envConfig.setTransactional(true);
envConfig.setAllowCreate(true);
env = new Environment(new File(homeDirectory), envConfig);
// Set the Berkeley DB config for opening all stores.
//
DatabaseConfig dbConfig = new DatabaseConfig();
dbConfig.setTransactional(true);
dbConfig.setAllowCreate(true);
// Create the Serial class catalog. This holds the serialized class
// format for all database records of serial format.
//
Database catalogDb = env.openDatabase(null, CLASS_CATALOG, dbConfig);
javaCatalog = new StoredClassCatalog(catalogDb);
// Open the Berkeley DB database for the part, supplier and shipment
// stores. The stores are opened with no duplicate keys allowed.
//
partDb = env.openDatabase(null, PART_STORE, dbConfig);
supplierDb = env.openDatabase(null, SUPPLIER_STORE, dbConfig);
shipmentDb = env.openDatabase(null, SHIPMENT_STORE, dbConfig);
// Open the SecondaryDatabase for the city index of the supplier store,
// and for the part and supplier indices of the shipment store.
// Duplicate keys are allowed since more than one supplier may be in
// the same city, and more than one shipment may exist for the same
// supplier or part. A foreign key constraint is defined for the
// supplier and part indices to ensure that a shipment only refers to
// existing part and supplier keys. The CASCADE delete action means
// that shipments will be deleted if their associated part or supplier
// is deleted.
//
SecondaryConfig secConfig = new SecondaryConfig();
secConfig.setTransactional(true);
secConfig.setAllowCreate(true);
secConfig.setSortedDuplicates(true);
secConfig.setKeyCreator(
new SupplierByCityKeyCreator(javaCatalog,
SupplierKey.class,
SupplierData.class,
String.class));
supplierByCityDb = env.openSecondaryDatabase(null, SUPPLIER_CITY_INDEX,
supplierDb, secConfig);
secConfig.setForeignKeyDatabase(partDb);
secConfig.setForeignKeyDeleteAction(ForeignKeyDeleteAction.CASCADE);
secConfig.setKeyCreator(
new ShipmentByPartKeyCreator(javaCatalog,
ShipmentKey.class,
ShipmentData.class,
PartKey.class));
shipmentByPartDb = env.openSecondaryDatabase(null, SHIPMENT_PART_INDEX,
shipmentDb, secConfig);
secConfig.setForeignKeyDatabase(supplierDb);
secConfig.setForeignKeyDeleteAction(ForeignKeyDeleteAction.CASCADE);
secConfig.setKeyCreator(
new ShipmentBySupplierKeyCreator(javaCatalog,
ShipmentKey.class,
ShipmentData.class,
SupplierKey.class));
shipmentBySupplierDb = env.openSecondaryDatabase(null,
SHIPMENT_SUPPLIER_INDEX,
shipmentDb, secConfig);
}
示例8: SampleDatabase
import com.sleepycat.je.SecondaryConfig; //导入方法依赖的package包/类
/**
* Open all storage containers, indices, and catalogs.
*/
public SampleDatabase(String homeDirectory)
throws DatabaseException, FileNotFoundException {
// Open the Berkeley DB environment in transactional mode.
//
System.out.println("Opening environment in: " + homeDirectory);
EnvironmentConfig envConfig = new EnvironmentConfig();
envConfig.setTransactional(true);
envConfig.setAllowCreate(true);
env = new Environment(new File(homeDirectory), envConfig);
// Set the Berkeley DB config for opening all stores.
//
DatabaseConfig dbConfig = new DatabaseConfig();
dbConfig.setTransactional(true);
dbConfig.setAllowCreate(true);
// Create the Serial class catalog. This holds the serialized class
// format for all database records of serial format.
//
Database catalogDb = env.openDatabase(null, CLASS_CATALOG, dbConfig);
javaCatalog = new StoredClassCatalog(catalogDb);
// Open the Berkeley DB database for the part, supplier and shipment
// stores. The stores are opened with no duplicate keys allowed.
//
partDb = env.openDatabase(null, PART_STORE, dbConfig);
supplierDb = env.openDatabase(null, SUPPLIER_STORE, dbConfig);
shipmentDb = env.openDatabase(null, SHIPMENT_STORE, dbConfig);
// Open the SecondaryDatabase for the city index of the supplier store,
// and for the part and supplier indices of the shipment store.
// Duplicate keys are allowed since more than one supplier may be in
// the same city, and more than one shipment may exist for the same
// supplier or part. A foreign key constraint is defined for the
// supplier and part indices to ensure that a shipment only refers to
// existing part and supplier keys. The CASCADE delete action means
// that shipments will be deleted if their associated part or supplier
// is deleted.
//
SecondaryConfig secConfig = new SecondaryConfig();
secConfig.setTransactional(true);
secConfig.setAllowCreate(true);
secConfig.setSortedDuplicates(true);
secConfig.setKeyCreator(new MarshalledKeyCreator(javaCatalog,
Supplier.class,
Supplier.CITY_KEY));
supplierByCityDb = env.openSecondaryDatabase(null, SUPPLIER_CITY_INDEX,
supplierDb, secConfig);
secConfig.setForeignKeyDatabase(partDb);
secConfig.setForeignKeyDeleteAction(ForeignKeyDeleteAction.CASCADE);
secConfig.setKeyCreator(new MarshalledKeyCreator(javaCatalog,
Shipment.class,
Shipment.PART_KEY));
shipmentByPartDb = env.openSecondaryDatabase(null, SHIPMENT_PART_INDEX,
shipmentDb, secConfig);
secConfig.setForeignKeyDatabase(supplierDb);
secConfig.setForeignKeyDeleteAction(ForeignKeyDeleteAction.CASCADE);
secConfig.setKeyCreator(new MarshalledKeyCreator(javaCatalog,
Shipment.class,
Shipment.SUPPLIER_KEY));
shipmentBySupplierDb = env.openSecondaryDatabase(null,
SHIPMENT_SUPPLIER_INDEX,
shipmentDb, secConfig);
}
示例9: SampleDatabase
import com.sleepycat.je.SecondaryConfig; //导入方法依赖的package包/类
/**
* Open all storage containers, indices, and catalogs.
*/
public SampleDatabase(String homeDirectory)
throws DatabaseException {
// Open the Berkeley DB environment in transactional mode.
//
System.out.println("Opening environment in: " + homeDirectory);
EnvironmentConfig envConfig = new EnvironmentConfig();
envConfig.setTransactional(true);
envConfig.setAllowCreate(true);
env = new Environment(new File(homeDirectory), envConfig);
// Set the Berkeley DB config for opening all stores.
//
DatabaseConfig dbConfig = new DatabaseConfig();
dbConfig.setTransactional(true);
dbConfig.setAllowCreate(true);
// Create the Serial class catalog. This holds the serialized class
// format for all database records of serial format.
//
Database catalogDb = env.openDatabase(null, CLASS_CATALOG, dbConfig);
javaCatalog = new StoredClassCatalog(catalogDb);
// Open the Berkeley DB database for the part, supplier and shipment
// stores. The stores are opened with no duplicate keys allowed.
//
partDb = env.openDatabase(null, PART_STORE, dbConfig);
supplierDb = env.openDatabase(null, SUPPLIER_STORE, dbConfig);
shipmentDb = env.openDatabase(null, SHIPMENT_STORE, dbConfig);
// Open the SecondaryDatabase for the city index of the supplier store,
// and for the part and supplier indices of the shipment store.
// Duplicate keys are allowed since more than one supplier may be in
// the same city, and more than one shipment may exist for the same
// supplier or part. A foreign key constraint is defined for the
// supplier and part indices to ensure that a shipment only refers to
// existing part and supplier keys. The CASCADE delete action means
// that shipments will be deleted if their associated part or supplier
// is deleted.
//
SecondaryConfig secConfig = new SecondaryConfig();
secConfig.setTransactional(true);
secConfig.setAllowCreate(true);
secConfig.setSortedDuplicates(true);
secConfig.setKeyCreator(new MarshalledKeyCreator(javaCatalog,
Supplier.class,
Supplier.CITY_KEY));
supplierByCityDb = env.openSecondaryDatabase(null, SUPPLIER_CITY_INDEX,
supplierDb, secConfig);
secConfig.setForeignKeyDatabase(partDb);
secConfig.setForeignKeyDeleteAction(ForeignKeyDeleteAction.CASCADE);
secConfig.setKeyCreator(new MarshalledKeyCreator(javaCatalog,
Shipment.class,
Shipment.PART_KEY));
shipmentByPartDb = env.openSecondaryDatabase(null, SHIPMENT_PART_INDEX,
shipmentDb, secConfig);
secConfig.setForeignKeyDatabase(supplierDb);
secConfig.setForeignKeyDeleteAction(ForeignKeyDeleteAction.CASCADE);
secConfig.setKeyCreator(new MarshalledKeyCreator(javaCatalog,
Shipment.class,
Shipment.SUPPLIER_KEY));
shipmentBySupplierDb = env.openSecondaryDatabase(null,
SHIPMENT_SUPPLIER_INDEX,
shipmentDb, secConfig);
}
示例10: SampleDatabase
import com.sleepycat.je.SecondaryConfig; //导入方法依赖的package包/类
/**
* Open all storage containers, indices, and catalogs.
*/
public SampleDatabase(String homeDirectory)
throws DatabaseException {
// Open the Berkeley DB environment in transactional mode.
//
System.out.println("Opening environment in: " + homeDirectory);
EnvironmentConfig envConfig = new EnvironmentConfig();
envConfig.setTransactional(true);
envConfig.setAllowCreate(true);
env = new Environment(new File(homeDirectory), envConfig);
// Set the Berkeley DB config for opening all stores.
//
DatabaseConfig dbConfig = new DatabaseConfig();
dbConfig.setTransactional(true);
dbConfig.setAllowCreate(true);
// Create the Serial class catalog. This holds the serialized class
// format for all database records of serial format.
//
Database catalogDb = env.openDatabase(null, CLASS_CATALOG, dbConfig);
javaCatalog = new StoredClassCatalog(catalogDb);
// Use the TupleSerialDbFactory for a Serial/Tuple-based database
// where marshalling interfaces are used.
//
factory = new TupleSerialFactory(javaCatalog);
// Open the Berkeley DB database for the part, supplier and shipment
// stores. The stores are opened with no duplicate keys allowed.
//
partDb = env.openDatabase(null, PART_STORE, dbConfig);
supplierDb = env.openDatabase(null, SUPPLIER_STORE, dbConfig);
shipmentDb = env.openDatabase(null, SHIPMENT_STORE, dbConfig);
// Open the SecondaryDatabase for the city index of the supplier store,
// and for the part and supplier indices of the shipment store.
// Duplicate keys are allowed since more than one supplier may be in
// the same city, and more than one shipment may exist for the same
// supplier or part. A foreign key constraint is defined for the
// supplier and part indices to ensure that a shipment only refers to
// existing part and supplier keys. The CASCADE delete action means
// that shipments will be deleted if their associated part or supplier
// is deleted.
//
SecondaryConfig secConfig = new SecondaryConfig();
secConfig.setTransactional(true);
secConfig.setAllowCreate(true);
secConfig.setSortedDuplicates(true);
secConfig.setKeyCreator(factory.getKeyCreator(Supplier.class,
Supplier.CITY_KEY));
supplierByCityDb = env.openSecondaryDatabase(null, SUPPLIER_CITY_INDEX,
supplierDb, secConfig);
secConfig.setForeignKeyDatabase(partDb);
secConfig.setForeignKeyDeleteAction(ForeignKeyDeleteAction.CASCADE);
secConfig.setKeyCreator(factory.getKeyCreator(Shipment.class,
Shipment.PART_KEY));
shipmentByPartDb = env.openSecondaryDatabase(null, SHIPMENT_PART_INDEX,
shipmentDb, secConfig);
secConfig.setForeignKeyDatabase(supplierDb);
secConfig.setForeignKeyDeleteAction(ForeignKeyDeleteAction.CASCADE);
secConfig.setKeyCreator(factory.getKeyCreator(Shipment.class,
Shipment.SUPPLIER_KEY));
shipmentBySupplierDb = env.openSecondaryDatabase(null,
SHIPMENT_SUPPLIER_INDEX,
shipmentDb, secConfig);
}
示例11: SampleDatabase
import com.sleepycat.je.SecondaryConfig; //导入方法依赖的package包/类
/**
* Open all storage containers, indices, and catalogs.
*/
public SampleDatabase(String homeDirectory)
throws DatabaseException {
// Open the Berkeley DB environment in transactional mode.
//
System.out.println("Opening environment in: " + homeDirectory);
EnvironmentConfig envConfig = new EnvironmentConfig();
envConfig.setTransactional(true);
envConfig.setAllowCreate(true);
env = new Environment(new File(homeDirectory), envConfig);
// Set the Berkeley DB config for opening all stores.
//
DatabaseConfig dbConfig = new DatabaseConfig();
dbConfig.setTransactional(true);
dbConfig.setAllowCreate(true);
// Create the Serial class catalog. This holds the serialized class
// format for all database records of serial format.
//
Database catalogDb = env.openDatabase(null, CLASS_CATALOG, dbConfig);
javaCatalog = new StoredClassCatalog(catalogDb);
// Open the Berkeley DB database for the part, supplier and shipment
// stores. The stores are opened with no duplicate keys allowed.
//
partDb = env.openDatabase(null, PART_STORE, dbConfig);
supplierDb = env.openDatabase(null, SUPPLIER_STORE, dbConfig);
shipmentDb = env.openDatabase(null, SHIPMENT_STORE, dbConfig);
// Open the SecondaryDatabase for the city index of the supplier store,
// and for the part and supplier indices of the shipment store.
// Duplicate keys are allowed since more than one supplier may be in
// the same city, and more than one shipment may exist for the same
// supplier or part. A foreign key constraint is defined for the
// supplier and part indices to ensure that a shipment only refers to
// existing part and supplier keys. The CASCADE delete action means
// that shipments will be deleted if their associated part or supplier
// is deleted.
//
SecondaryConfig secConfig = new SecondaryConfig();
secConfig.setTransactional(true);
secConfig.setAllowCreate(true);
secConfig.setSortedDuplicates(true);
secConfig.setKeyCreator(
new SupplierByCityKeyCreator(javaCatalog,
SupplierKey.class,
SupplierData.class,
String.class));
supplierByCityDb = env.openSecondaryDatabase(null, SUPPLIER_CITY_INDEX,
supplierDb, secConfig);
secConfig.setForeignKeyDatabase(partDb);
secConfig.setForeignKeyDeleteAction(ForeignKeyDeleteAction.CASCADE);
secConfig.setKeyCreator(
new ShipmentByPartKeyCreator(javaCatalog,
ShipmentKey.class,
ShipmentData.class,
PartKey.class));
shipmentByPartDb = env.openSecondaryDatabase(null, SHIPMENT_PART_INDEX,
shipmentDb, secConfig);
secConfig.setForeignKeyDatabase(supplierDb);
secConfig.setForeignKeyDeleteAction(ForeignKeyDeleteAction.CASCADE);
secConfig.setKeyCreator(
new ShipmentBySupplierKeyCreator(javaCatalog,
ShipmentKey.class,
ShipmentData.class,
SupplierKey.class));
shipmentBySupplierDb = env.openSecondaryDatabase(null,
SHIPMENT_SUPPLIER_INDEX,
shipmentDb, secConfig);
}
示例12: SampleDatabase
import com.sleepycat.je.SecondaryConfig; //导入方法依赖的package包/类
/**
* Open all storage containers, indices, and catalogs.
*/
public SampleDatabase(String homeDirectory)
throws DatabaseException, FileNotFoundException {
// Open the Berkeley DB environment in transactional mode.
//
System.out.println("Opening environment in: " + homeDirectory);
EnvironmentConfig envConfig = new EnvironmentConfig();
envConfig.setTransactional(true);
envConfig.setAllowCreate(true);
env = new Environment(new File(homeDirectory), envConfig);
// Set the Berkeley DB config for opening all stores.
//
DatabaseConfig dbConfig = new DatabaseConfig();
dbConfig.setTransactional(true);
dbConfig.setAllowCreate(true);
// Create the Serial class catalog. This holds the serialized class
// format for all database records of serial format.
//
Database catalogDb = env.openDatabase(null, CLASS_CATALOG, dbConfig);
javaCatalog = new StoredClassCatalog(catalogDb);
// Open the Berkeley DB database for the part, supplier and shipment
// stores. The stores are opened with no duplicate keys allowed.
//
partDb = env.openDatabase(null, PART_STORE, dbConfig);
supplierDb = env.openDatabase(null, SUPPLIER_STORE, dbConfig);
shipmentDb = env.openDatabase(null, SHIPMENT_STORE, dbConfig);
// Open the SecondaryDatabase for the city index of the supplier store,
// and for the part and supplier indices of the shipment store.
// Duplicate keys are allowed since more than one supplier may be in
// the same city, and more than one shipment may exist for the same
// supplier or part. A foreign key constraint is defined for the
// supplier and part indices to ensure that a shipment only refers to
// existing part and supplier keys. The CASCADE delete action means
// that shipments will be deleted if their associated part or supplier
// is deleted.
//
SecondaryConfig secConfig = new SecondaryConfig();
secConfig.setTransactional(true);
secConfig.setAllowCreate(true);
secConfig.setSortedDuplicates(true);
secConfig.setKeyCreator(new SupplierByCityKeyCreator(javaCatalog,
Supplier.class));
supplierByCityDb = env.openSecondaryDatabase(null, SUPPLIER_CITY_INDEX,
supplierDb, secConfig);
secConfig.setForeignKeyDatabase(partDb);
secConfig.setForeignKeyDeleteAction(ForeignKeyDeleteAction.CASCADE);
secConfig.setKeyCreator(new ShipmentByPartKeyCreator(javaCatalog,
Shipment.class));
shipmentByPartDb = env.openSecondaryDatabase(null, SHIPMENT_PART_INDEX,
shipmentDb, secConfig);
secConfig.setForeignKeyDatabase(supplierDb);
secConfig.setForeignKeyDeleteAction(ForeignKeyDeleteAction.CASCADE);
secConfig.setKeyCreator(new ShipmentBySupplierKeyCreator(javaCatalog,
Shipment.class));
shipmentBySupplierDb = env.openSecondaryDatabase(null,
SHIPMENT_SUPPLIER_INDEX,
shipmentDb, secConfig);
}
示例13: SampleDatabase
import com.sleepycat.je.SecondaryConfig; //导入方法依赖的package包/类
/**
* Open all storage containers, indices, and catalogs.
*/
public SampleDatabase(String homeDirectory)
throws DatabaseException {
// Open the Berkeley DB environment in transactional mode.
//
System.out.println("Opening environment in: " + homeDirectory);
EnvironmentConfig envConfig = new EnvironmentConfig();
envConfig.setTransactional(true);
envConfig.setAllowCreate(true);
env = new Environment(new File(homeDirectory), envConfig);
// Set the Berkeley DB config for opening all stores.
//
DatabaseConfig dbConfig = new DatabaseConfig();
dbConfig.setTransactional(true);
dbConfig.setAllowCreate(true);
// Create the Serial class catalog. This holds the serialized class
// format for all database records of serial format.
//
Database catalogDb = env.openDatabase(null, CLASS_CATALOG, dbConfig);
javaCatalog = new StoredClassCatalog(catalogDb);
// Open the Berkeley DB database for the part, supplier and shipment
// stores. The stores are opened with no duplicate keys allowed.
//
partDb = env.openDatabase(null, PART_STORE, dbConfig);
supplierDb = env.openDatabase(null, SUPPLIER_STORE, dbConfig);
shipmentDb = env.openDatabase(null, SHIPMENT_STORE, dbConfig);
// Open the SecondaryDatabase for the city index of the supplier store,
// and for the part and supplier indices of the shipment store.
// Duplicate keys are allowed since more than one supplier may be in
// the same city, and more than one shipment may exist for the same
// supplier or part. A foreign key constraint is defined for the
// supplier and part indices to ensure that a shipment only refers to
// existing part and supplier keys. The CASCADE delete action means
// that shipments will be deleted if their associated part or supplier
// is deleted.
//
SecondaryConfig secConfig = new SecondaryConfig();
secConfig.setTransactional(true);
secConfig.setAllowCreate(true);
secConfig.setSortedDuplicates(true);
secConfig.setKeyCreator(new SupplierByCityKeyCreator(javaCatalog,
SupplierData.class));
supplierByCityDb = env.openSecondaryDatabase(null, SUPPLIER_CITY_INDEX,
supplierDb, secConfig);
secConfig.setForeignKeyDatabase(partDb);
secConfig.setForeignKeyDeleteAction(ForeignKeyDeleteAction.CASCADE);
secConfig.setKeyCreator(new ShipmentByPartKeyCreator(javaCatalog,
ShipmentData.class));
shipmentByPartDb = env.openSecondaryDatabase(null, SHIPMENT_PART_INDEX,
shipmentDb, secConfig);
secConfig.setForeignKeyDatabase(supplierDb);
secConfig.setForeignKeyDeleteAction(ForeignKeyDeleteAction.CASCADE);
secConfig.setKeyCreator(new ShipmentBySupplierKeyCreator(javaCatalog,
ShipmentData.class));
shipmentBySupplierDb = env.openSecondaryDatabase(null,
SHIPMENT_SUPPLIER_INDEX,
shipmentDb, secConfig);
}