creating custom query with properties

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

creating custom query with properties

by mrserii :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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!





RE: creating custom query with properties

by michael-487 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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!





creating custom query with properties

by mrserii :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

can someone link me open source project that using database ? (nb project)



 :P  :P  :P





Re: creating custom query with properties

by Melongo Annabel :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Some parts of this message have been removed. Learn more about Nabble's security policy.


From: mrserii <mrserii@...>
To: nbj2ee@...
Sent: Wednesday, July 8, 2009 3:56:58 PM
Subject: [nbj2ee] creating custom query with properties

can someone link me open source project that using database ? (nb project)



:P  :P  :P