ztx1491 / hibernate-generic-dao

Automatically exported from code.google.com/p/hibernate-generic-dao
1 stars 0 forks source link

Adding a new feature : multiple choice field : #84

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Dear,

I have the following problem :
I need to execute this request : 

select count(distinct wB.name) from WELL_BORE WB 
left outer join WELL_LOG WL on WB.id=WL.WELL_BORE_ID 
left outer join WELL_LOG WL2 on WB.id=WL2.WELL_BORE_ID 
where 
WL.kind ='GR'
AND
WL2.kind ='RHOB';

I want to get bores that have log with kind 'gr' and log with kind 'rhob'.

How to execute this kind of request with Search API ?

Regards.

Original issue reported on code.google.com by jmarc.mo...@gmail.com on 24 Jan 2011 at 5:27

GoogleCodeExporter commented 8 years ago
This request can be write in this manner :

select  count( w.name) from WELL W 
where 
W.id in (
select WB.WELL_ID from WELL_BORE WB, WELL_LOG WL,  WELL_LOG WL2 where 
WL.WELL_BORE_ID = wb.id and
WL.WELL_BORE_ID = WL2.WELL_BORE_ID 
AND 
WL.kind ='GR'
AND
WL2.kind ='RHOB');

Any way to make it with hibernate-generic-dao ?

Original comment by jmarc.mo...@gmail.com on 25 Jan 2011 at 10:49

GoogleCodeExporter commented 8 years ago
This might work...

new Search(WellBore.class)
.addField("name", OP_COUNT_DISTINCT)
.addFilterSome("wellLog, Filter.equal("kind", "GR"))
.addFilterSome("wellLog, Filter.equal("kind", "RHOB"))

If not, you're going to have to go with raw hibernate query, but there's 
nothing wrong with that for these sorts of tricky queries.

Original comment by dwolvert on 29 Jan 2011 at 8:12

GoogleCodeExporter commented 8 years ago
Closing this out. It's more of a question than an issue.

Original comment by dwolvert on 25 Feb 2011 at 1:44