I am using spring to interact with postgresql. Here is my problem.
Person have three attributes:
If I try to get a list of person from database using the method below
List<Person> person= getJdbcTemplate().query("select * from person where name=?",new BeanPropertyRowMapper<person>(Person.class),name);
The compiler prompts
Failed to convert property value of type 'org.postgresql.jdbc.PgArray' to required type 'java.lang.String[]' for property 'hobbies';
Is there any way to map pgarray to java array?
By implementing our own RowMapper
public class PersonRowMapper implements RowMapper<Person>
Now, we can manipulate the result of rs.getArray(), then return person.
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.