Issue #1869 Fix unique checking for things without dataURI and with subtables.

Former-commit-id: cdf8e7daaa [formerly 3b6156843e] [formerly 7be9ad1f8b [formerly 3f600c5e7b0fb53aff7c8c594e5ca58c4f8250ef]]
Former-commit-id: 7be9ad1f8b
Former-commit-id: 2a8a87e564
This commit is contained in:
Ben Steffensmeier 2013-05-24 16:39:35 -05:00
parent e976a4c94e
commit c71afc4198

View file

@ -38,6 +38,7 @@ import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import org.apache.commons.beanutils.PropertyUtils;
import org.hibernate.Criteria;
import org.hibernate.QueryException;
import org.hibernate.Session;
@ -372,10 +373,21 @@ public abstract class PluginDao extends CoreDao {
for (Entry<String, Object> uriEntry : DataURIUtil.createDataURIMap(pdo)
.entrySet()) {
String key = uriEntry.getKey();
Object value = uriEntry.getValue();
if (key.equals("pluginName")) {
;// this is not in the db, only used internally.
} else if (value == null) {
continue;
}
Object value = uriEntry.getValue();
int dotIndex = key.indexOf(".");
if (dotIndex > 0) {
key = key.substring(0, dotIndex);
try {
value = PropertyUtils.getProperty(pdo, key);
} catch (Exception e) {
throw new PluginException(e);
}
}
if (value == null) {
criteria.add(Restrictions.isNull(key));
} else {
criteria.add(Restrictions.eq(key, value));