« Return to Thread: creating custom query with properties

RE: creating custom query with properties

by michael-487 :: Rate this Message:

Reply to Author | View in Thread

Hello,

Seems like you're doing a JPQL query rather than SQL - is this what you try to do?

Anyway, for SQL look in the PreparedStatement class:
   PreparedStatement pstmt = con.prepareStatement("UPDATE EMPLOYEES
                                     SET SALARY = ? WHERE ID = ?");
   pstmt.setBigDecimal(1, 153833.00)
   pstmt.setInt(2, 110592)

In JPA, you can habe named paramenters:
  Query q = em.createQuery( "SELECT s FROM Sample s WHERE s.something=:value" );
  q.setParameter( "value", valueObj )
  ...


HTH
Michael

-----Original Message-----
From: mrserii [mailto:mrserii@...]
Sent: Tuesday, July 07, 2009 11:31 PM
To: nbj2ee@...
Subject: [nbj2ee] creating custom query with properties


hellow everybody  [Exclamation]  [Exclamation]  [Exclamation]



i start to work with nb few days ago and there is something i cant do:



in SWING app i have query "select s from shipping s"



i want to add binded property from text field named "weight" (something like "select * from shipping where weight = $weight" in PHP...).



after all i want bing single result to text field.





tnx!




 « Return to Thread: creating custom query with properties