java - How to dynamically delete the rows of a table, or delete a table, with Hibernate? -
i have table in oracle database.
i want know how delete rows, or how delete purely table using hibernate, but not changing corresponding mapped class. mean, want ouside mapped class, in main java method example.
to read data, use native sql queries hibernate.
to write data, use session.save
but how do delete data table, or delete table ?
i looked @ hibernate documentation, solution involves changing mapped class code adding annotations...
i want solution 1 use read , write data :
session.createsqlquery("...");
or
session.save(...);
is there solution ?
i found answer in stackoverflow question :
query delete rows in table hibernate
if table want delete rows named mytable then, answer :
in hql :
session.createquery("delete mytable").executeupdate();
in native sql :
session.createsqlquery("delete mytable").executeupdate();
i should have looked longer in stackoverflow before posting question, sorry that.
Comments
Post a Comment