public class PsqlArrayAdaptor extends java.lang.Object implements ValueAdaptor
public class Pet {
public static Pet getInstance(ResultSet rs) throws SQLException {
Pet pet = new Pet();
pet.setId(rs.getInt("id"));
pet.setPayByQuarter((Integer[]) rs.getArray("pay_by_quarter").getArray());
return pet;
}
@Column("pay_by_quarter")
@ColDefine(customType = "integer[]", type = ColType.PSQL_ARRAY)
private Integer[] payByQuarter;
// ... 省略后面代码,包括字段声明以及 getter 和 setter
}
public class Jone {
public Jone(ResultSet rs) throws SQLException {
this.id = rs.getInt("id");
this.schedule = (String[]) rs.getArray("schedule").getArray();
}
@ColDefine(customType = "varchar[]", type = ColType.PSQL_ARRAY)
private String[] schedule;
// ... 省略后面代码,包括字段声明以及 getter 和 setter
}
| 构造器和说明 |
|---|
PsqlArrayAdaptor(java.lang.String customDbType) |
public java.lang.Object get(java.sql.ResultSet rs,
java.lang.String colName)
throws java.sql.SQLException
ValueAdaptorget 在接口中 ValueAdaptorrs - 结果集colName - 列名java.sql.SQLExceptionpublic void set(java.sql.PreparedStatement stat,
java.lang.Object obj,
int index)
throws java.sql.SQLException
ValueAdaptor一个值可以被设置到多个占位符中
set 在接口中 ValueAdaptorstat - 缓冲语句obj - 值index - 占位符位置,从 1 开始java.sql.SQLException