|
|
@ -65,12 +65,12 @@ public class BaseRepositoryImpl<T, ID extends Serializable> extends SimpleJpaRep
|
|
|
|
if (((value instanceof Object[])) || ((value instanceof Collection))) {
|
|
|
|
if (((value instanceof Object[])) || ((value instanceof Collection))) {
|
|
|
|
Object[] arraySerializable = (Object[]) value;
|
|
|
|
Object[] arraySerializable = (Object[]) value;
|
|
|
|
if ((arraySerializable != null) && (arraySerializable.length > 0)) {
|
|
|
|
if ((arraySerializable != null) && (arraySerializable.length > 0)) {
|
|
|
|
sb.append(" and o." + name + " in (:" + name.replace(".", "") + ")");
|
|
|
|
sb.append(" and model." + name + " in (:" + name.replace(".", "") + ")");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else if (value == null) {
|
|
|
|
} else if (value == null) {
|
|
|
|
sb.append(" and o." + name + " is null ");
|
|
|
|
sb.append(" and model." + name + " is null ");
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
sb.append(" and o." + name + "=:" + name.replace(".", ""));
|
|
|
|
sb.append(" and model." + name + "=:" + name.replace(".", ""));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -132,7 +132,7 @@ public class BaseRepositoryImpl<T, ID extends Serializable> extends SimpleJpaRep
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void deleteByProperties(String[] propName, Object[] propValue) {
|
|
|
|
public void deleteByProperties(String[] propName, Object[] propValue) {
|
|
|
|
if ((propName != null) && (propName.length > 0) && (propValue != null) && (propValue.length > 0) && (propValue.length == propName.length)) {
|
|
|
|
if ((propName != null) && (propName.length > 0) && (propValue != null) && (propValue.length > 0) && (propValue.length == propName.length)) {
|
|
|
|
StringBuffer sb = new StringBuffer("delete from " + persistentClass.getName() + " o where 1=1 ");
|
|
|
|
StringBuffer sb = new StringBuffer("delete from " + persistentClass.getName() + " model where 1=1 ");
|
|
|
|
appendQL(sb,propName,propValue);
|
|
|
|
appendQL(sb,propName,propValue);
|
|
|
|
Query query = entityManager.createQuery(sb.toString());
|
|
|
|
Query query = entityManager.createQuery(sb.toString());
|
|
|
|
setParameter(query,propName,propValue);
|
|
|
|
setParameter(query,propName,propValue);
|
|
|
@ -146,7 +146,7 @@ public class BaseRepositoryImpl<T, ID extends Serializable> extends SimpleJpaRep
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void deleteByIdIn(long[] ids) {
|
|
|
|
public void deleteByIdIn(long[] ids) {
|
|
|
|
if(ids != null && ids.length > 0){
|
|
|
|
if(ids != null && ids.length > 0){
|
|
|
|
String hql = "delete from " + persistentClass.getName() + " o where o.id in(:ids) ";
|
|
|
|
String hql = "delete from " + persistentClass.getName() + " model where model.id in(:ids) ";
|
|
|
|
Query query = entityManager.createQuery(hql);
|
|
|
|
Query query = entityManager.createQuery(hql);
|
|
|
|
query.setParameter("ids", Arrays.asList(ids));
|
|
|
|
query.setParameter("ids", Arrays.asList(ids));
|
|
|
|
|
|
|
|
|
|
|
@ -178,7 +178,7 @@ public class BaseRepositoryImpl<T, ID extends Serializable> extends SimpleJpaRep
|
|
|
|
&& (conditionValue != null) && (conditionValue.length > 0)) {
|
|
|
|
&& (conditionValue != null) && (conditionValue.length > 0)) {
|
|
|
|
StringBuffer sb = new StringBuffer();
|
|
|
|
StringBuffer sb = new StringBuffer();
|
|
|
|
|
|
|
|
|
|
|
|
sb.append("update " + persistentClass.getName() + " o set ");
|
|
|
|
sb.append("update " + persistentClass.getName() + " model set ");
|
|
|
|
for (int i = 0; i < propertyName.length; i++) {
|
|
|
|
for (int i = 0; i < propertyName.length; i++) {
|
|
|
|
sb.append(propertyName[i] + " = :p_" + propertyName[i] + ",");
|
|
|
|
sb.append(propertyName[i] + " = :p_" + propertyName[i] + ",");
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -210,7 +210,7 @@ public class BaseRepositoryImpl<T, ID extends Serializable> extends SimpleJpaRep
|
|
|
|
&& (propertyValue.length > 0) && (propertyName.length == propertyValue.length)) {
|
|
|
|
&& (propertyValue.length > 0) && (propertyName.length == propertyValue.length)) {
|
|
|
|
StringBuffer sb = new StringBuffer();
|
|
|
|
StringBuffer sb = new StringBuffer();
|
|
|
|
|
|
|
|
|
|
|
|
sb.append("update " + persistentClass.getName() + " o set ");
|
|
|
|
sb.append("update " + persistentClass.getName() + " model set ");
|
|
|
|
for (int i = 0; i < propertyName.length; i++) {
|
|
|
|
for (int i = 0; i < propertyName.length; i++) {
|
|
|
|
sb.append(propertyName[i] + " = :p_" + propertyName[i] + ",");
|
|
|
|
sb.append(propertyName[i] + " = :p_" + propertyName[i] + ",");
|
|
|
|
}
|
|
|
|
}
|
|
|
|