PL-7970 Dynamic attributes aren't fetched if view was not set to the LoadContext

This commit is contained in:
Andrey Subbotin 2016-10-12 10:08:37 +04:00
parent 75ec0b7bfe
commit 3ae2901a32
2 changed files with 8 additions and 3 deletions

View File

@ -190,9 +190,7 @@ public class RdbmsStore implements DataStore {
resultList = getResultList(context, query, ensureDistinct); resultList = getResultList(context, query, ensureDistinct);
// Fetch dynamic attributes // Fetch dynamic attributes
if (context.getView() != null if (!resultList.isEmpty() && resultList.get(0) instanceof BaseGenericIdEntity && context.isLoadDynamicAttributes()) {
&& BaseGenericIdEntity.class.isAssignableFrom(context.getView().getEntityClass())
&& context.isLoadDynamicAttributes()) {
dynamicAttributesManagerAPI.fetchDynamicAttributes((List<BaseGenericIdEntity>) resultList); dynamicAttributesManagerAPI.fetchDynamicAttributes((List<BaseGenericIdEntity>) resultList);
} }

View File

@ -220,12 +220,19 @@ public class DataManagerTest {
LoadContext<Server> loadContext = LoadContext.create(Server.class).setId(id).setLoadDynamicAttributes(true); LoadContext<Server> loadContext = LoadContext.create(Server.class).setId(id).setLoadDynamicAttributes(true);
server = dataManager.load(loadContext); server = dataManager.load(loadContext);
assertNotNull(server.getDynamicAttributes());
server = dataManager.reload(server, View.LOCAL); server = dataManager.reload(server, View.LOCAL);
assertNotNull(server.getDynamicAttributes()); assertNotNull(server.getDynamicAttributes());
loadContext = LoadContext.create(Server.class).setId(id).setLoadDynamicAttributes(false); loadContext = LoadContext.create(Server.class).setId(id).setLoadDynamicAttributes(false);
server = dataManager.load(loadContext); server = dataManager.load(loadContext);
assertNull(server.getDynamicAttributes()); assertNull(server.getDynamicAttributes());
loadContext = LoadContext.create(Server.class).setLoadDynamicAttributes(true);
loadContext.setQueryString("select s from sys$Server s where s.id = :id")
.setParameter("id", id);
List<Server> resultList = dataManager.loadList(loadContext);
assertNotNull(resultList.get(0).getDynamicAttributes());
} }
@Test @Test