2017-04-19 13 views
1

在同一個Environment實例中是否可以使用PersistentEntityStore和一個或多個普通Store實例?我希望能夠使用涵蓋這種組合變化的交易。 我發現潛在的商店名稱衝突,我不得不避免。還要別的嗎?在同一個Xodus環境中混合存儲

回答

0

在單個事務中可以混合使用不同API層的代碼。唯一的要求是不同API所觸及的數據應該被隔離,應該使用不相交的名稱集Stores

PersistentEntityStore使用的Stores是什麼名稱?任何PersistentEntityStore都有其自己的唯一名稱和所有Stores的名稱,它們表示實體存儲到鍵/值層的映射,從"${PersistentEntityStore name}."開始,因爲它在source code中指定。

另一個問題是API對於這種方法並不完整。經過StoreTransaction是對PersistentEntityStore創建的,它應該被強制轉換爲PersistentStoreTransaction爲了調用PersistentStoreTransaction#getEnvironmentTransaction()爲獲得潛在交易:

final StoreTransaction txn = entityStore.beginTransaction(); 
// here is underlying Transaction instance: 
final Transaction envTxn = ((PersistentStoreTransaction) txn).getEnvironmentTransaction(); 
相關問題