Skip to content

Entity created with default timestamp is null #2412

@fabianloewe

Description

@fabianloewe

I have the following table:

object MyTable : LongIdTable() {
    // ...
    val created = timestamp("created").defaultExpression(CurrentTimestamp).databaseGenerated()
    val modified = timestamp("modified").defaultExpression(CurrentTimestamp).databaseGenerated()
    // ...
}

and the following entity:

class MyEntity(id: EntityID<Long>) : LongEntity(id) {
    companion object : LongEntityClass<MyEntity>(MyTable)

    // ...
    val created by MyTable.created
    var modified by MyTable.modified
    // ...
}

Now, if I create the entity with:

val obj = MyEntity.new {
    // All properties are initialized except created and modified
}

// Fails
assertNotNull(obj.created)

But in the IDEA debugger, if I click on the property, it shows the Instant object that has been created in the database.
If I run into the assertion after clicking the property, the assertion doesn't fail anymore.
How is that possible?

Metadata

Metadata

Assignees

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