user3454863
user3454863

Reputation: 161

How to run the update query in JPA

I am playframework application developer. I am using createNativeQuery method in jpa to extracting values from tables through select query. I need to use update query. What i have to do and what will be the return type of that method. Please anyone help me. Thanks in advance.. if i use like this it showing error..

Query query=JPA.em().createNativeQuery("update truck set flag='YES' where shipment_upc=:EAN_code"); query.setParameter("EAN_code", EAN_code); System.out.println(query.getSingleResult());

Upvotes: 0

Views: 5271

Answers (1)

pL4Gu33
pL4Gu33

Reputation: 2085

Use createNativeQuery with your update- query and you will get back a Query- Object.

On it use executeUpdate and you get back the number of updated datas.

Upvotes: 2

Related Questions