Project

General

Profile

« Previous | Next » 

Revision 52c34f45

Added by Andreas Müller almost 8 years ago

Remove bidirectionality for supplemental data #5743

View differences:

cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/persistence/dao/hibernate/common/IdentifiableDaoBase.java
192 192
    @Override
193 193
    public int countSources(T identifiableEntity) {
194 194
        checkNotInPriorView("IdentifiableDaoBase.countSources(T identifiableEntity)");
195
        Query query = getSession().createQuery("select count(source) from OriginalSourceBase source where source.sourcedObj = :identifiableEntity");
196
        query.setParameter("identifiableEntity",identifiableEntity);
195
        Query query = getSession().createQuery("SELECT COUNT(source) FROM "+identifiableEntity.getClass().getName() + " ie JOIN ie.sources source WHERE ie = :identifiableEntity");
196
        query.setParameter("identifiableEntity", identifiableEntity);
197 197
        return ((Long)query.uniqueResult()).intValue();
198 198
    }
199 199

  
......
220 220
    @Override
221 221
    public List<IdentifiableSource> getSources(T identifiableEntity, Integer pageSize, Integer pageNumber, List<String> propertyPaths) {
222 222
        checkNotInPriorView("IdentifiableDaoBase.getSources(T identifiableEntity, Integer pageSize, Integer pageNumber)");
223
        Query query = getSession().createQuery("select source from OriginalSourceBase source where source.sourcedObj.id = :id and source.sourcedObj.class = :class");
223
        Query query = getSession().createQuery("SELECT source FROM "+ identifiableEntity.getClass().getName()+ " ie JOIN ie.sources source WHERE ie.id = :id");
224 224
        query.setParameter("id",identifiableEntity.getId());
225
        query.setParameter("class",identifiableEntity.getClass().getName());
226 225
        setPagingParameter(query, pageSize, pageNumber);
226
        @SuppressWarnings("unchecked")
227 227
        List<IdentifiableSource> results = query.list();
228 228
        defaultBeanInitializer.initializeAll(results, propertyPaths);
229 229
        return results;

Also available in: Unified diff