jpa list converter
时间: 2023-09-14 21:11:13 浏览: 132
spring_jpa_demo.zip
JPA (Java Persistence API) provides a way to convert collections of non-standard types to and from the database. To convert a list of objects to a database column, you can create a custom converter using the `@Converter` annotation.
Here's an example of how you can create a converter for a list of strings:
```java
import javax.persistence.AttributeConverter;
import javax.persistence.Converter;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
@Converter
public class ListConverter implements AttributeConverter<List<String>, String> {
private static final String DELIMITER = ",";
阅读全文