DAO: Rewrite change for method findByIdIncludingRemoved(ID id)

Also change the sibling method findById(final ID id)
This commit is contained in:
Marc-Aurèle Brothier 2016-05-09 11:39:04 +02:00
parent 696440a675
commit 39aa0e4f35
1 changed files with 17 additions and 5 deletions

View File

@ -942,12 +942,18 @@ public abstract class GenericDaoBase<T, ID extends Serializable> extends Compone
@DB()
@SuppressWarnings("unchecked")
public T findById(final ID id) {
T result = null;
if (_cache != null) {
final Element element = _cache.get(id);
return element == null ? lockRow(id, null) : (T)element.getObjectValue();
if (element == null) {
result = lockRow(id, null);
} else {
result = (T)element.getObjectValue();
}
} else {
return lockRow(id, null);
result = lockRow(id, null);
}
return result;
}
@Override
@ -968,13 +974,19 @@ public abstract class GenericDaoBase<T, ID extends Serializable> extends Compone
@Override
@DB()
public T findByIdIncludingRemoved(ID id) {
public T findByIdIncludingRemoved(final ID id) {
T result = null;
if (_cache != null) {
final Element element = _cache.get(id);
return element == null ? findById(id, true, null) : (T)element.getObjectValue();
if (element == null) {
result = findById(id, true, null);
} else {
result = (T)element.getObjectValue();
}
} else {
return findById(id, true, null);
result = findById(id, true, null);
}
return result;
}
@Override