pgsql exception.

From: Ravi <nm(dot)ravi2005(at)gmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: pgsql exception.
Date: 2010-02-22 12:41:09
Message-ID: bf8f49251002220441h1089e658j78237c8b4afdcc91@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi,
while passing util list to Postgres stored procedure getting an exception
saying
*org.postgresql.util.PSQLException: Cannot cast an instance of
java.util.ArrayList to type Types.ARRAY*
can you help to resolve it? its urgent

Method in Dao
public void savePerson(Person person, List<Address> addresses, List<Email>
emails, List<Phone> numbers){
call.withProcedureName("
person_save1");

Map<String, Object> out = call.execute(new
PGPerson(person),addresses,null,null);

}

*SP in Database*

CREATE OR REPLACE FUNCTION person_save(person_to_save person, addresses
address[], emails email[], numbers phone[])
RETURNS void AS
$BODY$
DECLARE
per_id bigint;
BEGIN
IF person_to_save.id

IS NULL OR person_to_save.id

= 0 THEN
SELECT INTO per_id nextval('people_id_seq');
INSERT INTO person (id, first_name,last_name,middle_name) values
(per_id, person_to_save.first_name, person_to_save.last_name,
person_to_save.middle_name);
ELSE
per_id := person_to_save.id

;
UPDATE person SET first_name=person_to_save.first_name,
last_name=person_to_save.last_name, middle_name=person_to_save.middle_name
WHERE id = person_to_save.id

;
END IF;
IF addresses IS NOT NULL THEN
EXECUTE person_addresses_save(per_id, addresses);
END IF;
IF emails IS NOT NULL THEN
EXECUTE person_emails_save(per_id, emails);
END IF;
IF numbers IS NOT NULL THEN
EXECUTE person_phones_save(per_id, numbers);
END IF;
END;$BODY$
LANGUAGE 'plpgsql' VOLATILE
COST 100;
ALTER FUNCTION person_save(person, address[], email[], phone[]) OWNER TO
postgres;
COMMENT ON FUNCTION person_save(person, address[], email[], phone[]) IS
'Saves a person. If the person is new they will insert or if they exist
they will update.
Will do the same for the other objects also addresses, emails, phone';

*exception raised is

org.postgresql.util.PSQLException: Cannot cast an instance of
java.util.ArrayList to type Types.ARRAY*

--
Ravi.T
BayLogic Technologies India Pvt. Ltd.
Vizag.

Browse pgsql-general by date

  From Date Subject
Next Message mike stanton 2010-02-22 13:35:03 ECPG: No multidimensional array support for simple data types
Previous Message AI Rumman 2010-02-22 12:29:40 tsearch2 gives NOTICE: word is too long