-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: positional param problem
PostPosted: Mon Feb 04, 2013 6:52 pm 
Newbie

Joined: Mon Feb 04, 2013 5:10 pm
Posts: 2
String cstr =
"SELECT distinct c.claim_index, p.treasury_payment_date, p.paid_amount, l.check_number " +
" FROM " +
"fpps_owner.claims c, fpps_owner.claim_payment p, fpps_owner.fee_claim_payments f, fpps_owner.fee_claim_payment_lines l " +
"WHERE " +
"c.claim_index = p.claim_index and c.claim_index = f.claim_index " +
"f.fee_claim_payment_id = l.fee_claim_payment_id " +
"and c.claim_status_cd = 'COMPLETE' " +
"and c.claim_index=?"
"and p.treasury_payment_date is not null ";


// "and not exists (select 1 from stg_277 s where c.claim_index = s.claim_index and s.claim_status_cd = 'NEW') and rownum < 100; "
Query paymentData = em.createNativeQuery(cstr);
paymentData.setParameter(1, this.sClaimKey); // fail with long key value
paymentList = em.createNativeQuery(cstr).getResultList();
System.out.println("size of list is: " + paymentList.size());

Error message is: Expected positional parameter count: 1, actual parameters: [] [SELECT distinct c.claim_index, p.treasury_payment_date, p.paid_amount, l.check_number FROM fpps_owner.claims c, fpps_owner.claim_payment p, fpps_owner.fee_claim_payments f, fpps_owner.fee_claim_payment_lines l WHERE c.claim_index = p.claim_index and c.claim_index = f.claim_index f.fee_claim_payment_id = l.fee_claim_payment_id and c.claim_status_cd = 'COMPLETE' and c.claim_index = ?] “

Can someone tell me what I've done wrong here? I've tried named params (= :claimKey) , different datatypes for args etc. Excuse me if it's obvious but I'm new to Hibernate!

Thanks for any help.


Top
 Profile  
 
 Post subject: Re: positional param problem
PostPosted: Tue Feb 05, 2013 3:22 am 
Expert
Expert

Joined: Tue Jun 16, 2009 3:36 am
Posts: 990
Well, only if you use the JPA-Query-Api the first parameter must have index = 1.
You are using the Hibernate-Query-Api where the first parameter must have index = 0.


Code:
paymentData.setParameter(0, this.sClaimKey);


Top
 Profile  
 
 Post subject: Re: positional param problem
PostPosted: Tue Feb 05, 2013 10:43 am 
Newbie

Joined: Mon Feb 04, 2013 5:10 pm
Posts: 2
Thanks! Will give it a try.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.