hibernate优化

yun-zuoyi
alwaysfrin 5 years ago
parent 3fe76d1713
commit 14660641ba

@ -20,6 +20,23 @@ import java.util.Map;
public interface BaseRepository <T, ID extends Serializable> extends JpaRepository<T, ID> {
/**
* service
*/
void clearSession();
/**
*
* @param t
*/
void detachObject(T t);
/**
*
* @param list
*/
void detachList(List<T> list);
/**
* <br/>
* idlong0
* uuid

@ -48,6 +48,24 @@ public class BaseRepositoryImpl<T, ID extends Serializable> extends SimpleJpaRep
this.snowflakeIdMaker = snowflakeIdMaker;
}
public void clearSession(){
entityManager.clear();
}
public void detachObject(T t){
entityManager.detach(t);
}
//集合设置为游离态
public void detachList(List<T> list){
if(list != null){
for(T t : list) {
//设置对象为游离态
entityManager.detach(t);
}
}
}
private void setParameter(Query query, String[] propName, Object[] propValue) {
String name = null;
Object value = null;

Loading…
Cancel
Save