Skip to content

Commit

Permalink
ids are long
Browse files Browse the repository at this point in the history
  • Loading branch information
coolsamson7 committed Sep 24, 2024
1 parent a22596d commit f3a3568
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 25 deletions.
2 changes: 1 addition & 1 deletion src/main/kotlin/org/sirius/dorm/ObjectManager.kt
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ class ObjectManager() {
}
}

fun findById(descriptor: ObjectDescriptor, id: Int) : DataObject? {
fun findById(descriptor: ObjectDescriptor, id: Long) : DataObject? {
val entity = entityManager.find(EntityEntity::class.java, id)

return if ( entity !== null)
Expand Down
6 changes: 3 additions & 3 deletions src/main/kotlin/org/sirius/dorm/object/DataObject.kt
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@ class DataObject(val type: ObjectDescriptor, status: Status, var state : ObjectS

var objectManager: ObjectManager
get() = type.objectManager!!
set(value) { }
set(_) { }

fun property(property: String) : PropertyDescriptor<Any> {
return type.property(property)
}

var id: Int
get() = values[0].get(objectManager) as Int
var id: Long
get() = values[0].get(objectManager) as Long
set(value) { values[0].set(type.properties[0], value) }


Expand Down
13 changes: 6 additions & 7 deletions src/main/kotlin/org/sirius/dorm/object/MultiValuedRelation.kt
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class MultiValuedRelation(relation: RelationDescriptor<*>, status: Status, val o
if (isLoaded()) {
// synchronize the objects set with the property.relations

val targetMap = HashMap<Int, PropertyEntity>()
val targetMap = HashMap<Long, PropertyEntity>()
val relations = relations()

// collect all targets in a map
Expand Down Expand Up @@ -121,17 +121,16 @@ class MultiValuedRelation(relation: RelationDescriptor<*>, status: Status, val o
override fun remove(element: DataObject): Boolean {
markDirty()

if (objects!!.remove(element)) {
return if (objects!!.remove(element)) {
// take care of inverse

val inverse = inverseRelation(element!!)
if ( inverse !== null) {
val inverse = inverseRelation(element)
if ( inverse !== null)
inverse.removeInverse(element)
}

return true
true
}
else return false
else false
}

override val size: Int
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ data class EntityEntity(
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Id
@Column(name = "ID")
var id : Int,
var id : Long,

@Column(name = "TYPE")
var type : String,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@ data class PropertyEntity(
@Column(name = "DOUBLE_VALUE")
var doubleValue : Double,

@ManyToMany(fetch = FetchType.LAZY)
@ManyToMany(fetch = FetchType.LAZY, cascade = [CascadeType.REMOVE])
@JoinTable(
name = "ATTRIBUTE_RELATION",
joinColumns = [JoinColumn(name = "FROM_ENTITY"), JoinColumn(name = "FROM_ATTRIBUTE")],
inverseJoinColumns = [JoinColumn(name = "TO_ENTITY"), JoinColumn(name = "TO_ATTRIBUTE")]
name = "RELATION",
joinColumns = [JoinColumn(name = "FROM_ENTITY"), JoinColumn(name = "FROM")],
inverseJoinColumns = [JoinColumn(name = "TO_ENTITY"), JoinColumn(name = "TO")]
)
val targets : MutableSet<PropertyEntity> = HashSet(),

Expand Down
4 changes: 2 additions & 2 deletions src/main/kotlin/org/sirius/dorm/query/QueryManager.kt
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ class QueryManager(val objectManager: ObjectManager, private val entityManager:

val result = ArrayList<DataObject>()

var entity = -1
var entity = -1L
var start = -1
var index = 0

Expand Down Expand Up @@ -168,7 +168,7 @@ class QueryManager(val objectManager: ObjectManager, private val entityManager:

val result = ArrayList<Array<Any?>>()

var entity = -1
var entity = -1L
var start = -1
var index = 0
for (attribute in attributes) {
Expand Down
10 changes: 3 additions & 7 deletions src/main/kotlin/org/sirius/dorm/transaction/TransactionState.kt
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ abstract class Operation() {
class TransactionState(val objectManager: ObjectManager, val transactionManager: PlatformTransactionManager) {
// instance data

val states = HashMap<Int, ObjectState>()
val states = HashMap<Long, ObjectState>()
val status : TransactionStatus

val pendingOperations = ArrayList<Operation>()
Expand Down Expand Up @@ -86,15 +86,15 @@ class TransactionState(val objectManager: ObjectManager, val transactionManager:

// public

fun retrieve(id: Int, ifMissing: () -> DataObject) : DataObject {
fun retrieve(id: Long, ifMissing: () -> DataObject) : DataObject {
return states.getOrPut(id) { ObjectState(ifMissing(), Status.MANAGED) }.obj
}

fun register(state: ObjectState) {
states.put(state.obj.id, state)
}

fun create(obj: DataObject) : DataObject{
fun create(obj: DataObject) : DataObject {
val state = ObjectState(obj, Status.CREATED)

obj.entity = EntityEntity(0, obj.type.name, "{}", ArrayList())
Expand All @@ -103,10 +103,6 @@ class TransactionState(val objectManager: ObjectManager, val transactionManager:

obj["id"] = obj.entity!!.id

// force flush

//objectManager.mapper.create(this, obj)

states.put(obj.id, state)

return obj
Expand Down

0 comments on commit f3a3568

Please sign in to comment.