These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 8 posts ] 
Author Message
 Post subject: Time to process queries through criteria api and EM queries
PostPosted: Sat Oct 07, 2006 3:27 pm 
Newbie

Joined: Sat Oct 07, 2006 2:48 pm
Posts: 17
hi, i had a problem that i solved 1 week ago, but that is not the reason i am posting here.

The Problem
I had to make a query to get some results, but the problem was if i did it through criteria api it took around 30 secods for return the resuts!. If if did it with directly query through entity manager, it took around 2 seconds.

The Context
I have a Shift, Order and Activity entities, shift and order have a many-to-many relation, order has a one-to-many relation with activity and also shift has a one-to-many relation with activity.
the entities look like this:

Code:
Activity:
@OneToMany
Shift shift;
@OneToMany
Order order;

Order:
@ManyToMany
List<Shift> shifts;
@OneToMany(mappedBy="order")
List<Activity> activities;


Shift:
@ManyToMany
List<Order> orders;
@OneToMany(mappedBy="shift")
List<Activity> activities;

(they have more propierties, but i am not going to put here them)
Activity has a not-null constraint with order, but has a null constrait with shift, because an activity can be created for one order, (the order has a valid shift) but with null shift. This means that the activity was created for status only, like NotFinishedStatus, ReassignedStatus, etc. I want to report the shift, i have to shown only those orders that have an activity (because one order can be created but nobody makes and activity for it) and also i have to show those orders that have an activity with reassigned status (this means that somebody made activities for the order, and at the end reassigned the order to other shift).

The queries
Code:
Criteria API

List<Activity> activityList = getSession()
   .createCriteria(Activity.class)
   .add(Property.forName("order").in(shift.getOrders()))
   .add( Restrictions.or(
      Property.forName("shift").eq(new Integer(shift.getId())),
      Property.forName("description").like(REASSIGN+"%")))
   .addOrder( Order.asc("order") )
   .list();

It takes around 30 seconds!


Code:
EntityManager Query

List<Activity> activityList = entityManager
   .createQuery("from Activity a"
   + " where a.order.id in (:orderList)"
   + " and (a.shift.id = :sId "
   + " or a.description like :reassignStatus)"
   + " order by a.order.id")
   .setParameter("orderList",shift.getOrders())
   .setParameter("sId",shift.getId())
   .setParameter("reassignStatus",REASSIGN+"%")
   .getResultList();

It takes around 2 seconds!


i'd like to know why this occurs, because i use criteria api in almost all my project.


thanks to all. and thanks to hibernate.


Top
 Profile  
 
 Post subject:
PostPosted: Sat Oct 07, 2006 10:43 pm 
Regular
Regular

Joined: Tue Sep 26, 2006 11:37 am
Posts: 115
Location: Sacramento, CA
Nopalin,

Could you post the generated sql for the two cases? Thanks a lot!

Marius


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 09, 2006 2:26 pm 
Newbie

Joined: Sat Oct 07, 2006 2:48 pm
Posts: 17
sorry, how can i get generate sql? i was searching around 1 hour, and didn't find anything, only hibernate query.

thanks


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 09, 2006 9:52 pm 
Regular
Regular

Joined: Tue Sep 26, 2006 11:37 am
Posts: 115
Location: Sacramento, CA
Look at hibernate.show_sql in

http://www.hibernate.org/hib_docs/refer ... -xmlconfig


If you ran a web app generally stdout goes into your server log.

Marius


Top
 Profile  
 
 Post subject:
PostPosted: Sat Oct 14, 2006 2:22 pm 
Newbie

Joined: Sat Oct 07, 2006 2:48 pm
Posts: 17
Hi, sorry but had a lot of things to do.

Ok these are the queries, but how i said above the entities have many properties.. so the queries are very big.


Queries through Criteria API
Quote:
Query generate for shift.getOrders() (parameters)
2006-10-14 13:00:17,746 INFO [STDOUT] Hibernate: select workorders0_.WorkedShift_id as WorkedSh1_1_, workorders0_.workOrders_id as workOrders2_1_, workorder1_.id as id401_0_, workorder1_.cause as cause401_0_, workorder1_.priority as priority401_0_, workorder1_.description as descript4_401_0_, workorder1_.line_id as line12_401_0_, workorder1_.internal as internal401_0_, workorder1_.finishStatus_id as finishS13_401_0_, workorder1_.openStatus_id as openStatus14_401_0_, workorder1_.closeStatus_id as closeSt15_401_0_, workorder1_.plant_id as plant16_401_0_, workorder1_.mainSaverId as mainSave6_401_0_, workorder1_.lastStatus_id as lastStatus17_401_0_, workorder1_.equipName as equipName401_0_, workorder1_.lastMaintenance_id as lastMai18_401_0_, workorder1_.lastPlant_id as lastPlant19_401_0_, workorder1_.deathTimeMaintenance as deathTim8_401_0_, workorder1_.deathTimeOthers as deathTim9_401_0_, workorder1_.lastCloseActivity_id as lastClo20_401_0_, workorder1_.lastCloseActivityInWorkedshift_id as lastClo21_401_0_, workorder1_.maintenance_id as mainten22_401_0_, workorder1_.equip_id as equip23_401_0_, workorder1_.workGroup_id as workGroup24_401_0_, workorder1_.noAutoInsertable as noAutoI10_401_0_, workorder1_.inProcessStatus_id as inProce25_401_0_, workorder1_.printStatus_id as printSt26_401_0_, workorder1_.mainSaverSync as mainSav11_401_0_ from WorkedShift_WorkOrder workorders0_ left outer join WorkOrder workorder1_ on workorders0_.workOrders_id=workorder1_.id where workorders0_.WorkedShift_id=?

Query generate by Criteria API
2006-10-14 13:00:17,800 INFO [STDOUT] Hibernate: select this_.id as id396_10_, this_.description as descript2_396_10_, this_.line_id as line5_396_10_, this_.finishStatus_id as finishSt6_396_10_, this_.openStatus_id as openStatus7_396_10_, this_.closeStatus_id as closeSta8_396_10_, this_.workedShift_id as workedSh9_396_10_, this_.lastStatus_id as lastStatus10_396_10_, this_.deathTimeMaintenance as deathTim3_396_10_, this_.deathTimeOthers as deathTim4_396_10_, this_.pendingReason_id as pending11_396_10_, this_.workOrder_id as workOrder12_396_10_, this_.activityType_id as activit13_396_10_, this_.purchase_id as purchase14_396_10_, purchase2_.id as id408_0_, purchase2_.provider_id as provider14_408_0_, purchase2_.note as note408_0_, purchase2_.destination_id as destina15_408_0_, purchase2_.quantity as quantity408_0_, purchase2_.openStatus_id as openStatus16_408_0_, purchase2_.closeStatus_id as closeSt17_408_0_, purchase2_.application as applicat4_408_0_, purchase2_.workOrder_id as workOrder18_408_0_, purchase2_.equip_id as equip19_408_0_, purchase2_.lastStatusName as lastStat5_408_0_, purchase2_.requester_id as requester20_408_0_, purchase2_.productCost as productC6_408_0_, purchase2_.rejectedCount as rejected7_408_0_, purchase2_.priceDate as priceDate408_0_, purchase2_.arriveDate as arriveDate408_0_, purchase2_.promisedDate as promise10_408_0_, purchase2_.purchaseOrder as purchas11_408_0_, purchase2_.previousEquip as previou12_408_0_, purchase2_.rejected as rejected408_0_, provider3_.id as id406_1_, provider3_.name as name406_1_, provider3_.disabled as disabled406_1_, provider3_.description as descript4_406_1_, provider3_.providerType_id as provider5_406_1_, providerty4_.id as id407_2_, providerty4_.name as name407_2_, providerty4_.disabled as disabled407_2_, providerty4_.description as descript4_407_2_, destinatio5_.id as id405_3_, destinatio5_.name as name405_3_, destinatio5_.disabled as disabled405_3_, destinatio5_.description as descript4_405_3_, destinatio5_.centroCostos as centroCo5_405_3_, status6_.id as id395_4_, status6_.name as name395_4_, status6_.date as date395_4_, status6_.person_id as person4_395_4_, workorder7_.id as id401_5_, workorder7_.cause as cause401_5_, workorder7_.priority as priority401_5_, workorder7_.description as descript4_401_5_, workorder7_.line_id as line12_401_5_, workorder7_.internal as internal401_5_, workorder7_.finishStatus_id as finishS13_401_5_, workorder7_.openStatus_id as openStatus14_401_5_, workorder7_.closeStatus_id as closeSt15_401_5_, workorder7_.plant_id as plant16_401_5_, workorder7_.mainSaverId as mainSave6_401_5_, workorder7_.lastStatus_id as lastStatus17_401_5_, workorder7_.equipName as equipName401_5_, workorder7_.lastMaintenance_id as lastMai18_401_5_, workorder7_.lastPlant_id as lastPlant19_401_5_, workorder7_.deathTimeMaintenance as deathTim8_401_5_, workorder7_.deathTimeOthers as deathTim9_401_5_, workorder7_.lastCloseActivity_id as lastClo20_401_5_, workorder7_.lastCloseActivityInWorkedshift_id as lastClo21_401_5_, workorder7_.maintenance_id as mainten22_401_5_, workorder7_.equip_id as equip23_401_5_, workorder7_.workGroup_id as workGroup24_401_5_, workorder7_.noAutoInsertable as noAutoI10_401_5_, workorder7_.inProcessStatus_id as inProce25_401_5_, workorder7_.printStatus_id as printSt26_401_5_, workorder7_.mainSaverSync as mainSav11_401_5_, equip8_.id as id392_6_, equip8_.name as name392_6_, equip8_.disabled as disabled392_6_, equip8_.description as descript4_392_6_, equip8_.plant_id as plant5_392_6_, person9_.id as id412_7_, person9_.name as name412_7_, person9_.disabled as disabled412_7_, person9_.contact_id as contact6_412_7_, person9_.secondName as secondName412_7_, person9_.thirdName as thirdName412_7_, contact10_.id as id410_8_, contact10_.address as address410_8_, contact10_.email as email410_8_, contact10_.telephone as telephone410_8_, contact10_.fax as fax410_8_, contact10_.pager as pager410_8_, employee11_.id as id391_9_, employee11_.person_id as person3_391_9_, employee11_.employeeId as employeeId391_9_ from Activity this_ left outer join Purchase purchase2_ on this_.purchase_id=purchase2_.id left outer join Provider provider3_ on purchase2_.provider_id=provider3_.id left outer join ProviderType providerty4_ on provider3_.providerType_id=providerty4_.id left outer join Destination destinatio5_ on purchase2_.destination_id=destinatio5_.id left outer join Status status6_ on purchase2_.openStatus_id=status6_.id left outer join WorkOrder workorder7_ on purchase2_.workOrder_id=workorder7_.id left outer join Equip equip8_ on purchase2_.equip_id=equip8_.id left outer join Person person9_ on purchase2_.requester_id=person9_.id left outer join Contact contact10_ on person9_.contact_id=contact10_.id left outer join Employee employee11_ on person9_.id=employee11_.person_id where this_.workOrder_id in (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) and (this_.workedShift_id is not null or this_.description like ?) order by this_.workOrder_id asc



Queries through EM
Quote:
Query generate for shift.getOrders() (parameters)
Is is the same as above

Queries generated by EM
2006-10-14 13:04:45,175 INFO [STDOUT] Hibernate: select activity0_.id as id396_, activity0_.description as descript2_396_, activity0_.line_id as line5_396_, activity0_.finishStatus_id as finishSt6_396_, activity0_.openStatus_id as openStatus7_396_, activity0_.closeStatus_id as closeSta8_396_, activity0_.workedShift_id as workedSh9_396_, activity0_.lastStatus_id as lastStatus10_396_, activity0_.deathTimeMaintenance as deathTim3_396_, activity0_.deathTimeOthers as deathTim4_396_, activity0_.pendingReason_id as pending11_396_, activity0_.workOrder_id as workOrder12_396_, activity0_.activityType_id as activit13_396_, activity0_.purchase_id as purchase14_396_ from Activity activity0_ where (activity0_.workOrder_id in (? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ?)) and (activity0_.workedShift_id=? or activity0_.description like ?) order by activity0_.workOrder_id

2006-10-14 13:04:46,336 INFO [STDOUT] Hibernate: select purchase0_.id as id408_9_, purchase0_.provider_id as provider14_408_9_, purchase0_.note as note408_9_, purchase0_.destination_id as destina15_408_9_, purchase0_.quantity as quantity408_9_, purchase0_.openStatus_id as openStatus16_408_9_, purchase0_.closeStatus_id as closeSt17_408_9_, purchase0_.application as applicat4_408_9_, purchase0_.workOrder_id as workOrder18_408_9_, purchase0_.equip_id as equip19_408_9_, purchase0_.lastStatusName as lastStat5_408_9_, purchase0_.requester_id as requester20_408_9_, purchase0_.productCost as productC6_408_9_, purchase0_.rejectedCount as rejected7_408_9_, purchase0_.priceDate as priceDate408_9_, purchase0_.arriveDate as arriveDate408_9_, purchase0_.promisedDate as promise10_408_9_, purchase0_.purchaseOrder as purchas11_408_9_, purchase0_.previousEquip as previou12_408_9_, purchase0_.rejected as rejected408_9_, provider1_.id as id406_0_, provider1_.name as name406_0_, provider1_.disabled as disabled406_0_, provider1_.description as descript4_406_0_, provider1_.providerType_id as provider5_406_0_, providerty2_.id as id407_1_, providerty2_.name as name407_1_, providerty2_.disabled as disabled407_1_, providerty2_.description as descript4_407_1_, destinatio3_.id as id405_2_, destinatio3_.name as name405_2_, destinatio3_.disabled as disabled405_2_, destinatio3_.description as descript4_405_2_, destinatio3_.centroCostos as centroCo5_405_2_, status4_.id as id395_3_, status4_.name as name395_3_, status4_.date as date395_3_, status4_.person_id as person4_395_3_, workorder5_.id as id401_4_, workorder5_.cause as cause401_4_, workorder5_.priority as priority401_4_, workorder5_.description as descript4_401_4_, workorder5_.line_id as line12_401_4_, workorder5_.internal as internal401_4_, workorder5_.finishStatus_id as finishS13_401_4_, workorder5_.openStatus_id as openStatus14_401_4_, workorder5_.closeStatus_id as closeSt15_401_4_, workorder5_.plant_id as plant16_401_4_, workorder5_.mainSaverId as mainSave6_401_4_, workorder5_.lastStatus_id as lastStatus17_401_4_, workorder5_.equipName as equipName401_4_, workorder5_.lastMaintenance_id as lastMai18_401_4_, workorder5_.lastPlant_id as lastPlant19_401_4_, workorder5_.deathTimeMaintenance as deathTim8_401_4_, workorder5_.deathTimeOthers as deathTim9_401_4_, workorder5_.lastCloseActivity_id as lastClo20_401_4_, workorder5_.lastCloseActivityInWorkedshift_id as lastClo21_401_4_, workorder5_.maintenance_id as mainten22_401_4_, workorder5_.equip_id as equip23_401_4_, workorder5_.workGroup_id as workGroup24_401_4_, workorder5_.noAutoInsertable as noAutoI10_401_4_, workorder5_.inProcessStatus_id as inProce25_401_4_, workorder5_.printStatus_id as printSt26_401_4_, workorder5_.mainSaverSync as mainSav11_401_4_, equip6_.id as id392_5_, equip6_.name as name392_5_, equip6_.disabled as disabled392_5_, equip6_.description as descript4_392_5_, equip6_.plant_id as plant5_392_5_, person7_.id as id412_6_, person7_.name as name412_6_, person7_.disabled as disabled412_6_, person7_.contact_id as contact6_412_6_, person7_.secondName as secondName412_6_, person7_.thirdName as thirdName412_6_, contact8_.id as id410_7_, contact8_.address as address410_7_, contact8_.email as email410_7_, contact8_.telephone as telephone410_7_, contact8_.fax as fax410_7_, contact8_.pager as pager410_7_, employee9_.id as id391_8_, employee9_.person_id as person3_391_8_, employee9_.employeeId as employeeId391_8_ from Purchase purchase0_ left outer join Provider provider1_ on purchase0_.provider_id=provider1_.id left outer join ProviderType providerty2_ on provider1_.providerType_id=providerty2_.id left outer join Destination destinatio3_ on purchase0_.destination_id=destinatio3_.id left outer join Status status4_ on purchase0_.openStatus_id=status4_.id left outer join WorkOrder workorder5_ on purchase0_.workOrder_id=workorder5_.id left outer join Equip equip6_ on purchase0_.equip_id=equip6_.id left outer join Person person7_ on purchase0_.requester_id=person7_.id left outer join Contact contact8_ on person7_.contact_id=contact8_.id left outer join Employee employee9_ on person7_.id=employee9_.person_id where purchase0_.id=?

2006-10-14 13:04:46,350 INFO [STDOUT] Hibernate:
select purchase0_.id as id408_9_, purchase0_.provider_id as provider14_408_9_, purchase0_.note as note408_9_, purchase0_.destination_id as destina15_408_9_, purchase0_.quantity as quantity408_9_, purchase0_.openStatus_id as openStatus16_408_9_, purchase0_.closeStatus_id as closeSt17_408_9_, purchase0_.application as applicat4_408_9_, purchase0_.workOrder_id as workOrder18_408_9_, purchase0_.equip_id as equip19_408_9_, purchase0_.lastStatusName as lastStat5_408_9_, purchase0_.requester_id as requester20_408_9_, purchase0_.productCost as productC6_408_9_, purchase0_.rejectedCount as rejected7_408_9_, purchase0_.priceDate as priceDate408_9_, purchase0_.arriveDate as arriveDate408_9_, purchase0_.promisedDate as promise10_408_9_, purchase0_.purchaseOrder as purchas11_408_9_, purchase0_.previousEquip as previou12_408_9_, purchase0_.rejected as rejected408_9_, provider1_.id as id406_0_, provider1_.name as name406_0_, provider1_.disabled as disabled406_0_, provider1_.description as descript4_406_0_, provider1_.providerType_id as provider5_406_0_, providerty2_.id as id407_1_, providerty2_.name as name407_1_, providerty2_.disabled as disabled407_1_, providerty2_.description as descript4_407_1_, destinatio3_.id as id405_2_, destinatio3_.name as name405_2_, destinatio3_.disabled as disabled405_2_, destinatio3_.description as descript4_405_2_, destinatio3_.centroCostos as centroCo5_405_2_, status4_.id as id395_3_, status4_.name as name395_3_, status4_.date as date395_3_, status4_.person_id as person4_395_3_, workorder5_.id as id401_4_, workorder5_.cause as cause401_4_, workorder5_.priority as priority401_4_, workorder5_.description as descript4_401_4_, workorder5_.line_id as line12_401_4_, workorder5_.internal as internal401_4_, workorder5_.finishStatus_id as finishS13_401_4_, workorder5_.openStatus_id as openStatus14_401_4_, workorder5_.closeStatus_id as closeSt15_401_4_, workorder5_.plant_id as plant16_401_4_, workorder5_.mainSaverId as mainSave6_401_4_, workorder5_.lastStatus_id as lastStatus17_401_4_, workorder5_.equipName as equipName401_4_, workorder5_.lastMaintenance_id as lastMai18_401_4_, workorder5_.lastPlant_id as lastPlant19_401_4_, workorder5_.deathTimeMaintenance as deathTim8_401_4_, workorder5_.deathTimeOthers as deathTim9_401_4_, workorder5_.lastCloseActivity_id as lastClo20_401_4_, workorder5_.lastCloseActivityInWorkedshift_id as lastClo21_401_4_, workorder5_.maintenance_id as mainten22_401_4_, workorder5_.equip_id as equip23_401_4_, workorder5_.workGroup_id as workGroup24_401_4_, workorder5_.noAutoInsertable as noAutoI10_401_4_, workorder5_.inProcessStatus_id as inProce25_401_4_, workorder5_.printStatus_id as printSt26_401_4_, workorder5_.mainSaverSync as mainSav11_401_4_, equip6_.id as id392_5_, equip6_.name as name392_5_, equip6_.disabled as disabled392_5_, equip6_.description as descript4_392_5_, equip6_.plant_id as plant5_392_5_, person7_.id as id412_6_, person7_.name as name412_6_, person7_.disabled as disabled412_6_, person7_.contact_id as contact6_412_6_, person7_.secondName as secondName412_6_, person7_.thirdName as thirdName412_6_, contact8_.id as id410_7_, contact8_.address as address410_7_, contact8_.email as email410_7_, contact8_.telephone as telephone410_7_, contact8_.fax as fax410_7_, contact8_.pager as pager410_7_, employee9_.id as id391_8_, employee9_.person_id as person3_391_8_, employee9_.employeeId as employeeId391_8_ from Purchase purchase0_ left outer join Provider provider1_ on purchase0_.provider_id=provider1_.id left outer join ProviderType providerty2_ on provider1_.providerType_id=providerty2_.id left outer join Destination destinatio3_ on purchase0_.destination_id=destinatio3_.id left outer join Status status4_ on purchase0_.openStatus_id=status4_.id left outer join WorkOrder workorder5_ on purchase0_.workOrder_id=workorder5_.id left outer join Equip equip6_ on purchase0_.equip_id=equip6_.id left outer join Person person7_ on purchase0_.requester_id=person7_.id left outer join Contact contact8_ on person7_.contact_id=contact8_.id left outer join Employee employee9_ on person7_.id=employee9_.person_id where purchase0_.id=?


why do EM create 3 queries?

sorry if it has a lot of spam, but i tried with some legible and the queries took the same time. In this case the time is very different.

thanks


Top
 Profile  
 
 Post subject:
PostPosted: Sun Oct 15, 2006 12:23 pm 
Regular
Regular

Joined: Tue Sep 26, 2006 11:37 am
Posts: 115
Location: Sacramento, CA
Nopalin,

Your details are difficult to follow. I cleaned up the 2 series of queries and they seem to be very different. That's suspicious... the examples are a bit too convoluted for the time I have available to look at them ... sorry :(

One way or another the second set of queries should be fast if you have the proper indexes in place.

Code:
--- Criteria API ---

select xxxx
from Activity this_
  left outer join Purchase purchase2_ on this_.purchase_id=purchase2_.id
  left outer join Provider provider3_ on purchase2_.provider_id=provider3_.id
  left outer join ProviderType providerty4_ on provider3_.providerType_id=providerty4_.id
  left outer join Destination destinatio5_ on purchase2_.destination_id=destinatio5_.id
  left outer join Status status6_ on purchase2_.openStatus_id=status6_.id
  left outer join WorkOrder workorder7_ on purchase2_.workOrder_id=workorder7_.id
  left outer join Equip equip8_ on purchase2_.equip_id=equip8_.id
  left outer join Person person9_ on purchase2_.requester_id=person9_.id
  left outer join Contact contact10_ on person9_.contact_id=contact10_.id
  left outer join Employee employee11_ on person9_.id=employee11_.person_id
  where this_.workOrder_id in (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
   and (this_.workedShift_id is not null or this_.description like ?)
  order by this_.workOrder_id asc
 
 
-- EM --
select xxxxx
  from Activity activity0_
  where (activity0_.workOrder_id in (? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ?)) and (activity0_.workedShift_id=? or activity0_.description like ?)
  order by activity0_.workOrder_id

select xxxx
  from Purchase purchase0_
  left outer join Provider provider1_ on purchase0_.provider_id=provider1_.id
  left outer join ProviderType providerty2_ on provider1_.providerType_id=providerty2_.id
  left outer join Destination destinatio3_ on purchase0_.destination_id=destinatio3_.id
  left outer join Status status4_ on purchase0_.openStatus_id=status4_.id
  left outer join WorkOrder workorder5_ on purchase0_.workOrder_id=workorder5_.id
  left outer join Equip equip6_ on purchase0_.equip_id=equip6_.id
  left outer join Person person7_ on purchase0_.requester_id=person7_.id
  left outer join Contact contact8_ on person7_.contact_id=contact8_.id
  left outer join Employee employee9_ on person7_.id=employee9_.person_id
  where purchase0_.id=?

select xxxx
  from Purchase purchase0_
  left outer join Provider provider1_ on purchase0_.provider_id=provider1_.id
  left outer join ProviderType providerty2_ on provider1_.providerType_id=providerty2_.
  id left outer join Destination destinatio3_ on purchase0_.destination_id=destinatio3_.id
  left outer join Status status4_ on purchase0_.openStatus_id=status4_.id
  left outer join WorkOrder workorder5_ on purchase0_.workOrder_id=workorder5_.id
  left outer join Equip equip6_ on purchase0_.equip_id=equip6_.id
  left outer join Person person7_ on purchase0_.requester_id=person7_.id
  left outer join Contact contact8_ on person7_.contact_id=contact8_.id
  left outer join Employee employee9_ on person7_.id=employee9_.person_id
  where purchase0_.id=?


Top
 Profile  
 
 Post subject:
PostPosted: Sun Oct 15, 2006 2:35 pm 
Newbie

Joined: Sat Oct 07, 2006 2:48 pm
Posts: 17
don't worry, thanks for your time however.

Ok, the question is: why the queries are different in both cases? and why EM generate 3 queries?

im confused on how hibernate generate the queries, but if criteria api take more time executing the query agains EM, i think im going to use EM in place of Criteria API.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 16, 2006 6:16 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
read up about the differences between criteria and hql.

e.g. how one obeys fetch and the other does not.

_________________
Max
Don't forget to rate


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 8 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.