简体   繁体   中英

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.

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. How can I fix this?

The JdbcPagingItemReader knows nothing about JPA mappings. It requires a RowMapper in order to map items to your domain type Clothing .

What you need to use is rather the JpaPagingItemReader which knows about @Entity annotated classes and how to map them to items.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM