Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-users] New QueryException in version 1.1

The error does not make any sense, as TRANSACTION_ID is the id of the
CpTransaction, not POLICY_NUMBER, the delete should only be using the
TRANSACTION_ID field.  Have you customized you delete query sql?

Please include the full exception stack trace.  Also include the finest log
for the entire transaction commit.  If it is too large, then isolate the
transaction to just deleting the one object.



khaskett wrote:
> 
> I will try to limit the parent entity to just relevant fields, as it is
> quite large -
> @Entity
> @Table(name = "CP_TRANSACTION")
> @Converter(name = "boolean", converterClass =
> com.gmrc.jpa.domain.mappings.converters.BooleanYNConverter.class)
> public class CpTransaction extends BaseDomain implements
> java.io.Serializable {
> 
>     private Set<CpMsg> cpMsgs = new HashSet<CpMsg>(0);
> ....
>     private String policyNumber;
> ....
>     private Long transactionId;
> ...
> 
> 
>     public boolean addCpMsg(final CpMsg cpMsg) {
>     	boolean retVal = false;
>         if (cpMsg != null) {
>         	if (this.cpMsgs == null) {
>                 this.cpMsgs = new HashSet<CpMsg>();
>             }
>             retVal = this.cpMsgs.add(cpMsg);
>             cpMsg.setCpTransaction(this);
>         }
>         return retVal;
>     }
> 
>     @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy
> = "cpTransaction")
>     @PrivateOwned
>     public Set<CpMsg> getCpMsgs() {
>         return this.cpMsgs;
>     }
> 
>     public void setCpMsgs(final Set<CpMsg> cpMsgs) {
>         this.cpMsgs = cpMsgs;
>     }
> 
>     @Column(name = "POLICY_NUMBER", length = 20)
>     public String getPolicyNumber() {
>         return this.policyNumber;
>     }
> 
>     public void setPolicyNumber(final String policyNumber) {
>         this.policyNumber = policyNumber;
>     }
> 
>     @Id
>     @GeneratedValue(strategy = GenerationType.IDENTITY)
>     @Column(name = "TRANSACTION_ID", unique = true, nullable = false,
> precision = 11, scale = 0)
>     public Long getTransactionId() {
>         return this.transactionId;
>     }
> 
>     public void setTransactionId(final Long transactionId) {
>         this.transactionId = transactionId;
>     }
> }
> 
> // This is the Child table
> @Entity
> @Table(name = "CP_MSG")
> public class CpMsg extends BaseDomain {
> 
>     private Long msgId;
>     private String policyNbr;
>     private Date msgTime;
>     private String msgType;
>     private String msgText;
>     private String userId;
>     private CpTransaction cpTransaction;
> 
>     @ManyToOne(fetch = FetchType.LAZY)
>     @JoinColumn(name = "POLICY_NBR", referencedColumnName =
> "POLICY_NUMBER", updatable = false, insertable = false)
>     public CpTransaction getCpTransaction() {
>         return this.cpTransaction;
>     }
> 
>     public void setCpTransaction(final CpTransaction cpTransaction) {
>         this.cpTransaction = cpTransaction;
>         
>         if (this.cpTransaction != null &&
> !this.cpTransaction.getCpMsgs().contains(this)) {
>         	this.cpTransaction.getCpMsgs().add(this);
>         	this.policyNbr = this.cpTransaction.getPolicyNumber();
>         }
>     }
> 
>     public CpMsg() {
>     }
> 
>     public CpMsg(final Long msgId, final Date msgTime, final String
> msgText) {
>         this.msgId = msgId;
>         this.msgTime = msgTime;
>         this.msgText = msgText;
>     }
> 
>     public CpMsg(final Long msgId, final String policyNbr, final String
> userId, final Date msgTime,
>             final String msgType, final String msgText) {
>         this.msgId = msgId;
>         this.policyNbr = policyNbr;
>         this.msgTime = msgTime;
>         this.msgType = msgType;
>         this.msgText = msgText;
>         this.userId = userId;
>     }
> 
>     @Id
>     @GeneratedValue(strategy = GenerationType.IDENTITY)
>     @Column(name = "MSG_ID", unique = true, nullable = false, precision =
> 11, scale = 0)
>     public Long getMsgId() {
>         return this.msgId;
>     }
> 
>     public void setMsgId(final Long msgId) {
>         this.msgId = msgId;
>     }
> 
>     @Column(name = "POLICY_NBR", length = 20)
>     public String getPolicyNbr() {
>         return this.policyNbr;
>     }
> 
>     public void setPolicyNbr(final String policyNbr) {
>         this.policyNbr = policyNbr;
>     }
> 
>     @Temporal(TemporalType.DATE)
>     @Column(name = "MSG_TIME", nullable = false, length = 26)
>     public Date getMsgTime() {
>         return this.msgTime;
>     }
> 
>     public void setMsgTime(final Date msgTime) {
>         this.msgTime = msgTime;
>     }
> 
>     @Column(name = "MSG_TYPE", length = 5)
>     public String getMsgType() {
>         return this.msgType;
>     }
> 
>     public void setMsgType(final String msgType) {
>         this.msgType = msgType;
>     }
> 
>     @Column(name = "MSG_TEXT", nullable = false)
>     public String getMsgText() {
>         return this.msgText;
>     }
> 
>     public void setMsgText(final String msgText) {
>         this.msgText = msgText;
>     }
> 
>     public void setUserId(final String userId) {
>         this.userId = userId;
>     }
> 
>     @Column(name = "USER_ID", nullable = false)
>     public String getUserId() {
>         return this.userId;
>     }
> 
>     @Override
>     public BaseDomain getParentDomain() {
>         // ParentDomain context not supported
>         return null;
>     }
> 
>     @Override
>     public CpActionCode getCpActionCode() {
>         // there is not associated action code
>         return null;
>     }
> 
>     @Override
>     @Transient
>     public long getId() {
>         return this.getMsgId();
>     }
> 
>     @Override
>     public void setId(long id) {
>         this.setMsgId(id);
>     }
> }
> 
> The full stack trace is pretty much as listed earlier. I will add the
> couple of statements before and after this error. I have logging set to
> FINEST right now.
> 
> [3/31/09 21:04:41:609 CDT] 0000003c SystemOut     O [EL Finest]:
> 2009-03-31
> 21:04:41.609--ClientSession(1163543898)--Connection(409213028)--Thread(Thread[WebContainer
> : 0,5,main])--[SQL0100] Row not found for DELETE.:02000 - null
> [3/31/09 21:04:41:640 CDT] 0000003c SystemOut     O [EL Fine]: 2009-03-31
> 21:04:41.64--ClientSession(1163543898)--Connection(409213028)--Thread(Thread[WebContainer
> : 0,5,main])--DELETE FROM CP_LOB WHERE (LOB_ID = ?)
> 	bind => [26589]
> [3/31/09 21:04:41:796 CDT] 0000003c SystemOut     O [EL Warning]:
> 2009-03-31 21:04:41.781--UnitOfWork(494673276)--Thread(Thread[WebContainer
> : 0,5,main])--Exception [EclipseLink-6094] (Eclipse Persistence Services -
> 1.1.0.r3634): org.eclipse.persistence.exceptions.QueryException
> Exception Description: The parameter name [POLICY_NUMBER] in the query's
> selection criteria does not match any parameter name defined in the query.
> Query: DeleteObjectQuery(com.gmrc.jpa.domain.CpTransaction@de21fdeb)
> [3/31/09 21:04:41:796 CDT] 0000003c SystemOut     O [EL Finer]: 2009-03-31
> 21:04:41.796--ClientSession(1163543898)--Connection(409213028)--Thread(Thread[WebContainer
> : 0,5,main])--rollback transaction
> [3/31/09 21:04:41:859 CDT] 0000003c SystemOut     O [EL Finer]: 2009-03-31
> 21:04:41.859--UnitOfWork(494673276)--Thread(Thread[WebContainer :
> 0,5,main])--release unit of work
> [3/31/09 21:04:41:859 CDT] 0000003c SystemOut     O [EL Finer]: 2009-03-31
> 21:04:41.859--ClientSession(1163543898)--Thread(Thread[WebContainer :
> 0,5,main])--client released
> 
> The id of the CpTransaction object is not null, it is 31840.
> As there are multiple child tables to CpTransaction the full stack is
> quite large also.. but here is a snippet where it first does a read on
> CpMsg
> [3/31/09 21:04:40:250 CDT] 0000003c SystemOut     O [EL Finest]:
> 2009-03-31
> 21:04:40.25--ServerSession(1388466882)--Thread(Thread[WebContainer :
> 0,5,main])--Execute query ReadAllQuery(name="cpMsgs" referenceClass=CpMsg
> sql="SELECT MSG_ID, MSG_TEXT, MSG_TYPE, MSG_TIME, USER_ID, POLICY_NBR FROM
> CP_MSG WHERE (POLICY_NBR = ?)")
> [3/31/09 21:04:40:250 CDT] 0000003c SystemOut     O [EL Finest]:
> 2009-03-31
> 21:04:40.25--ServerSession(1388466882)--Thread(Thread[WebContainer :
> 0,5,main])--reconnecting to external connection pool
> [3/31/09 21:04:40:250 CDT] 0000003c SystemOut     O [EL Fine]: 2009-03-31
> 21:04:40.25--ServerSession(1388466882)--Connection(307630678)--Thread(Thread[WebContainer
> : 0,5,main])--SELECT MSG_ID, MSG_TEXT, MSG_TYPE, MSG_TIME, USER_ID,
> POLICY_NBR FROM CP_MSG WHERE (POLICY_NBR = ?)
> 	bind => [0000431908]
> 
> And the POLICY_NBR is correct.
> 
> Let me know if there is anything else 
> 
> 
> James Sutherland wrote:
>> 
>> That is odd, in the CpTransaction object that you are deleting, what is
>> the value of its id, is it null?  What is its Id, policyNumber is not
>> marked as the id?  Please include the  complete mappings for this class
>> and the full exception stack trace.
>> 
>> 
>> 
>> khaskett wrote:
>>> 
>>> I removed the @JoinColumn as suggested but I still get the same error -
>>> [3/31/09 20:28:00:437 CDT] 00000035 SystemOut     O [EL Warning]:
>>> 2009-03-31
>>> 20:28:00.421--UnitOfWork(2109111734)--Thread(Thread[WebContainer :
>>> 0,5,main])--Exception [EclipseLink-6094] (Eclipse Persistence Services -
>>> 1.1.0.r3634): org.eclipse.persistence.exceptions.QueryException
>>> Exception Description: The parameter name [POLICY_NUMBER] in the query's
>>> selection criteria does not match any parameter name defined in the
>>> query.
>>> Query: DeleteObjectQuery(com.gmrc.jpa.domain.CpTransaction@de21fdeb)
>>> 
>>> Anything else I might try?
>>> Thanks
>>> 
>>> 
>>> James Sutherland wrote:
>>>> 
>>>> I'm not exactly sure, but my guess is it has something to do with the,
>>>> 
>>>> @JoinColumn(name = "POLICY_NUMBER", referencedColumnName =
>>>> "POLICY_NBR") 
>>>> 
>>>> Annotation in your @OneToMany mapping.  In JPA 1.0 using a @JoinColumn
>>>> in a @OneToMany was not supported.  However in JPA 2.0 it will be, and
>>>> is in EclipseLink 1.1.  Because you are using a mappedBy in your
>>>> mapping though, you should not have the @JoinColumn, so you should
>>>> remove it.
>>>> 
>>>> 
>>>> khaskett wrote:
>>>>> 
>>>>> Is there a way to figure out why I am getting a QueryException in a
>>>>> delete request?
>>>>> [3/30/09 14:47:35:328 CDT] 0000003f SystemOut     O [EL Warning]:
>>>>> 2009-03-30
>>>>> 14:47:35.328--UnitOfWork(2104393070)--Thread(Thread[WebContainer :
>>>>> 5,5,main])--Exception [EclipseLink-6094] (Eclipse Persistence Services
>>>>> - 1.1.0.r3634): org.eclipse.persistence.exceptions.QueryException
>>>>> Exception Description: The parameter name [POLICY_NUMBER] in the
>>>>> query's selection criteria does not match any parameter name defined
>>>>> in the query.
>>>>> Query: DeleteObjectQuery(com.gmrc.jpa.domain.CpTransaction@de21fdeb)
>>>>> 
>>>>> I was not seeing this in the 1.0.2 version.
>>>>> 
>>>>> I have narrowed it down to the relationship between these two
>>>>> entities.
>>>>> 
>>>>> @Entity
>>>>> @Table(name = "CP_TRANSACTION")
>>>>> public class CpTransaction extends BaseDomain implements
>>>>> java.io.Serializable {
>>>>> ....
>>>>>     private Set<CpMsg> cpMsgs = new HashSet<CpMsg>(0);
>>>>> ....
>>>>>     @OneToMany(fetch = FetchType.LAZY, mappedBy = "cpTransaction")
>>>>>     @JoinColumn(name = "POLICY_NUMBER", referencedColumnName =
>>>>> "POLICY_NBR")
>>>>>     @PrivateOwned
>>>>>     public Set<CpMsg> getCpMsgs() {
>>>>>         return this.cpMsgs;
>>>>>     }
>>>>> 
>>>>>     @Column(name = "POLICY_NUMBER", length = 20)
>>>>>     public String getPolicyNumber() {
>>>>>         return this.policyNumber;
>>>>>     }
>>>>> }
>>>>> 
>>>>> @Entity
>>>>> @Table(name = "CP_MSG")
>>>>> public class CpMsg extends BaseDomain {
>>>>>     private Long msgId;
>>>>> .....
>>>>>     private String policyNbr;
>>>>>     private CpTransaction cpTransaction;
>>>>> 
>>>>>     @ManyToOne(fetch = FetchType.LAZY)
>>>>>     @JoinColumn(name = "POLICY_NBR", referencedColumnName =
>>>>> "POLICY_NUMBER", updatable = false, insertable = false)
>>>>>     public CpTransaction getCpTransaction() {
>>>>>         return this.cpTransaction;
>>>>>     }
>>>>> 
>>>>>     @Id
>>>>>     @GeneratedValue(strategy = GenerationType.IDENTITY)
>>>>>     @Column(name = "MSG_ID", unique = true, nullable = false,
>>>>> precision = 11, scale = 0)
>>>>>     public Long getMsgId() {
>>>>>         return this.msgId;
>>>>>     }
>>>>>     
>>>>>     @Column(name = "POLICY_NBR", length = 20)
>>>>>     public String getPolicyNbr() {
>>>>>         return this.policyNbr;
>>>>>     }
>>>>> }
>>>>> 
>>>>> The SQL relationship is CP_TRANSACTION.POLICY_NUMBER =
>>>>> CP_MSG.POLICY_NBR.
>>>>> 
>>>>> If I do a getCpMsgs() it seems to find them correctly.
>>>>> 
>>>>> Thanks
>>>>> Kevin
>>>>> 
>>>> 
>>>> 
>>> 
>>> 
>> 
>> 
> 
> 


-----
---
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/New-QueryException-in-version-1.1-tp22792539p22848191.html
Sent from the EclipseLink - Users mailing list archive at Nabble.com.



Back to the top