You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@openjpa.apache.org by mvas <va...@yahoo.com> on 2010/08/25 22:37:42 UTC

quick question regarding joining tables

Hi,

I have the follwing problem and I was wondering if anyone know the answer or
can provide me with a tutorial link or any other helpful information....

I have the code below, the tables are standalone (don't ask me why... even
they don't know....) and I have to quesry them basen on the attribues in the
code (where start/end day is always the current) and display a list based on
the search criteria.....
My problem is that if for example I have two entries in the
"BrandOrderOffer" with the "OrderOffer" ordOffrN. 
(eg. {brand/ordOffrN} {1, 10} and {2,10} where the common ordOffrN=10) then
I'm getting back two full instances of the result.
I need to join the tables but I'm not sure on how to do it in openjpa (if
possible)...
Could someone give his lights on this one please?

many thanks in advance...

Michail

results = em.createQuery(""+
				"select boo,oo,ooq,oori from"+
				" BrandOrderOffer boo, OrderOffer oo, OrderOfferOriginQualification ooq,
OrderOfferRewardItem oori "+
				" where"+
				" boo.pk.cmpyN = :brand and"+
				" boo.pk.ordOffrN = oo.pk.ordOffrN and"+
				" oo.pk.ordOffrN = ooq.pk.ordOffrN and"+
				" ooq.pk.rwrdN = oori.rwrdN and"+
				" ooq.pk.ordOrigC = '9' and"+
				" oo.ordOffrCancF = 'N' and"+
				" oo.pk.ordOffrEndD > :endDate and"+
				" oo.pk.ordOffrStrtD <= :startDate and"+				
				" (oo.ordOffrCustC = :custType or oo.ordOffrCustC = '3') and"+
				" (oo.ordTypeN is null or oo.ordTypeN='   ' or oo.ordTypeN=:orderType)")
				.setParameter("brand",(long)brand2)
				.setParameter("endDate",endDate)
				.setParameter("startDate",startDate)				
				.setParameter("custType",custType2)
				.setParameter("orderType",orderType2)
				.getResultList();

-- 
View this message in context: http://openjpa.208410.n2.nabble.com/quick-question-regarding-joining-tables-tp5463014p5463014.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.