Originally posted by Rvrk reddy:
Mark: I know hibernate basics, we have complicated reflection code to generate polymorphic queries. In summary in our code we can only do "criteria.list", this criteria/associations populated by reflection.
If I hard code in my EJB (by using LEFT_JOIN), I get only one SQL, but our requirement is diffrent.
Can you please suggest me right mappings that can generate only ONE SQL in posted usecase, if this works I will try to simulate by reflection.
Thanks a lot.
Originally posted by Mark Spritzler:
I don't understand what you mean here. "If I hard code in my EJB"? We need code examples for you to demonstrate. Also if you have to have the fetching strategy to stay the same throughout your application, which I doubt, you can set your collection fetching strategies to either "subselect" or eager.
Mark
Originally posted by Mark Spritzler:
Try the above mapping, By default Hibernate loads things lazily. For Many To One, they put a Proxy object for History and Security. Which means if you query for a User, it will not run a query against History or Security. The moment your code gets the History or Security object, it will run a query for each one.
Now if you don't want a proxy for History or Security and you want it all loaded when you query for the User, which makes just one query for all of it, then use the following mapping.
I was figuring you were talking about the One-To-Many, because usually that is what people are talking about with the N+1. But it can relate to a many to one, just that the N is really a 1 also, so it would be a 1+1 selects issue.
Mark
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime. |