Revision 2d09ccf7
Added by Andreas Müller over 4 years ago
cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/persistence/dao/hibernate/reference/OriginalSourceDaoImpl.java | ||
---|---|---|
23 | 23 |
import org.springframework.stereotype.Repository; |
24 | 24 |
|
25 | 25 |
import eu.etaxonomy.cdm.common.CdmUtils; |
26 |
import eu.etaxonomy.cdm.model.common.IdentifiableEntity; |
|
27 | 26 |
import eu.etaxonomy.cdm.model.reference.ISourceable; |
28 | 27 |
import eu.etaxonomy.cdm.model.reference.OriginalSourceBase; |
29 | 28 |
import eu.etaxonomy.cdm.persistence.dao.hibernate.common.CdmEntityDaoBase; |
... | ... | |
71 | 70 |
} |
72 | 71 |
|
73 | 72 |
@Override |
74 |
public List<IdentifiableEntity> findOriginalSourceByIdInSource(Class clazz, String idInSource, String idNamespace) {
|
|
73 |
public <S extends ISourceable> List<S> findOriginalSourceByIdInSource(Class<S> clazz, String idInSource, String idNamespace) {
|
|
75 | 74 |
Session session = getSession(); |
76 | 75 |
Query q = session.createQuery( |
77 |
"Select c from " + clazz.getSimpleName() + " as c " +
|
|
78 |
"inner join c.sources as source " +
|
|
79 |
"where source.idInSource = :idInSource " +
|
|
76 |
"SELECT c FROM " + clazz.getSimpleName() + " as c " +
|
|
77 |
" INNER JOIN c.sources as source " +
|
|
78 |
"WHERE source.idInSource = :idInSource " +
|
|
80 | 79 |
" AND source.idNamespace = :idNamespace" |
81 | 80 |
); |
82 | 81 |
q.setString("idInSource", idInSource); |
83 | 82 |
q.setString("idNamespace", idNamespace); |
84 | 83 |
//TODO integrate reference in where |
85 |
List<IdentifiableEntity> results = q.list(); |
|
84 |
@SuppressWarnings("unchecked") |
|
85 |
List<S> results = q.list(); |
|
86 | 86 |
|
87 | 87 |
return results; |
88 | 88 |
} |
Also available in: Unified diff
add more specific return type to CommonService.getSourcedObjectByIdInSource