/** Create the data bindings and collection views. */ public SampleViews(SampleDatabase db) { // Create the data bindings. // In this sample, EntityBinding classes are used to bind the stored // key/data entry pair to a combined data object; a "tricky" binding // that uses transient fields is used--see PartBinding, etc, for // details. For keys, a one-to-one binding is implemented with // EntryBinding classes to bind the stored tuple entry to a key Object. // ClassCatalog catalog = db.getClassCatalog(); EntryBinding partKeyBinding = new PartKeyBinding(); EntityBinding partDataBinding = new PartBinding(catalog, Part.class); EntryBinding supplierKeyBinding = new SupplierKeyBinding(); EntityBinding supplierDataBinding = new SupplierBinding(catalog, Supplier.class); EntryBinding shipmentKeyBinding = new ShipmentKeyBinding(); EntityBinding shipmentDataBinding = new ShipmentBinding(catalog, Shipment.class); EntryBinding cityKeyBinding = TupleBinding.getPrimitiveBinding(String.class); // Create map views for all stores and indices. // StoredSortedMap is used since the stores and indices are ordered // (they use the DB_BTREE access method). // partMap = new StoredSortedMap(db.getPartDatabase(), partKeyBinding, partDataBinding, true); supplierMap = new StoredSortedMap( db.getSupplierDatabase(), supplierKeyBinding, supplierDataBinding, true); shipmentMap = new StoredSortedMap( db.getShipmentDatabase(), shipmentKeyBinding, shipmentDataBinding, true); shipmentByPartMap = new StoredSortedMap( db.getShipmentByPartDatabase(), partKeyBinding, shipmentDataBinding, true); shipmentBySupplierMap = new StoredSortedMap( db.getShipmentBySupplierDatabase(), supplierKeyBinding, shipmentDataBinding, true); supplierByCityMap = new StoredSortedMap( db.getSupplierByCityDatabase(), cityKeyBinding, supplierDataBinding, true); }
/** Create the data bindings and collection views. */ public SampleViews(SampleDatabase db) { // Create the data bindings. // In this sample, the stored key and data entries are used directly // rather than mapping them to separate objects. Therefore, no binding // classes are defined here and the SerialBinding class is used. // ClassCatalog catalog = db.getClassCatalog(); EntryBinding partKeyBinding = new SerialBinding(catalog, PartKey.class); EntryBinding partDataBinding = new SerialBinding(catalog, PartData.class); EntryBinding supplierKeyBinding = new SerialBinding(catalog, SupplierKey.class); EntryBinding supplierDataBinding = new SerialBinding(catalog, SupplierData.class); EntryBinding shipmentKeyBinding = new SerialBinding(catalog, ShipmentKey.class); EntryBinding shipmentDataBinding = new SerialBinding(catalog, ShipmentData.class); EntryBinding cityKeyBinding = new SerialBinding(catalog, String.class); // Create map views for all stores and indices. // StoredSortedMap is not used since the stores and indices are // ordered by serialized key objects, which do not provide a very // useful ordering. // partMap = new StoredSortedMap(db.getPartDatabase(), partKeyBinding, partDataBinding, true); supplierMap = new StoredSortedMap( db.getSupplierDatabase(), supplierKeyBinding, supplierDataBinding, true); shipmentMap = new StoredSortedMap( db.getShipmentDatabase(), shipmentKeyBinding, shipmentDataBinding, true); shipmentByPartMap = new StoredSortedMap( db.getShipmentByPartDatabase(), partKeyBinding, shipmentDataBinding, true); shipmentBySupplierMap = new StoredSortedMap( db.getShipmentBySupplierDatabase(), supplierKeyBinding, shipmentDataBinding, true); supplierByCityMap = new StoredSortedMap( db.getSupplierByCityDatabase(), cityKeyBinding, supplierDataBinding, true); }