[英]Java Spring Batch Embedded fields on model always null
I'm having issues where the JdbcPagingItemReader can't pull in the values for fields that have been annotated with @Embedded. 我遇到了JdbcPagingItemReader无法提取使用@Embedded注释的字段的值的问题。
For example: 例如:
@Entity
@Data
class Clothing {
String name;
@Embedded
Cost total;
}
During the batch job, the name will be correct, but the total is always null. 在批处理作业中,名称将是正确的,但总数始终为null。 How can I fix this?
我怎样才能解决这个问题?
The JdbcPagingItemReader
knows nothing about JPA mappings. JdbcPagingItemReader
对JPA映射一无所知。 It requires a RowMapper
in order to map items to your domain type Clothing
. 它需要使用
RowMapper
才能将项目映射到您的域类型Clothing
。
What you need to use is rather the JpaPagingItemReader
which knows about @Entity
annotated classes and how to map them to items. 您需要使用的是
JpaPagingItemReader
,它了解@Entity
注释的类以及如何将它们映射到项目。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.