Skip to content

Commit

Permalink
Merge pull request #242 from JetBrains/ytdb-226-entity-renew
Browse files Browse the repository at this point in the history
Reimplementation of resetToNew method - second attempt.
  • Loading branch information
andrii0lomakin authored Jan 16, 2025
2 parents 02c9072 + f32f06f commit 4b52a10
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 5 deletions.
2 changes: 1 addition & 1 deletion entity-store/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
dependencies {
api(project(":xodus-openAPI"))
api("io.youtrackdb:youtrackdb-core:1.0.0-20250116.103948-6")
api("io.youtrackdb:youtrackdb-core:1.0.0-20250116.142259-7")

implementation(project(":xodus-utils"))
implementation(project(":xodus-environment"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,12 @@
*/
package jetbrains.exodus.entitystore.orientdb

import com.jetbrains.youtrack.db.api.DatabaseSession
import jetbrains.exodus.entitystore.EntityStore
import jetbrains.exodus.entitystore.PersistentEntityId

interface OEntityStore : EntityStore {
val databaseSession: DatabaseSession

fun requireActiveTransaction(): OStoreTransaction

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@ class OPersistentEntityStore(

private val currentTransaction = ThreadLocal<OStoreTransaction>()

override val databaseSession: DatabaseSession
get() {
val tx = currentTransaction.get() ?: throw IllegalStateException("There is no active database session")
return tx.databaseSession
}

override fun close() {
//or it should be closed independently
currentTransaction.get()?.abort()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,10 +130,8 @@ open class OVertexEntity(vertex: Vertex, private val store: OEntityStore) : OEnt
val clusterId = identity.clusterId
identity.reset()

vertexRecord = store.requireActiveTransaction().databaseSession.newVertex(oEntityId.getTypeName())
(vertexRecord as RecordAbstract).also {
(it.identity as RecordId).clusterId = clusterId
}
identity.clusterId = clusterId
vertexRecord = (store.databaseSession as DatabaseSessionInternal).newVertex(identity)
}

override fun generateId() {
Expand Down

0 comments on commit 4b52a10

Please sign in to comment.