babyfish-ct / jimmer

A revolutionary ORM framework for both java and kotlin.
Apache License 2.0
876 stars 88 forks source link

[BUG] When there is a nullable BigInteger type in the entity, an error occurs stating 'Cannot invoke "java.math.BigDecimal.toBigInteger()" because "decimal" is null' #658

Closed ClearPlume closed 2 months ago

ClearPlume commented 2 months ago

Below is the definition of this entity:

@Entity
interface Export {
    @Id
    val id: String

    val size: BigInteger?
}

Here is the code at the location of the error:

private static class BigIntegerReader implements Reader<BigInteger> {
    @Override
    public BigInteger read(ResultSet rs, Context ctx) throws SQLException {
        BigDecimal decimal = rs.getBigDecimal(ctx.col());
        return decimal.toBigInteger();
    }
}

From the code, it can be seen that after extracting a BigDecimal from the ResultSet, there is no null check before directly calling toBigInteger, which caused this problem.

babyfish-ct commented 2 months ago

Try 0.8.171