Skip to content

Support seqName in IdTable #2438

@leechoongyon

Description

@leechoongyon

I am using the oracle Table Sequence and declaring IdTable to use BatchUpdateStatement. To use BatchUpdateStatement, a table declared with IdTable is required.

ex) object TestTable: IntIdTable(
) {
	
}

BatchUpdateStatement(TestTable).xxx

Threr are two questions.

Question 1. I cannot input sequenceName in IdTable. Therefore, I am using it as shown below. Is it okay to use it this way?

// The existing source
open class IntIdTable(name: String = "", columnName: String = "id") : IdTable<Int>(name) {
    /** The identity column of this [IntIdTable], for storing 4-byte integers wrapped as [EntityID] instances. */
    final override val id: Column<EntityID<Int>> = integer(columnName).autoIncrement().entityId()
    final override val primaryKey = PrimaryKey(id)
}

// The source I developed (idSeqName has been added to the source)
open class IntIdTableWithAutoIncrementSequence(name: String = "", columnName: String = "id", idSeqName: String? = null) : IdTable<Int>(name) {
    /** The identity column of this [IntIdTableWithAutoIncrementSequence], for storing 4-byte integers wrapped as [EntityID] instances. */
    final override val id: Column<EntityID<Int>> = integer(columnName).autoIncrement(idSeqName).entityId()
    final override val primaryKey = PrimaryKey(id)
}

Question 2. Is it okay to propose a PR for the following content? (idSeqName has been added to the source)

// The existing source
open class LongIdTable(name: String = "", columnName: String = "id") : IdTable<Long>(name) {
    /** The identity column of this [LongIdTable], for storing 8-byte integers wrapped as [EntityID] instances. */
    final override val id: Column<EntityID<Long>> = long(columnName).autoIncrement().entityId()
    final override val primaryKey = PrimaryKey(id)
}


open class IntIdTable(name: String = "", columnName: String = "id") : IdTable<Int>(name) {
    /** The identity column of this [IntIdTable], for storing 4-byte integers wrapped as [EntityID] instances. */
    final override val id: Column<EntityID<Int>> = integer(columnName).autoIncrement().entityId()
    final override val primaryKey = PrimaryKey(id)
}



// The source I developed (idSeqName has been added to the source)
open class LongIdTable(name: String = "", columnName: String = "id", idSeqName: String? = null) : IdTable<Long>(name) {
    /** The identity column of this [LongIdTable], for storing 8-byte integers wrapped as [EntityID] instances. */
    final override val id: Column<EntityID<Long>> = long(columnName).autoIncrement(idSeqName).entityId()
    final override val primaryKey = PrimaryKey(id)
}

open class IntIdTable(name: String = "", columnName: String = "id", idSeqName: String? = null) : IdTable<Int>(name) {
    /** The identity column of this [IntIdTable], for storing 4-byte integers wrapped as [EntityID] instances. */
    final override val id: Column<EntityID<Int>> = integer(columnName).autoIncrement(idSeqName).entityId()
    final override val primaryKey = PrimaryKey(id)
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions