I'm trying to get Hibernate to call a stored procedure on insert, and I am running into the following error:
Hibernate: {exec virtual_currency.test_proc(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)}
13:18:33,244 WARN [org.hibernate.util.JDBCExceptionReporter] SQL Error: 0, SQLState: null
13:18:33,244 ERROR [org.hibernate.util.JDBCExceptionReporter] Batch entry 0 exec virtual_currency.test_proc(1, 17, 0, 0, 0.0, 0, 0, 100.0, 1, 2008-02-11 13:18:32.994000 -08:00:00, 35) was aborted. Call getNextException to see the cause.
13:18:33,244 WARN [org.hibernate.util.JDBCExceptionReporter] SQL Error: 0, SQLState: 0100E
13:18:33,244 ERROR [org.hibernate.util.JDBCExceptionReporter] A result was returned when none was expected.
I'm not sure what the problem is, since the procedure is not returning anything. Any help is much appreciated.
Environment:
Hibernate 3
DB: Postgres 8.2
Driver: PostgreSQL 8.2 JDBC4 with SSL (build 508)
Java 6
Here is the sql-insert from my Hibernate mapping file:
<sql-insert callable="true">{exec virtual_currency.test_proc(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)}</sql-insert>
And here is the procedure definition:
PROCEDURE test_proc (
p_account_id IN integer,
p_virtual_currency_id IN integer,
p_character_id IN integer,
p_game_id IN integer,
p_balance IN double precision,
p_virtual_currency_balance_id IN integer,
p_event_action_id IN integer,
p_trans_amt IN double precision,
p_modified_by IN integer,
p_last_update_date IN timestamp,
p_id IN integer
)
IS
DECLARE
BEGIN
return;
END;
I also tried it as a function and got a different error:
Hibernate: select nextval ('virtual_currency_balance_audit_id_seq')
Hibernate: {call virtual_currency.test_proc(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)}
13:25:13,372 ERROR [org.hibernate.jdbc.AbstractBatcher] Exception executing batch:
org.hibernate.StaleStateException: Batch update returned unexpected row count from update [0]; actual row count: 0; expected: 1
Mapping:
<sql-insert callable="true">{call virtual_currency.test_proc(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)}</sql-insert>
Function defintion:
FUNCTION test_proc (
p_account_id IN integer,
p_virtual_currency_id IN integer,
p_character_id IN integer,
p_game_id IN integer,
p_balance IN double precision,
p_virtual_currency_balance_id IN integer,
p_event_action_id IN integer,
p_trans_amt IN double precision,
p_modified_by IN integer,
p_last_update_date IN timestamp,
p_id IN integer
)
RETURN integer
IS
DECLARE
BEGIN
return 1;
END;
|