You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The scalar property can be set to null to INSERT/UPDATE null values.
Actual behavior
The exception is thrown:
java.lang.IllegalArgumentException: 'title' cannot be null, please specify non-null value or use nullable annotation to decorate this property
at io.learnbydoing.models.BookDraft$Producer$DraftImpl.setTitle(BookDraft.java:628)
at io.learnbydoing.repository.BookRepository.lambda$insertExplicitlySetTitleToNull$1(BookRepository.java:23)
at org.babyfish.jimmer.runtime.Internal.modifyDraft(Internal.java:173)
at org.babyfish.jimmer.runtime.Internal.lambda$produce$0(Internal.java:28)
at org.babyfish.jimmer.runtime.Internal.usingDraftContext(Internal.java:102)
at org.babyfish.jimmer.runtime.Internal.produce(Internal.java:26)
at io.learnbydoing.models.BookDraft$Producer.produce(BookDraft.java:123)
at io.learnbydoing.models.BookDraft$Producer.produce(BookDraft.java:119)
at io.learnbydoing.repository.BookRepository.insertExplicitlySetTitleToNull(BookRepository.java:18)
at io.learnbydoing.repository.BookRepositoryTest.insertExplicitlySetTitleToNull(BookRepositoryTest.java:38)
at java.base/java.lang.reflect.Method.invoke(Method.java:568)
at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
In the Null Handling section of the documentation, there is an example with the Draft type of setting the property to null. This is the property of the relation, strictly speaking, and the generated BookDraft indeed would allow storing the null in the storeId. However, if I want to explicitly set the scalar property to null, the exception is thrown:
java.lang.IllegalArgumentException: 'title' cannot be null, please specify non-null value or use nullable annotation to decorate this property
The title property itself is both nullable in the H2 database, and in the POJO and is marked with @TNullable
Reproduction steps
Clone the project and execute the test BookRepositoryTest#insertExplicitlySetTitleToNull()
Generated SQL
N/A
Relation Model
The schema is set up in the init.sql in the test resources by the following SQL:
CREATE TABLE IF NOT EXISTS AUTHOR(
ID BIGSERIAL PRIMARY KEY,
FIRST_NAME TEXT NOT NULL,
LAST_NAME TEXT NOT NULL
);
CREATE TABLE IF NOT EXISTS BOOK(
ID BIGSERIAL PRIMARY KEY,
TITLE TEXT,
CREATED_AT TEXT,
AUTHOR_ID BIGINT NOT NULL REFERENCES AUTHOR(ID)
);
Screenshots
N/A
Logs
Already pasted above
The text was updated successfully, but these errors were encountered:
The annotation is designed for jimmer-swagger, not the orm itself.
The annotation org.jetbrains.annotations.Nullabe(or any annotation whose name ends with Nullable or Null) id designed for the framework.
This org.jetbrains.annotations.Nullabe can be used like this
@Nullable
Type value;
but, unfortunately, it cannot be used like this
List<@Nullable ElementType> values;
So this annotation is designed like this
List<@TNullable ElementType> values;
If original design goal of this annotation is to support more nullity information which cannot be described by jetbrains annotation. let the nullity information can be as powerful as kotlin.
If the framework itself wants to support TNullable, its package org.babyfish.jimmer.clinet must be renamed to org.babyfish.jimmer.lang, is it acceptalbe?
If it should be used to affect the behavior of the framework itself, its package org.babyfish.jimmer.clinet must be renamed to org.babyfish.jimmer.lang, is it acceptalbe?
Jimmer Version
0.9.37
JDK Version
JDK 17
Database
H2
OS
Linux
Expected behavior
The scalar property can be set to
null
toINSERT
/UPDATE
null values.Actual behavior
The exception is thrown:
Description
I've created the MRE, please check here: https://github.com/mipo256/jimmer-draft-scalar-to-null
In the Null Handling section of the documentation, there is an example with the Draft type of setting the property to
null
. This is the property of the relation, strictly speaking, and the generatedBookDraft
indeed would allow storing thenull
in thestoreId
. However, if I want to explicitly set the scalar property tonull
, the exception is thrown:java.lang.IllegalArgumentException: 'title' cannot be null, please specify non-null value or use nullable annotation to decorate this property
The
title
property itself is both nullable in the H2 database, and in the POJO and is marked with@TNullable
Reproduction steps
Clone the project and execute the test
BookRepositoryTest#insertExplicitlySetTitleToNull()
Generated SQL
N/A
Relation Model
The schema is set up in the
init.sql
in the test resources by the following SQL:Screenshots
N/A
Logs
Already pasted above
The text was updated successfully, but these errors were encountered: