我在Oracle DB中创建了一个类型:
create or replace TYPE client_type AS OBJECT
(
NMB NUMBER(7,0),
TITLE VARCHAR2(30),
);
之后我用Java创建了一个相应的类;
public class Client implements SQLData {
private int nmb;
private String title;
public int getNmb() {
return ncst;
}
public void setNmb(int nmb) {
this.nmb = nmb;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
@Override
public String getSQLTypeName() throws SQLException {
return "CLIENT_TYPE";
}
@Override
public void readSQL(SQLInput stream, String typeName) throws SQLException {
setNmb(stream.readInt());
setTitle(stream.readString());
}
@Override
public void writeSQL(SQLOutput stream) throws SQLException {
stream.writeInt(getNmb());
stream.writeString(getTitle());
}
}
然后我调用一个过程来插入新数据:
SimpleJdbcCall jdbcCall = new SimpleJdbcCall(jdbcTemplate).withProcedureName("P_INSERTCLIENT");
jdbcCall.declareParameters(new SqlParameter("P_CLIENT", OracleTypes.STRUCT, "CLIENT_TYPE"));
Map in = Collections.singletonMap("P_CLIENT", customer);
jdbcCall.execute(in);
NMB插入表中,TITLE值设置为null ... 我试图更改我的client_type,添加了一个DATE,它也被正确插入。
我在使用字符串做错了什么 - > varchar字段?