Stored Procedure error

View: New views
4 Messages — Rating Filter:   Alert me  

Stored Procedure error

by khaskett :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

We have a stored Procedure call to a SQL Server database that is erroring out.
The primary key read from the row [DatabaseRecord(
        paramAgentNumber => XXXXXXXXX
        paramAgentSubcode => ZZZZZZZ
        paramInitials => ABC
        paramLastName => SOME
        paramFirstName => ONE
        paramEmail => SONE@xyz.com                                  
        paramReturn => null)] during the execution of the query was detected to be null.  Primary keys must not contain null.

Which indicates that part of the primary key is returning null, specifically paramReturn.  But the primary key does not include paramReturn.

Here is the call -

        final ReadObjectQuery readObjectQuery = new ReadObjectQuery(CpUser.class);
        final StoredProcedureCall call = new StoredProcedureCall();
        call.setProcedureName("spMSIRetrieveByUserID");
        call.addNamedArgumentValue(CpUserManagerImpl.PARAM_USER_ID, argumentValue);
        call.addNamedOutputArgument(CpUserManagerImpl.PARAM_AGENT_NUMBER);
        call.addNamedOutputArgument(CpUserManagerImpl.PARAM_AGENT_SUBCODE);
        call.addNamedOutputArgument(CpUserManagerImpl.PARAM_INITIALS);
        call.addNamedOutputArgument(CpUserManagerImpl.PARAM_LAST_NAME);
        call.addNamedOutputArgument(CpUserManagerImpl.PARAM_FIRST_NAME);
        call.addNamedOutputArgument(CpUserManagerImpl.PARAM_EMAIL);
        call.addNamedOutputArgument(CpUserManagerImpl.PARAM_RETURN);
        readObjectQuery.setCall(call);

        return (CpUser) getSession().executeQuery(readObjectQuery);

Here is the entity -

@Entity
public class CpUser extends BaseDomain {

    // Attributes
    @Id
    @Column(name = "paramUserID")
    private String userId;

    @Column(name = "paramInitials")
    private String initials;

    @Column(name = "paramBinarySession")
    private String binarySessionID;

    @Column(name = "paramFirstName")
    private String firstName;

    @Column(name = "paramLastName")
    private String lastName;

    @Column(name = "paramAgentNumber")
    private String producer;

    @Column(name = "paramAgentSubcode")
    private String contractNumber;

    @Column(name = "paramEmail")
    private String emailAddress;

    @Column(name = "paramReturn")
    private int result;

Any ideas on what is wrong?

Re: Stored Procedure error

by James Sutherland :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Your procedure must return all of the column values required for the object, including its primary key paramUserID.  Currently your row does not include that value.  Perhaps make the PARAM_USER_ID an INOUT param.

khaskett wrote:
We have a stored Procedure call to a SQL Server database that is erroring out.
The primary key read from the row [DatabaseRecord(
        paramAgentNumber => XXXXXXXXX
        paramAgentSubcode => ZZZZZZZ
        paramInitials => ABC
        paramLastName => SOME
        paramFirstName => ONE
        paramEmail => SONE@xyz.com                                  
        paramReturn => null)] during the execution of the query was detected to be null.  Primary keys must not contain null.

Which indicates that part of the primary key is returning null, specifically paramReturn.  But the primary key does not include paramReturn.

Here is the call -

        final ReadObjectQuery readObjectQuery = new ReadObjectQuery(CpUser.class);
        final StoredProcedureCall call = new StoredProcedureCall();
        call.setProcedureName("spMSIRetrieveByUserID");
        call.addNamedArgumentValue(CpUserManagerImpl.PARAM_USER_ID, argumentValue);
        call.addNamedOutputArgument(CpUserManagerImpl.PARAM_AGENT_NUMBER);
        call.addNamedOutputArgument(CpUserManagerImpl.PARAM_AGENT_SUBCODE);
        call.addNamedOutputArgument(CpUserManagerImpl.PARAM_INITIALS);
        call.addNamedOutputArgument(CpUserManagerImpl.PARAM_LAST_NAME);
        call.addNamedOutputArgument(CpUserManagerImpl.PARAM_FIRST_NAME);
        call.addNamedOutputArgument(CpUserManagerImpl.PARAM_EMAIL);
        call.addNamedOutputArgument(CpUserManagerImpl.PARAM_RETURN);
        readObjectQuery.setCall(call);

        return (CpUser) getSession().executeQuery(readObjectQuery);

Here is the entity -

@Entity
public class CpUser extends BaseDomain {

    // Attributes
    @Id
    @Column(name = "paramUserID")
    private String userId;

    @Column(name = "paramInitials")
    private String initials;

    @Column(name = "paramBinarySession")
    private String binarySessionID;

    @Column(name = "paramFirstName")
    private String firstName;

    @Column(name = "paramLastName")
    private String lastName;

    @Column(name = "paramAgentNumber")
    private String producer;

    @Column(name = "paramAgentSubcode")
    private String contractNumber;

    @Column(name = "paramEmail")
    private String emailAddress;

    @Column(name = "paramReturn")
    private int result;

Any ideas on what is wrong?

RE: Stored Procedure error

by khaskett :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I changed the Stored Proc to be an INOUT param and I changed the call
from my code to be -

call.addNamedInOutputArgumentValue(CpUserManagerImpl.PARAM_USER_ID,
argumentValue,
    CpUserManagerImpl.PARAM_USER_ID, java.lang.String.class);
call.addNamedOutputArgument(CpUserManagerImpl.PARAM_AGENT_NUMBER);

But I am still getting an error -
[6/10/09 15:21:15:703 CDT] 0000003b SystemOut     O [EL Fine]:
2009-06-10
15:21:15.687--ServerSession(2028632298)--Connection(430447016)--Thread(T
hread[WebContainer : 1,5,main])--EXECUTE spMSIRetrieveByUserID
@paramUserID  = ? , @paramAgentNumber = ? , @paramAgentSubcode = ? ,
@paramInitials = ? , @paramLastName = ? , @paramFirstName = ? ,
@paramEmail = ? , @paramReturn = ?
        bind => [KHASKETT => paramUserID , => paramAgentNumber, =>
paramAgentSubcode, => paramInitials, => paramLastName, =>
paramFirstName, => paramEmail, => paramReturn]
[6/10/09 15:21:15:765 CDT] 0000003b SystemOut     O [EL Warning]:
2009-06-10
15:21:15.765--UnitOfWork(298193350)--Thread(Thread[WebContainer :
1,5,main])--Exception [EclipseLink-6044] (Eclipse Persistence Services -
1.1.1.v20090430-r4097):
org.eclipse.persistence.exceptions.QueryException
Exception Description: The primary key read from the row
[DatabaseRecord(
        paramUserID  => khaskett
        paramAgentNumber => XXXXXXXXX
        paramAgentSubcode => YYYYYYY
        paramInitials => ABC
        paramLastName => Some
        paramFirstName => One
        paramEmail => SOne@...
        paramReturn => 0)] during the execution of the query was
detected to be null.  Primary keys must not contain null.
Query: ReadObjectQuery(referenceClass=CpUser )

>From the results it would appear that paramUserID should be getting set
now.

-----Original Message-----
From: eclipselink-users-bounces@...
[mailto:eclipselink-users-bounces@...] On Behalf Of James
Sutherland
Sent: Wednesday, June 10, 2009 12:34 PM
To: eclipselink-users@...
Subject: Re: [eclipselink-users] Stored Procedure error


Your procedure must return all of the column values required for the
object, including its primary key paramUserID.  Currently your row does
not include that value.  Perhaps make the PARAM_USER_ID an INOUT param.


khaskett wrote:

>
> We have a stored Procedure call to a SQL Server database that is
> erroring out.
> The primary key read from the row [DatabaseRecord(
> paramAgentNumber => XXXXXXXXX
> paramAgentSubcode => ZZZZZZZ
> paramInitials => ABC
> paramLastName => SOME
> paramFirstName => ONE
> paramEmail => SONE@...
> paramReturn => null)] during the execution of the query was
detected

> to be null.  Primary keys must not contain null.
>
> Which indicates that part of the primary key is returning null,
> specifically paramReturn.  But the primary key does not include
> paramReturn.
>
> Here is the call -
>
>         final ReadObjectQuery readObjectQuery = new
> ReadObjectQuery(CpUser.class);
>         final StoredProcedureCall call = new StoredProcedureCall();
>         call.setProcedureName("spMSIRetrieveByUserID");
>         call.addNamedArgumentValue(CpUserManagerImpl.PARAM_USER_ID,
> argumentValue);
>
> call.addNamedOutputArgument(CpUserManagerImpl.PARAM_AGENT_NUMBER);
>
> call.addNamedOutputArgument(CpUserManagerImpl.PARAM_AGENT_SUBCODE);
>         call.addNamedOutputArgument(CpUserManagerImpl.PARAM_INITIALS);
>
call.addNamedOutputArgument(CpUserManagerImpl.PARAM_LAST_NAME);
>
call.addNamedOutputArgument(CpUserManagerImpl.PARAM_FIRST_NAME);

>         call.addNamedOutputArgument(CpUserManagerImpl.PARAM_EMAIL);
>         call.addNamedOutputArgument(CpUserManagerImpl.PARAM_RETURN);
>         readObjectQuery.setCall(call);
>
>         return (CpUser) getSession().executeQuery(readObjectQuery);
>
> Here is the entity -
>
> @Entity
> public class CpUser extends BaseDomain {
>
>     // Attributes
>     @Id
>     @Column(name = "paramUserID")
>     private String userId;
>
>     @Column(name = "paramInitials")
>     private String initials;
>
>     @Column(name = "paramBinarySession")
>     private String binarySessionID;
>
>     @Column(name = "paramFirstName")
>     private String firstName;
>
>     @Column(name = "paramLastName")
>     private String lastName;
>
>     @Column(name = "paramAgentNumber")
>     private String producer;
>
>     @Column(name = "paramAgentSubcode")
>     private String contractNumber;
>
>     @Column(name = "paramEmail")
>     private String emailAddress;
>
>     @Column(name = "paramReturn")
>     private int result;
>
> Any ideas on what is wrong?
>


-----
http://wiki.eclipse.org/User:James.sutherland.oracle.com James
Sutherland http://www.eclipse.org/eclipselink/
 EclipseLink ,  http://www.oracle.com/technology/products/ias/toplink/
TopLink
Wiki:  http://wiki.eclipse.org/EclipseLink EclipseLink ,
http://wiki.oracle.com/page/TopLink TopLink
Forums:  http://forums.oracle.com/forums/forum.jspa?forumID=48 TopLink ,
http://www.nabble.com/EclipseLink-f26430.html EclipseLink
Book:  http://en.wikibooks.org/wiki/Java_Persistence Java Persistence
--
View this message in context:
http://www.nabble.com/Stored-Procedure-error-tp23890538p23967269.html
Sent from the EclipseLink - Users mailing list archive at Nabble.com.

_______________________________________________
eclipselink-users mailing list
eclipselink-users@...
https://dev.eclipse.org/mailman/listinfo/eclipselink-users


This message (including any attachments) is intended only for
the use of the individual or entity to which it is addressed and
may contain information that is non-public, proprietary,
privileged, confidential, and exempt from disclosure under
applicable law or may constitute as attorney work product.
If you are not the intended recipient, you are hereby notified
that any use, dissemination, distribution, or copying of this
communication is strictly prohibited. If you have received this
communication in error, notify us immediately by telephone and
(i) destroy this message if a facsimile or (ii) delete this message
immediately if this is an electronic communication.

Thank you.
_______________________________________________
eclipselink-users mailing list
eclipselink-users@...
https://dev.eclipse.org/mailman/listinfo/eclipselink-users

RE: Stored Procedure error

by James Sutherland :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

The row does seem to have the id column now, so the error is odd.  Check your descriptor as see if its primaryKeyFields are what you think they are, do you have an orm.xml or are you overriding the id column somewhere.


khaskett wrote:
I changed the Stored Proc to be an INOUT param and I changed the call
from my code to be -

call.addNamedInOutputArgumentValue(CpUserManagerImpl.PARAM_USER_ID,
argumentValue,
    CpUserManagerImpl.PARAM_USER_ID, java.lang.String.class);
call.addNamedOutputArgument(CpUserManagerImpl.PARAM_AGENT_NUMBER);

But I am still getting an error -
[6/10/09 15:21:15:703 CDT] 0000003b SystemOut     O [EL Fine]:
2009-06-10
15:21:15.687--ServerSession(2028632298)--Connection(430447016)--Thread(T
hread[WebContainer : 1,5,main])--EXECUTE spMSIRetrieveByUserID
@paramUserID  = ? , @paramAgentNumber = ? , @paramAgentSubcode = ? ,
@paramInitials = ? , @paramLastName = ? , @paramFirstName = ? ,
@paramEmail = ? , @paramReturn = ?
        bind => [KHASKETT => paramUserID , => paramAgentNumber, =>
paramAgentSubcode, => paramInitials, => paramLastName, =>
paramFirstName, => paramEmail, => paramReturn]
[6/10/09 15:21:15:765 CDT] 0000003b SystemOut     O [EL Warning]:
2009-06-10
15:21:15.765--UnitOfWork(298193350)--Thread(Thread[WebContainer :
1,5,main])--Exception [EclipseLink-6044] (Eclipse Persistence Services -
1.1.1.v20090430-r4097):
org.eclipse.persistence.exceptions.QueryException
Exception Description: The primary key read from the row
[DatabaseRecord(
        paramUserID  => khaskett
        paramAgentNumber => XXXXXXXXX
        paramAgentSubcode => YYYYYYY
        paramInitials => ABC
        paramLastName => Some
        paramFirstName => One
        paramEmail => SOne@xyz.com
        paramReturn => 0)] during the execution of the query was
detected to be null.  Primary keys must not contain null.
Query: ReadObjectQuery(referenceClass=CpUser )

>From the results it would appear that paramUserID should be getting set
now.

-----Original Message-----
From: eclipselink-users-bounces@eclipse.org
[mailto:eclipselink-users-bounces@eclipse.org] On Behalf Of James
Sutherland
Sent: Wednesday, June 10, 2009 12:34 PM
To: eclipselink-users@eclipse.org
Subject: Re: [eclipselink-users] Stored Procedure error


Your procedure must return all of the column values required for the
object, including its primary key paramUserID.  Currently your row does
not include that value.  Perhaps make the PARAM_USER_ID an INOUT param.


khaskett wrote:
>
> We have a stored Procedure call to a SQL Server database that is
> erroring out.
> The primary key read from the row [DatabaseRecord(
> paramAgentNumber => XXXXXXXXX
> paramAgentSubcode => ZZZZZZZ
> paramInitials => ABC
> paramLastName => SOME
> paramFirstName => ONE
> paramEmail => SONE@xyz.com
> paramReturn => null)] during the execution of the query was
detected
> to be null.  Primary keys must not contain null.
>
> Which indicates that part of the primary key is returning null,
> specifically paramReturn.  But the primary key does not include
> paramReturn.
>
> Here is the call -
>
>         final ReadObjectQuery readObjectQuery = new
> ReadObjectQuery(CpUser.class);
>         final StoredProcedureCall call = new StoredProcedureCall();
>         call.setProcedureName("spMSIRetrieveByUserID");
>         call.addNamedArgumentValue(CpUserManagerImpl.PARAM_USER_ID,
> argumentValue);
>
> call.addNamedOutputArgument(CpUserManagerImpl.PARAM_AGENT_NUMBER);
>
> call.addNamedOutputArgument(CpUserManagerImpl.PARAM_AGENT_SUBCODE);
>         call.addNamedOutputArgument(CpUserManagerImpl.PARAM_INITIALS);
>
call.addNamedOutputArgument(CpUserManagerImpl.PARAM_LAST_NAME);
>
call.addNamedOutputArgument(CpUserManagerImpl.PARAM_FIRST_NAME);
>         call.addNamedOutputArgument(CpUserManagerImpl.PARAM_EMAIL);
>         call.addNamedOutputArgument(CpUserManagerImpl.PARAM_RETURN);
>         readObjectQuery.setCall(call);
>
>         return (CpUser) getSession().executeQuery(readObjectQuery);
>
> Here is the entity -
>
> @Entity
> public class CpUser extends BaseDomain {
>
>     // Attributes
>     @Id
>     @Column(name = "paramUserID")
>     private String userId;
>
>     @Column(name = "paramInitials")
>     private String initials;
>
>     @Column(name = "paramBinarySession")
>     private String binarySessionID;
>
>     @Column(name = "paramFirstName")
>     private String firstName;
>
>     @Column(name = "paramLastName")
>     private String lastName;
>
>     @Column(name = "paramAgentNumber")
>     private String producer;
>
>     @Column(name = "paramAgentSubcode")
>     private String contractNumber;
>
>     @Column(name = "paramEmail")
>     private String emailAddress;
>
>     @Column(name = "paramReturn")
>     private int result;
>
> Any ideas on what is wrong?
>