I'm working with AS8 (build b08-fcs), DB2 Connect 8.2, on Linux (IA32) connecting to a z/os UDB server.
The connection pings, the beans deploy, create / update / etc. works. Data is being commited to the database, and EJB-QL such as the following work flaslessly.
SELECT OBJECT(p) FROM Person AS p
If only everything were so simple.
When I try to do the following query (which worked when we used CMP on a MS-SQL server), things don't go so well.
select object(p) from Person p where p.firstName like ?1
I get the following error:
SQL statement<select t0."DATEOFBIRTH", t0."FIRSTNAME", t0."GENDER", t0."LASTNAME", t0."MIDDLENAME", t0."PERSONID", t0."SALUTATION", t0."SUFFIX" from "PERSON" t0 where t0."FIRSTNAME" like CAST (? AS VARCHAR(32672))> with input values:java.lang.String:Admin%.
Please examine the SQLException for more information.
NestedException: com.ibm.db2.jcc.b.SqlException: DB2 SQL error: SQLCODE: -132, SQLSTATE: 42824, SQLERRMC: null
Why on earth would this be trying to CAST the parameter as a VARCHAR with a maximum length? That seems a bit... stupid. Removing the CAST from my test queries with the db2 control center resulting in accurate responses, adding the CAST resulted in the same error. Following is the table definition for the Person table (where this query is failing).
CREATE TABLE WEBBASE.Person (
personId INTEGER NOT NULL,
salutation CHAR(5),
firstName VARCHAR(50) NOT NULL,
middleName VARCHAR(15),
lastName VARCHAR(50) NOT NULL,
suffix CHAR(3),
gender SMALLINT NOT NULL,
dateOfBirth DATE,
PRIMARY KEY(personId)
) IN WEBBASE.TBSPPRSN;
FYI: Before invoking the finder method, a '%' is prepended to the parameter at ?1. in EJB-QL the query would end up being something along the lines of:
select object(p) from Person p where p.firstName like "%jack"
As I said, this worked fine with MS-SQL...
Any help is greatly appreciated.