ITADN

Entity created with default timestamp is null

#2412Openfabianloewe 创建于 2025-02-18
F
fabianloewecommented
I have the following table: ```kotlin object MyTable : LongIdTable() { // ... val created = timestamp("created").defaultExpression(CurrentTimestamp).databaseGenerated() val modified = timestamp("modified").defaultExpression(CurrentTimestamp).databaseGenerated() // ... } ``` and the following entity: ```kotlin 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: ```kotlin 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?
4 条评论