# <img src="https://raw.githubusercontent.com/wiki/jetbrains/xodus/xodus.png" width=160>
The **Entity Stores** layer is designed to access data as [entities](https://github.com/JetBrains/xodus/blob/master/openAPI/src/main/java/jetbrains/exodus/entitystore/Entity.java) with attributes and links. Use a [transaction](https://github.com/JetBrains/xodus/blob/master/openAPI/src/main/java/jetbrains/exodus/entitystore/StoreTransaction.java) to create, modify, read and query data. Transactions are quite similar to [those](https://github.com/JetBrains/xodus/blob/master/openAPI/src/main/java/jetbrains/exodus/env/Transaction.java) on the **Environments** layer, though the **Entity Store** API is much richer in terms of querying data. The API and the implementation live in the _jetbrains.exodus.entitystore_ package.
[PersistentEntityStore](https://github.com/JetBrains/xodus/wiki/Entity-Stores#persistententitystore)
<br>[Transactions](https://github.com/JetBrains/xodus/wiki/Entity-Stores#transactions)
<br>[Entities](https://github.com/JetBrains/xodus/wiki/Entity-Stores#entities)
<br>[Properties](https://github.com/JetBrains/xodus/wiki/Entity-Stores#properties)
<br>[Links](https://github.com/JetBrains/xodus/wiki/Entity-Stores#links)
<br>[Blobs](https://github.com/JetBrains/xodus/wiki/Entity-Stores#blobs)
<br>[Queries](https://github.com/JetBrains/xodus/wiki/Entity-Stores#queries)
<br> [Iterating over All Entities of Specified Type](https://github.com/JetBrains/xodus/wiki/Entity-Stores#iterating-over-all-entities-of-specified-type)
<br> [EntityIterable](https://github.com/JetBrains/xodus/wiki/Entity-Stores#entityiterable)
<br> [EntityIterator](https://github.com/JetBrains/xodus/wiki/Entity-Stores#entityiterator)
<br> [Searching by Property Value](https://github.com/JetBrains/xodus/wiki/Entity-Stores#searching-by-property-value)
<br> [Searching in Range of Property Values](https://github.com/JetBrains/xodus/wiki/Entity-Stores#searching-in-range-of-property-values)
<br> [Traversing Links](https://github.com/JetBrains/xodus/wiki/Entity-Stores#traversing-links)
<br> [SelectDistinct and SelectManyDistinct](https://github.com/JetBrains/xodus/wiki/Entity-Stores#selectdistinct-and-selectmanydistinct)
<br> [Binary Operations](https://github.com/JetBrains/xodus/wiki/Entity-Stores#binary-operations)
<br> [Searching for Entities Having Property, Link, Blob](https://github.com/JetBrains/xodus/wiki/Entity-Stores#searching-for-entities-having-property-link-blob)
<br> [Sorting](https://github.com/JetBrains/xodus/wiki/Entity-Stores#sorting)
<br> [Other Goodies](https://github.com/JetBrains/xodus/wiki/Entity-Stores#other-goodies)
<br>[Sequences](https://github.com/JetBrains/xodus/wiki/Entity-Stores#sequences)
## PersistentEntityStore
To open or create an entity store, create an instance of [PersistentEntityStore](https://github.com/JetBrains/xodus/blob/master/openAPI/src/main/java/jetbrains/exodus/entitystore/PersistentEntityStore.java) with the help of the [PersistentEntityStores](https://github.com/JetBrains/xodus/blob/master/entity-store/src/main/java/jetbrains/exodus/entitystore/PersistentEntityStores.java) utility class:
```java
PersistentEntityStore entityStore = PersistentEntityStores.newInstance("/home/me/.myAppData");
```
`PersistentEntityStore` works over `Environment`, so the method that is shown above implicitly creates an `Environment` with the same location. Each `PersistentEntityStore` has a name. You can create several entity stores with different names over an `Environment`. If you don't specify a name, the [default name](https://github.com/JetBrains/xodus/blob/master/entity-store/src/main/java/jetbrains/exodus/entitystore/PersistentEntityStores.java#L30) is used.
`PersistentEntityStore` has different methods to create an instance of a `PersistentEntityStore`. In addition to the underlying `Environment`, you can specify the [BlobValut](https://github.com/JetBrains/xodus/blob/master/openAPI/src/main/java/jetbrains/exodus/entitystore/BlobVault.java) and [PersistentEntityStoreConfig](https://github.com/JetBrains/xodus/blob/master/openAPI/src/main/java/jetbrains/exodus/entitystore/PersistentEntityStoreConfig.java). `BlobVault` is a base class that describes an interface to binary large objects (BLOBs) that are used internally by the implementation of a `PersistentEntityStore`. If you don't specify a `BlobVault` when you create a `PersistentEntityStore`, an instance of the [FileSystemBlobVault](https://github.com/JetBrains/xodus/blob/master/openAPI/src/main/java/jetbrains/exodus/entitystore/FileSystemBlobVault.java) class is used. If you don't specify the `PersistentEntityStoreConfig` when you create a `PersistentEntityStore`, [PersistentEntityStoreConfig.DEFAULT](https://github.com/JetBrains/xodus/blob/master/openAPI/src/main/java/jetbrains/exodus/entitystore/PersistentEntityStoreConfig.java#L58) is used.
Like [ContextualEnvironment](https://github.com/JetBrains/xodus/blob/master/openAPI/src/main/java/jetbrains/exodus/env/ContextualEnvironment.java), `PersistentEntityStore` is always aware of the transaction that is started in the current thread. The [getCurrentTransaction()](https://github.com/JetBrains/xodus/blob/master/openAPI/src/main/java/jetbrains/exodus/entitystore/EntityStore.java#L84) method returns the transaction that is started in the current thread or null if there is no such transaction.
When you are finished working with a `PersistentEntityStore`, call the `close()` method.
## Transactions
[Entity store transactions](https://github.com/JetBrains/xodus/blob/master/openAPI/src/main/java/jetbrains/exodus/entitystore/StoreTransaction.java) are quite similar to the `Environment` layer transactions. To manually start a transaction, use [beginTransaction()](https://github.com/JetBrains/xodus/blob/master/openAPI/src/main/java/jetbrains/exodus/entitystore/EntityStore.java#L56):
```java
final StoreTransaction txn = store.beginTransaction();
```
or [beginReadonlyTransaction()](https://github.com/JetBrains/xodus/blob/master/openAPI/src/main/java/jetbrains/exodus/entitystore/EntityStore.java#L67):
```java
final StoreTransaction txn = store.beginReadonlyTransaction();
```
An attempt to modify data in a read-only transaction fails with a `ReadonlyTransactionException`.
Any transaction should be finished, meaning that it is either aborted or committed. The transaction can also be flushed or reverted. The methods `commit()` and `flush()` return `true` if they succeed. If any method returns `false`, a database version mismatch has occurred. In this case, there are two possibilities: to abort the transaction and finish or revert the transaction and continue. An unsuccessful flush implicitly reverts the transaction and moves it to the latest (newest) database snapshot, so database operations can be repeated against it:
```java
StoreTransaction txn = beginTransaction();
try {
do {
// do something
// if txn has already been aborted in user code
if (txn != getCurrentTransaction()) {
txn = null;
break;
}
} while (!txn.flush());
} finally {
// if txn has not already been aborted in execute()
if (txn != null) {
txn.abort();
}
}
```
If you don't care for such spinning and don't want to control the results of `flush()` and `commit()`, you can use the
[executeInTransaction()](https://github.com/JetBrains/xodus/blob/master/openAPI/src/main/java/jetbrains/exodus/entitystore/PersistentEntityStore.java#L63),
[executeInExclusiveTransaction()](https://github.com/JetBrains/xodus/blob/master/openAPI/src/main/java/jetbrains/exodus/entitystore/PersistentEntityStore.java#L73),
[executeInReadonlyTransaction()](https://github.com/JetBrains/xodus/blob/ma
没有合适的资源?快使用搜索试试~ 我知道了~
xodus,JeTeWork XODUS是JTeWord YouTrand和JETHealthHub使用的一个Java事务无模式...
共978个文件
java:712个
kt:207个
gradle:16个
需积分: 10 0 下载量 177 浏览量
2019-09-24
23:18:35
上传
评论
收藏 2.64MB ZIP 举报
温馨提示
JeTeWork XODUS是一个用Java和Kotlin编写的事务性无模式嵌入式数据库。
资源推荐
资源详情
资源评论
收起资源包目录
xodus,JeTeWork XODUS是JTeWord YouTrand和JETHealthHub使用的一个Java事务无模式嵌入式数据库。.zip (978个子文件)
gradlew.bat 2KB
org.apache.lucene.codecs.Codec 66B
testXD_362.data 19B
jetbrains.exodus.io.DataReaderWriterProvider 225B
jetbrains.exodus.io.DataReaderWriterProvider 165B
jetbrains.exodus.io.DataReaderWriterProvider 60B
pskill.exe 458KB
copyright.ftl 566B
.gitignore 651B
key.gpg 3KB
build.gradle 8KB
build.gradle 2KB
build.gradle 841B
build.gradle 816B
build.gradle 530B
build.gradle 528B
settings.gradle 304B
build.gradle 268B
build.gradle 219B
build.gradle 218B
build.gradle 192B
build.gradle 139B
build.gradle 130B
build.gradle 122B
build.gradle 106B
build.gradle 103B
gradlew 5KB
jna1.jar 607KB
jna0.jar 286KB
gradle-wrapper.jar 53KB
EnvironmentConfig.java 104KB
PersistentEntityStoreImpl.java 92KB
AbstractPersistent23Tree.java 50KB
PersistentStoreTransaction.java 49KB
PersistentEntityStoreRefactorings.java 48KB
EnvironmentImpl.java 42KB
EnvironmentTest.java 39KB
EntityTests.java 31KB
FindTests.java 28KB
VirtualFileSystem.java 28KB
PersistentEntityStoreConfig.java 26KB
EntityIterableBase.java 26KB
StoreTransaction.java 24KB
Persistent23TreeTest.java 24KB
TransactionTest.java 23KB
VfsStreamsTests.java 22KB
BTreeReclaimTest.java 21KB
EntityLinksTests.java 20KB
SortIterable.java 20KB
PatriciaTreeMutable.java 20KB
QueryEngine.java 19KB
TreeCursorDuplicatesTest.java 19KB
PersistentBitTreeLongMap.java 18KB
QueryTreeTest.java 17KB
TreeCursorNoDuplicatesTest.java 17KB
AbstractPersistentHashSet.java 17KB
EntityMetaDataImpl.java 16KB
TreePutTest.java 16KB
MutableNode.java 16KB
PatriciaCursorDecorator.java 16KB
PersistentObjectCache.java 16KB
Persistent23TreeMapTest.java 16KB
FileSystemBlobVaultOld.java 16KB
PersistentLongMapTest.java 16KB
Environment.java 15KB
Entity.java 14KB
LogTests.java 14KB
EntityIterableCache.java 14KB
BTreeMutable.java 13KB
EntityIterableHandleBase.java 13KB
InternalPageMutable.java 13KB
CompressBackupUtil.java 12KB
EntityBlobTests.java 12KB
EnvironmentTestsBase.java 12KB
BinaryOperatorsTests.java 12KB
EntityIterable.java 12KB
ModelMetaDataImpl.java 12KB
SortIndirectIterable.java 12KB
EntityIdArrayCachedInstanceIterableFactory.java 12KB
EntityIdArrayCachedInstanceIterableTests.java 12KB
UniqueKeyIndicesEngine.java 11KB
PatriciaTraverser.java 11KB
BufferedDataWriter.java 11KB
ReadWriteTransaction.java 11KB
MetaTreeImpl.java 11KB
PersistentLinkedHashMap.java 11KB
TreeKeepingEntityIterable.java 11KB
PropertiesIterable.java 11KB
PriorityQueueTest.java 11KB
PersistentHashSetTest.java 11KB
LoggableTests.java 10KB
BlobVault.java 10KB
BottomPageMutable.java 10KB
BinaryOperatorEntityIterable.java 10KB
EnvironmentConfig.java 10KB
BTreePutSpecificTest.java 10KB
HumanReadablePresentationTests.java 10KB
BTreeDeleteSpecificTest.java 10KB
ForkSupportIO.java 10KB
PersistentEntity.java 10KB
共 978 条
- 1
- 2
- 3
- 4
- 5
- 6
- 10
资源评论
weixin_38744270
- 粉丝: 327
- 资源: 2万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功