I have such model for saving:
@Table("EXPERIMENTS")
data class Experiment(
@Id val id: Long,
val userId: Long,
val time: String,
@JsonProperty
val data: Any
)
such saving processor:
@PostMapping("/experiment")
fun saveUserExperiment(@RequestBody experiment: Experiment) = service.saveExperiment(experiment)
such service:
@Service
class ExperimentService(val db: ExperimentRepository) {
fun saveExperiment(experiment: Experiment) = db.save(experiment)
...
}
and I save it via postman in such way:
POST /experiment HTTP/1.1
Content-Type: application/json
User-Agent: PostmanRuntime/7.29.2
Accept: */*
Postman-Token: 1c2aaf40-8933-4988-b92a-6694539c3aba
Host: localhost:8080
Accept-Encoding: gzip, deflate, br
Connection: keep-alive
Content-Length: 105
{
"userId":1,
"time": "2018-10-18 05:30:57.907",
"data": {"red":123,"blue":123,"green":123}
}
HTTP/1.1 200 OK
Content-Type: application/json
Transfer-Encoding: chunked
Date: Sat, 30 Jul 2022 15:57:55 GMT
Keep-Alive: timeout=60
Connection: keep-alive
{"id":7,"userId":1,"time":"2018-10-18 05:30:57.907","data":{"red":123,"blue":123,"green":123}}
during saving I receive such error:
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.springframework.util.ReflectionUtils (file:/Users/_t/.gradle/caches/modules-2/files-2.1/org.springframework/spring-core/5.3.2/152489ed8223a6ad19065a3cd1ee6b9e20c0b82f/spring-core-5.3.2.jar) to field java.util.LinkedHashMap.head
WARNING: Please consider reporting this to the maintainers of org.springframework.util.ReflectionUtils
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
and also after fetching the list of models I receive such error:
Parameter specified as non-null is null: method com.example.demo.models.Experiment.<init>, parameter data
list I receive in such way:
@Query("select * from experiments")
fun getExperiments(): List<Experiment>
my database has such table:
experiments: table
+ columns
id: int NN auto_increment = 1
user_id: mediumtext NN
time: timestamp default CURRENT_TIMESTAMP
data: json
+ keys
#1: PK (id) (underlying index PRIMARY)
I'm not sure whether it is ok that I receive 200OK response from the api but json field is null even if I have it filled.