(However the entity should be a managed one. Otherwise it throws an exception saying that you are trying to remove a detached object.)
You can use an EJBQL query to delete a record from database directly. In this case no managed entity is required. Following is an example query, which deletes one record from "Client" table.
It deletes the client whose clientId is 10.
DELETE FROM Client client where client.clientId = 10
Now I am going to use SEAM managed EntityManager to create a Query object as below and execute the query by calling it's "executeUpdate()" method.
Injecting EntityManager.
@In
EntityManager entityManager
EntityManager entityManager
Creating and executing query
Query q = entityManager.createQuery("DELETE FROM Client client where client.clientId = 10");
q.executeUpdate();//delete row
q.executeUpdate();//delete row
Great Article
ReplyDeleteJava EE online training | Java Training in Chennai
I appreciate that you produced this wonderful article to help us get more knowledge about this topic. I know, it is not an easy task to write such a big article in one day, I've tried that and I've failed. But, here you are, trying the big task and finishing it off and getting good comments and ratings. That is one hell of a job done!
ReplyDeleteData Science Training in Indira nagar
Data Science Training in btm layout
Data Science Training in Kalyan nagar
Data Science training in Indira nagar
Data science training in bangalore
Hi great readding your post
ReplyDeleteGood content. You write beautiful things.
ReplyDeletevbet
mrbahis
mrbahis
taksi
hacklink
sportsbet
korsan taksi
sportsbet
hacklink
Success Write content success. Thanks.
ReplyDeletebetturkey
canlı slot siteleri
kralbet
betpark
betmatik
deneme bonusu
canlı poker siteleri
kocaeli
ReplyDeletekonya
kuşadası
kütahya
malatya
TWEW