问题
As a system analyst, I develop a class object mapping the columns of tables , so that I can call stored procedures to return a list of class objects as json array. Throughout examining the SQL structure of the table, there is a composite key made of LOOKUP_CODE and LOOKUP_TYPE.
The sql database is Oracle 9i
Result : Some fields are missing to be returned
Would you please devise the strategies to match the columns under this case?
Here is my table columns :
Here is the SQL:
CREATE TABLE "PC_LOOKUP"
( "LOOKUP_TYPE" VARCHAR2(30 BYTE) NOT NULL ENABLE,
"LOOKUP_CODE" VARCHAR2(30 BYTE) NOT NULL ENABLE,
"LOOKUP_VALUE" VARCHAR2(100 BYTE) NOT NULL ENABLE,
"LOOKUP_DESC" VARCHAR2(200 BYTE),
"LAST_UPD_DATE" DATE NOT NULL ENABLE,
"LAST_UPD_BY" VARCHAR2(8 BYTE) NOT NULL ENABLE,
CONSTRAINT "B_PC_LOOKUP_PK" PRIMARY KEY ("LOOKUP_TYPE", "LOOKUP_CODE")
Here is my class (LookUp.java):
@NamedStoredProcedureQueries({
@NamedStoredProcedureQuery(name = "call_look_up_list",
procedureName = "pkg.get_pc_lookup_value",
parameters = {
@StoredProcedureParameter(mode = ParameterMode.IN, name = "i_lookup_type", type = String.class),
@StoredProcedureParameter(mode = ParameterMode.IN, name = "i_lookup_code", type = String.class),
@StoredProcedureParameter(mode = ParameterMode.REF_CURSOR, name = "o_lookup_value", type = void.class)
}),
@NamedStoredProcedureQuery(name = "call_look_up_single",
procedureName = "pkg.get_pc_lookup_value_prim",
parameters = {
@StoredProcedureParameter(mode = ParameterMode.IN, name = "i_lookup_type", type = String.class),
@StoredProcedureParameter(mode = ParameterMode.IN, name = "i_lookup_code", type = String.class),
@StoredProcedureParameter(mode = ParameterMode.OUT, name = "o_lookup_value", type = String.class)
})
})
public class LookUp implements Serializable{
@Transient
private static final long serialVersionUID = 3506968846904417333L;
@Column(nullable = false , insertable = false, updatable=false, name = "LAST_UPD_BY" )
private String lastUpdateBy;
@Column(nullable = false , insertable = false, updatable=false, columnDefinition = "TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP" , name = "LAST_UPD_DATE")
private Date lastUpdateDate = new Date();
@EmbeddedId
private LookUpCompositeKey privateKey;
@Column(nullable = true , name = "LOOKUP_DESC")
private String desc;
@Column(nullable = false , name = "LOOKUP_VALUE")
private String value;
Here is my class : (LookUpCompositeKey .java)
@Embeddable
public class LookUpCompositeKey implements Serializable {
private static final long serialVersionUID = -5628924656701586906L;
@Column( name = "LOOKUP_TYPE")
String type;
@Column( name = "LOOKUP_CODE")
String code;
public LookUpCompositeKey() {
}
来源:https://stackoverflow.com/questions/58848271/oracle9i-jpa-hibernate-namedstoredprocedurequery-string-attributes-of-my-objec