Hi,

I have created and deployed a container managed entity bean using Orion
v0.81 connecting to a Sybase DBMS.  I can retrieve and update existing bean
instances without any problems.  However, if I try to create a new instance
of the bean, I get the following SQL exception:

12/19/99 5:15 PM Error in bean DailyEntry
java.sql.SQLException: JZ0SA: Prepared Statement: Input parameter not set,
index: 1.
        at com.sybase.jdbc.ErrorMessage.raiseError(ErrorMessage.java)
        at com.sybase.tds.TdsParam.prepareForSend(TdsParam.java, Compiled
Code)
        at com.sybase.jdbc.ParamManager.checkParams(ParamManager.java,
Compiled Code)
        at com.sybase.tds.Tds.language(Tds.java, Compiled Code)
        at com.sybase.jdbc.SybStatement.sendQuery(SybStatement.java,
Compiled Code)
        at
com.sybase.jdbc.SybPreparedStatement.sendQuery(SybPreparedStatement.java,
Compiled Code)
        at com.sybase.jdbc.SybStatement.executeQuery(SybStatement.java)
        at
com.sybase.jdbc.SybPreparedStatement.executeQuery(SybPreparedStatement.java)
        at EntityHomeWrapper1.create(EntityHomeWrapper1.java:275)
        at NewTaskDetailsProc.saveTaskDetails(NewTaskDetailsProc.java:219)
        at NewTaskDetailsProc.doPost(NewTaskDetailsProc.java:71)
            [...]

I have decompiled the EntityHomeWrapper1 wrapper class to see what it is
trying to do, and the problem is with the code that sets up the SQL
statement that checks to ensure that the new bean instance does not already
exist in the database.  I am using a compound key, and the
preparedStatement.set method calls for each of the key fields are all using
the same argument index (1), rather than an incrementing index.  Here is the
relevant code:

                PreparedStatement preparedstatement = getSelectStatement();
                if(entitybeanwrapper0.object.employeeCode == null)
                    preparedstatement.setNull(1, 12);
                else
                    preparedstatement.setString(1,
entitybeanwrapper0.object.employeeCode);
                if(entitybeanwrapper0.object.costCentreCode == null)
                    preparedstatement.setNull(1, 12);
                else
                    preparedstatement.setString(1,
entitybeanwrapper0.object.costCentreCode);
                if(entitybeanwrapper0.object.activityCode == null)
                    preparedstatement.setNull(1, 12);
                else
                    preparedstatement.setString(1,
entitybeanwrapper0.object.activityCode);
                if(entitybeanwrapper0.object.premiseCode == null)
                    preparedstatement.setNull(1, 12);
                else
                    preparedstatement.setString(1,
entitybeanwrapper0.object.premiseCode);
                preparedstatement.setInt(1,
entitybeanwrapper0.object.startTime);

Is this a bug?  As far as I can tell, my ejb-jar.xml and orion-ejb-jar.xml
files look okay...

Any help would be greatly appreciated.

Cheers,
Paul.
--
Paul Hosking
Solutions Architect
Software Development Solutions
Innovus .........
........Helping Good Businesses Do Better

Phone:  64 4 472 0877
Fax:    64 4 472 0858
mailto:[EMAIL PROTECTED]
http://www.innovus.co.nz



Reply via email to