Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » Exception [EclipseLink-6044] Primary keys must not contain null.
Exception [EclipseLink-6044] Primary keys must not contain null. [message #652866] Mon, 07 February 2011 12:42 Go to next message
imran raza khan is currently offline imran raza khanFriend
Messages: 18
Registered: January 2011
Junior Member
Hi,

I am getting following error


[EL Finer]: 2011-02-07 06:28:03.025--ServerSession(25849454)--Thread(Thread[pool-1- thread-1,5,main])--client acquired
[EL Finest]: 2011-02-07 06:28:03.025--UnitOfWork(10054858)--Thread(Thread[pool-1-thr ead-1,5,main])--Execute query ReadAllQuery(name="createA
utoVoucherPayOrder" referenceClass=AutoVoucherPayOrder )
[EL Fine]: 2011-02-07 06:28:03.025--ServerSession(25849454)--Connection(2920707)-- Thread(Thread[pool-1-thread-1,5,main])--BEGIN TABSMGR.ISN_
CreateAutoVoucherPayOrder(P_Subno=>?, P_CardDetails=>?, P_TransNumber=>?); END;
bind => [3222222222, 1234567890123456, => P_TransNumber]
[EL Warning]: 2011-02-07 06:28:03.664--UnitOfWork(10054858)--Thread(Thread[pool-1-thr ead-1,5,main])--Local Exception Stack:
Exception [EclipseLink-6044] (Eclipse Persistence Services - 2.1.1.v20100817-r8050): org.eclipse.persistence.exceptions.QueryException
Exception Description: The primary key read from the row [DatabaseRecord(
P_TransNumber => 165210601)] during the execution of the query was detected to be null. Primary keys must not contain null.
Query: ReadAllQuery(name="createAutoVoucherPayOrder" referenceClass=AutoVoucherPayOrder )
at org.eclipse.persistence.exceptions.QueryException.nullPrimar yKeyInBuildingObject(QueryException.java:868)
at org.eclipse.persistence.internal.descriptors.ObjectBuilder.b uildObject(ObjectBuilder.java:481)
at org.eclipse.persistence.internal.descriptors.ObjectBuilder.b uildObject(ObjectBuilder.java:454)
at org.eclipse.persistence.queries.ObjectLevelReadQuery.buildOb ject(ObjectLevelReadQuery.java:721)
at org.eclipse.persistence.queries.ReadAllQuery.registerResultI nUnitOfWork(ReadAllQuery.java:723)
at org.eclipse.persistence.queries.ReadAllQuery.executeObjectLe velReadQuery(ReadAllQuery.java:420)
at org.eclipse.persistence.queries.ObjectLevelReadQuery.execute DatabaseQuery(ObjectLevelReadQuery.java:1074)
at org.eclipse.persistence.queries.DatabaseQuery.execute(Databa seQuery.java:736)
at org.eclipse.persistence.queries.ObjectLevelReadQuery.execute (ObjectLevelReadQuery.java:1034)
at org.eclipse.persistence.queries.ReadAllQuery.execute(ReadAll Query.java:380)
at org.eclipse.persistence.queries.ObjectLevelReadQuery.execute InUnitOfWork(ObjectLevelReadQuery.java:1112)
at org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.int ernalExecuteQuery(UnitOfWorkImpl.java:2909)
at org.eclipse.persistence.internal.sessions.AbstractSession.ex ecuteQuery(AbstractSession.java:1291)
at org.eclipse.persistence.internal.sessions.AbstractSession.ex ecuteQuery(AbstractSession.java:1273)
at org.eclipse.persistence.internal.sessions.AbstractSession.ex ecuteQuery(AbstractSession.java:1247)
at org.eclipse.persistence.internal.jpa.EJBQueryImpl.executeRea dQuery(EJBQueryImpl.java:479)
at org.eclipse.persistence.internal.jpa.EJBQueryImpl.getSingleR esult(EJBQueryImpl.java:745)
at com.warid.ss.billpayment.model.BillPaymentService.payBillThr uVoucher(BillPaymentService.java:42)
at com.warid.ss.billpayment.BillPaymentTask.run(BillPaymentTask .java:81)
at java.util.concurrent.Executors$RunnableAdapter.call(Executor s.java:441)
at java.util.concurrent.FutureTask$Sync.innerRunAndReset(Future Task.java:317)
at java.util.concurrent.FutureTask.runAndReset(FutureTask.java: 150)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFu tureTask.access$101(ScheduledThreadPoolExecutor.java:98)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFu tureTask.runPeriodic(ScheduledThreadPoolExecutor.java:181)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFu tureTask.run(ScheduledThreadPoolExecutor.java:205)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Threa dPoolExecutor.java:885)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoo lExecutor.java:907)
at java.lang.Thread.run(Thread.java:619)

Regards,
imran
Re: Exception [EclipseLink-6044] Primary keys must not contain null. [message #652874 is a reply to message #652866] Mon, 07 February 2011 12:50 Go to previous messageGo to next message
imran raza khan is currently offline imran raza khanFriend
Messages: 18
Registered: January 2011
Junior Member
Hi,

Following is my entity class


@Entity
@NamedStoredProcedureQuery(
name="createAutoVoucherPayOrder",
resultClass=AutoVoucherPayOrder.class,
procedureName="AutoVoucherPayOrder",
parameters={
@StoredProcedureParameter(queryParameter="P_Subno" ,direction=Direction.IN, type=String.class),
@StoredProcedureParameter(queryParameter="P_CardDetails", direction=Direction.IN, type=String.class),
@StoredProcedureParameter(queryParameter="P_TransNumber", direction=Direction.OUT, type=Long.class)
}
)
public class AutoVoucherPayOrder implements Serializable {

private static final long serialVersionUID = 1L;

public AutoVoucherPayOrder() {
super();
}


@Id
private Long P_TransNumber = 0L ;
private String P_Subno ;
private String P_CardDetails ;


public String getP_Subno() {
return P_Subno;
}
public void setP_Subno(String p_Subno) {
P_Subno = p_Subno;
}
public String getP_CardDetails() {
return P_CardDetails;
}
public void setP_CardDetails(String p_CardDetails) {
P_CardDetails = p_CardDetails;
}
public Long getP_TransNumber() {
return P_TransNumber;
}
public void setP_TransNumber(Long p_TransNumber) {

P_TransNumber = p_TransNumber;
}

}


and following is my code from where i am calling

Query q2 = tabsEM.createNamedQuery("createAutoVoucherPayOrder");
q2.setParameter("P_Subno", subno);
q2.setParameter("P_CardDetails", voucherNo);
autoVoucherPayOrder = (AutoVoucherPayOrder) q2.getSingleResult();

String transactionNumber = autoVoucherPayOrder.getP_TransNumber().toString();

Regards,
imran

[Updated on: Tue, 08 February 2011 08:01]

Report message to a moderator

Re: Exception [EclipseLink-6044] Primary keys must not contain null. [message #652906 is a reply to message #652866] Mon, 07 February 2011 14:40 Go to previous messageGo to next message
Chris Delahunt is currently offline Chris DelahuntFriend
Messages: 1039
Registered: July 2009
Senior Member
Hello,

The issue now could be that EclipseLink is case sensitive. If so, one of the folliowing should work:
1) Use the case of the Column expected in the parameter definition:
@StoredProcedureParameter(direction=OUT, name="P_TransNumber", queryParameter="P_TRANSNUMBER", type=Long.class),

2) Set the <property name="eclipselink.jpa.uppercase-column-names" value="true"/> property in your persistence.xml.

If these work, the issue is that the stored proc parameter is defined as "P_TransNumber" which results in a null value when "P_TRANSNUMBER" is used for the look up as these strings do not match.

Best Regards,
Chris
Re: Exception [EclipseLink-6044] Primary keys must not contain null. [message #652975 is a reply to message #652906] Mon, 07 February 2011 19:34 Go to previous message
imran raza khan is currently offline imran raza khanFriend
Messages: 18
Registered: January 2011
Junior Member
Hi Chris,

Thanks for your help, its start working now.

Regards,
imran
Previous Topic:OSGI WAB problem with persistence.xml
Next Topic:Unwanted aggregated child cascade delete
Goto Forum:
  


Current Time: Thu Dec 18 08:36:49 GMT 2014

Powered by FUDForum. Page generated in 0.02055 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software