Today's project logic needs to pass the number of groups past. Then a generic method is invoked. But the parameter of this method is object. If you change the parameter type, the other module calls this method and there is a problem.
The final solution is to add a judgment to the DAO layer
This is the DAO layer code
Public List Findbyproperty (String PropertyName, Object value) {
List list = new ArrayList ();
String querystring = "from Userinfo as model where model." + propertyname + =? ORDER by Model.userinfoid DESC ";
try {
//// judge if string array type
if (value instanceof string[]) {
///If True to strong to string array
string [] Arr = (string[]) value;
for (int i = 0; i < arr.length i++) {
this.gethibernatetemplate (). Find (QueryString, value);
List.add (This.gethibernatetemplate (). Find (QueryString, arr[i));
}
else{
list = This.gethibernatetemplate (). Find (QueryString, value);
}
catch (RuntimeException re) {
Log.error ("Find by property name failed", re);
throw re;
}
return list;
}
In addition to instanceof to judge can also use the Istarray method
if (Value.getclass (). IsArray ()) {
//If it is an array then action
}
Online search looked down they all suggested using the IsArray method to say that the first one could be an anomaly.