Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp
Hibernate version: 3.2 cr1
Mapping documents:
Code:
<hibernate-mapping default-lazy="false" package="com.joshlia.logic">
<class name="Department" table="department">
<id name="id" column="id">
<generator class="sequence">
<param name="sequence">dept_seq</param>
</generator>
</id>
<property name="name" column="name" />
<sql-insert callable="true">{call USP_DEPARTMENT_I(?)}</sql-insert>
</class>
</hibernate-mapping>
Code between sessionFactory.openSession() and session.close():Code:
session.connection();
session.beginTransaction();
Department department=new Department();
department.setName(name);
session.save(department);
Full stack trace of any exception that occurs:Name and version of the database you are using:Oracle 9i
The generated SQL (show_sql=true):Code:
Hibernate:
select
dept_seq.nextval
from
dual
Hibernate:
{call USP_DEPARTMENT_I(?)}
Debug level Hibernate log excerpt:Code:
Aug 23, 2006 5:26:13 PM org.hibernate.util.JDBCExceptionReporter logExceptions
WARNING: SQL Error: 1006, SQLState: 72000
Aug 23, 2006 5:26:13 PM org.hibernate.util.JDBCExceptionReporter logExceptions
SEVERE: ORA-01006: bind variable does not exist
Aug 23, 2006 5:26:13 PM org.hibernate.event.def.AbstractFlushingEventListener performExecutions
SEVERE: Could not synchronize database state with session
org.hibernate.exception.GenericJDBCException: could not insert: [com.joshlia.logic.Department]
at org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:103)
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:91)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2140)
at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2503)
at org.hibernate.action.EntityInsertAction.execute(EntityInsertAction.java:51)
at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:248)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:232)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:139)
at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:297)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:988)
at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:337)
at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:106)
at com.joshlia.Office.createAndStoreDepartment(Office.java:48)
at com.joshlia.Office.main(Office.java:18)
Caused by: java.sql.SQLException: ORA-01006: bind variable does not exist
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:134)
at oracle.jdbc.ttc7.TTIoer.processError(TTIoer.java:289)
at oracle.jdbc.ttc7.Oall7.receive(Oall7.java:582)
at oracle.jdbc.ttc7.TTC7Protocol.doOall7(TTC7Protocol.java:1986)
at oracle.jdbc.ttc7.TTC7Protocol.parseExecuteFetch(TTC7Protocol.java:1144)
at oracle.jdbc.driver.OracleStatement.executeNonQuery(OracleStatement.java:2152)
at oracle.jdbc.driver.OracleStatement.doExecuteOther(OracleStatement.java:2035)
at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:2876)
at oracle.jdbc.driver.OraclePreparedStatement.executeUpdate(OraclePreparedStatement.java:609)
at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2123)
... 12 more
Oracle Stored Proc:Code:
CREATE OR REPLACE PROCEDURE "JOSHUA"."USP_DEPARTMENT_I"
(
-- id_in in department.id%type,
name_in in department.name%type,
result_cursor out TYPES.cursor_type
)
as
begin
insert into department(
-- department.id,
department.name
)values(
-- emp_seq.nextval,
name_in
);
OPEN result_cursor FOR SELECT 'success' AS status FROM dual;
end;
Dear all,
How do I connect to Oracle Stored Procedure? Can anyone help me regarding this matter?