1 8 9 package com.sleepycat.persist; 10 11 import java.util.Set ; 12 13 import com.sleepycat.je.Database; import com.sleepycat.je.DatabaseConfig; 15 import com.sleepycat.je.DatabaseException; 16 import com.sleepycat.je.Environment; 17 import com.sleepycat.je.SecondaryConfig; 18 import com.sleepycat.je.Sequence; 19 import com.sleepycat.je.SequenceConfig; 20 import com.sleepycat.je.Transaction; 21 import com.sleepycat.persist.evolve.EvolveConfig; 22 import com.sleepycat.persist.evolve.EvolveStats; 23 import com.sleepycat.persist.evolve.IncompatibleClassException; 24 import com.sleepycat.persist.evolve.Mutations; 25 import com.sleepycat.persist.impl.Store; 26 import com.sleepycat.persist.model.DeleteAction; 27 import com.sleepycat.persist.model.Entity; import com.sleepycat.persist.model.EntityModel; 29 import com.sleepycat.persist.model.PrimaryKey; 30 import com.sleepycat.persist.model.SecondaryKey; 31 32 122 public class EntityStore { 123 124 private Store store; 125 126 145 public EntityStore(Environment env, String storeName, StoreConfig config) 146 throws DatabaseException, IncompatibleClassException { 147 148 store = new Store(env, storeName, config, false ); 149 } 150 151 154 void dumpCatalog() { 155 store.dumpCatalog(); 156 } 157 158 163 public Environment getEnvironment() { 164 return store.getEnvironment(); 165 } 166 167 172 public StoreConfig getConfig() { 173 return store.getConfig(); 174 } 175 176 181 public String getStoreName() { 182 return store.getStoreName(); 183 } 184 185 191 public static Set <String > getStoreNames(Environment env) 192 throws DatabaseException { 193 194 return Store.getStoreNames(env); 195 } 196 197 204 public EntityModel getModel() { 205 return store.getModel(); 206 } 207 208 215 public Mutations getMutations() { 216 return store.getMutations(); 217 } 218 219 241 public <PK,E> PrimaryIndex<PK,E> getPrimaryIndex(Class <PK> primaryKeyClass, 242 Class <E> entityClass) 243 throws DatabaseException { 244 245 return store.getPrimaryIndex 246 (primaryKeyClass, primaryKeyClass.getName(), 247 entityClass, entityClass.getName()); 248 } 249 250 280 public <SK,PK,E> SecondaryIndex<SK,PK,E> 281 getSecondaryIndex(PrimaryIndex<PK,E> primaryIndex, 282 Class <SK> keyClass, 283 String keyName) 284 throws DatabaseException { 285 286 return store.getSecondaryIndex 287 (primaryIndex, primaryIndex.getEntityClass(), 288 primaryIndex.getEntityClass().getName(), 289 keyClass, keyClass.getName(), keyName); 290 } 291 292 323 public <SK,PK,E1,E2 extends E1> SecondaryIndex<SK,PK,E2> 324 getSubclassIndex(PrimaryIndex<PK,E1> primaryIndex, 325 Class <E2> entitySubclass, 326 Class <SK> keyClass, 327 String keyName) 328 throws DatabaseException { 329 330 331 getModel().getClassMetadata(entitySubclass.getName()); 332 333 return store.getSecondaryIndex 334 (primaryIndex, entitySubclass, 335 primaryIndex.getEntityClass().getName(), 336 keyClass, keyClass.getName(), keyName); 337 } 338 339 357 public EvolveStats evolve(EvolveConfig config) 358 throws DatabaseException { 359 360 return store.evolve(config); 361 } 362 363 378 public void truncateClass(Class entityClass) 379 throws DatabaseException { 380 381 store.truncateClass(null, entityClass); 382 } 383 384 400 public void truncateClass(Transaction txn, Class entityClass) 401 throws DatabaseException { 402 403 store.truncateClass(txn, entityClass); 404 } 405 406 434 public void sync() 435 throws DatabaseException { 436 437 store.sync(); 438 } 439 440 448 public void closeClass(Class entityClass) 449 throws DatabaseException { 450 451 store.closeClass(entityClass); 452 } 453 454 458 public void close() 459 throws DatabaseException { 460 461 store.close(); 462 } 463 464 473 public Sequence getSequence(String name) 474 throws DatabaseException { 475 476 return store.getSequence(name); 477 } 478 479 500 public SequenceConfig getSequenceConfig(String name) { 501 return store.getSequenceConfig(name); 502 } 503 504 525 public void setSequenceConfig(String name, SequenceConfig config) { 526 store.setSequenceConfig(name, config); 527 } 528 529 552 public DatabaseConfig getPrimaryConfig(Class entityClass) { 553 return store.getPrimaryConfig(entityClass); 554 } 555 556 578 public void setPrimaryConfig(Class entityClass, DatabaseConfig config) { 579 store.setPrimaryConfig(entityClass, config); 580 } 581 582 620 public SecondaryConfig getSecondaryConfig(Class entityClass, 621 String keyName) { 622 return store.getSecondaryConfig(entityClass, keyName); 623 } 624 625 665 public void setSecondaryConfig(Class entityClass, 666 String keyName, 667 SecondaryConfig config) { 668 store.setSecondaryConfig(entityClass, keyName, config); 669 } 670 } 671 | Popular Tags |