java - JPA EclipseLink Custom Entity/Object as IN Parameter -
i have stored procedures working when pass in basic java objects (string, long, etc.) cant seem pass in own entity/object without getting following error:
exception [eclipselink-4002] (eclipse persistence services - 2.5.2.v20140319-9ad6abd): org.eclipse.persistence.exceptions.databaseexception internal exception: java.sql.sqlexception: invalid column type error code: 17004 call: begin sar_ops.input_rule_no_response(operation_id_in=>?, executing_usr_id_in=>?, rule_obj_in=>?, success_ind_out=>?, error_cur_out=>?); end; bind => [mo1234abcd, test, rule [id=99999, last_updated_by=mike], => success_ind_out, => error_cur_out] query: resultsetmappingquery(name="input_rule_no_response" )
from reading thought code work (see below). added @struct annotation , gave name of matching oracle object database. under impression eclispelink documentation need @embeddable , @struct annotations on class, have added @entity annotation whilst testing theory still same error. feel must missing form of configuration eclipselink know object im passing in java class representation of oracle object expects.
oracle object , stored proc definition:
procedure input_rule_no_response ( operation_id_in in operation_id_type ,executing_usr_id_in in usr_id%type ,rule_obj_in in rule_obj_type ,success_ind_out out uttype.boolean_type ,error_cur_out out sys_refcursor ) ... create or replace type rule_obj_type object ( id number(10), last_updated_by varchar2(100) )
my stored procedure defined as:
@namedstoredprocedurequery( name="input_rule_no_response", resultclasses={dberror.class, rule.class}, procedurename="sar_ops.input_rule_no_response", parameters={ @storedprocedureparameter(name="operation_id_in", mode=parametermode.in, type=string.class), @storedprocedureparameter(name="executing_usr_id_in", mode=parametermode.in, type=string.class), @storedprocedureparameter(name="rule_obj_in", mode=parametermode.in, type=rule.class), @storedprocedureparameter(name="success_ind_out", mode=parametermode.out, type=character.class), @storedprocedureparameter(name="error_cur_out", mode=parametermode.ref_cursor, type=void.class) })
and entity looks like:
@embeddable @entity @struct(name="rule_obj_type", fields={"id","last_updated_by"}) public class rule implements serializable{ private static final long serialversionuid = 4768354320081279604l; @id @column(name="id") private long id; @column(name="last_updated_by") private string last_updated_by; public long getid() { return id; } public void setid(long id) { this.id = id; } public string getlast_updated_by() { return last_updated_by; } public void setlast_updated_by(string last_updated_by) { this.last_updated_by = last_updated_by; } @override public string tostring() { return "rule [id=" + id + ", last_updated_by=" + last_updated_by + "]"; } }
and execute code:
public boolean inputrulenoresponse(rule sar) { storedprocedurequery query = em.createnamedstoredprocedurequery("input_rule_no_response"); query.setparameter("operation_id_in", "mo1234abcd"); query.setparameter("executing_usr_id_in", "test"); query.setparameter("rule_obj_in", sar); return query.execute(); }
the answer add jdbctype , jdbctypename stored procedure configuration suggested chris.
Comments
Post a Comment