Hello
I have 2 tables documents and document_sections
in documents I have relation ManyToOne to document_sections
I have entities for these tables
I need criteria that will work like next SQL
Code:
SELECT t1.*
FROM documents AS t1
LEFT JOIN document_sections AS t2
WHERE t1.fileName = some_vaslue AND
t2.applicationSection = some_vaslue1
So I want to use both tables in where clause but have only documents in result
I've tried different things to do and below I put one variant
Code:
DetachedCriteria dc = DetachedCriteria.forClass(Document.class);
if(StringUtils.isNotBlank(searchDocumentName)){
dc.add(Restrictions.like("fileName", searchDocumentName));
}
if(selectedApplicationSection != null){
dc.createAlias("documentSection", "ds", JoinType.INNER_JOIN,
Restrictions.eq("ds.applicationSection", selectedApplicationSection));
when I try to get result list - I get List<Object[]> instead List<Documents>
and this array of objects contains both Entities: DocumentSection and Document
so result like was exacuted next query:
Code:
SELECT t1.*, t2.*
FROM documents AS t1
LEFT JOIN document_sections AS t2
WHERE t1.fileName = some_vaslue AND
t2.applicationSection = some_vaslue1
Can somebody help me?