java - Disable JPA query cache -
i have java ee program runs on wildfly 9 server. in program want record in database thousands of records in once. that's why in method use native query:
public int record(collection<myentity> entities) { /** * following query like: * insert my_table (id, date, value) values * (1, '2016-02-24', 10), * (2, '2016-02-23', 8), * ... * (10000, '2016-02-01', 6); */ stringbuilder querystring = new stringbuilder("insert my_table (id, date, value) values "); (int = 1; <= entities.size(); i++) { querystring.append("?,?,?)"); if (i < parameters.size()) { querystring.append(','); } } query query = getentitymanager().createnativequery(querystring.tostring()); int parameterposition = 0; (myentity entity : entities) { query.setparameter(++parameterposition, entity.getid()); query.setparameter(++parameterposition, entity.getdate()); query.setparameter(++parameterposition, entity.getvalue()); } return query.executeupdate(); }
my problem hibernate
keeps in cache (i don't know how many) prepared statements. example if have 1 entity in collection, query insert my_table (id, date, value) value (?,?,?)
cached, 2 entities insert my_table (id, date, value) value (?,?,?),(?,?,?)
, on. said want record thousands of records, big strings cached , after while application crash ugly java heap space
error.
so wonder if it's possible disable cache particular query ?
Comments
Post a Comment