betweenGo

Archive for January, 2007

HibernateException: Found two representations of same collection

by on Jan.26, 2007, under Hibernate

Sometimes you might stumble upon this confusing exception.

org.hibernate.HibernateException: Found two representations of same collection: com.betweengo.Foos

This could have happened because after clearing a Hibernate session (session.clear()) you updated a property that contains a collection. I found just making sure to clear the session once seemed to fix the problem but that may not be a suitable solution in more complex situations.

More information about this problem can be found at http://forum.hibernate.org/viewtopic.php?p=2231400.

Share
Leave a Comment : more...

Catching Oracle exceptions

by on Jan.26, 2007, under Hibernate, Oracle

Oracle SQL queries can throw exceptions. For example in this query f there is no data then Oracle will throw a NO_DATA_FOUND exception.

SELECT status_date INTO v_status_date FROM member WHERE member_id = p_member_id_in;

ORA-01403: no data found

If this query is part of a stored procedure and is called from Hibernate you will get this uninformative exception.

org.hibernate.exception.DataException: could not execute query

Oracle SQL, like many languages, has a try catch construct. In this example you could do the following.

BEGIN
  SELECT status_date INTO v_status_date FROM member WHERE member_id = p_member_id_in;
EXCEPTION
  WHEN NO_DATA_FOUND THEN
    v_status_date := NULL;
END;

Share
Leave a Comment :, more...

Calling Oracle Stored Procedures and Functions

by on Jan.22, 2007, under Oracle

Calling an Oracle function is quite simple. For example

SELECT package.register(1, "Frank", "Kim") FROM dual;

However calling Oracle stored procedures is a bit more tricky, especially if the Oracle stored procedure has output parameters. Here is an example of how to call an Oracle stored procedure that has three input parameters and two output parameters.


DECLARE p_credit_status_out INTEGER;
p_school_status_out INTEGER;

BEGIN
package.get_status(1, "Frank", "Kim", p_credit_status_out, p_school_status_out);
END;
/

Share
Leave a Comment : more...

Oracle Triggers

by on Jan.05, 2007, under Oracle

Creation

CREATE TRIGGER trig_frank
    BEFORE INSERT ON table_frank
    FOR EACH ROW
    BEGIN
        SELECT seq_frank.nextval
        INTO :new.id
        FROM dual;
    END;

.
RUN;

References

Share
Leave a Comment : more...

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!