As you guys know, I've been against the idea of fetch profiles for a
long time (Max always disagreed).

(BTW, please clearly distingush "fetch profiles" from "fetch plans". We
have had "fetch plans" for years, as a subset of what the Criteria API
can do.)

The basis for my problem was that a fetch profile is really specific to
a particular transaction, but ends up being expressed in the mapping
document, which is a _global_ construct. So, if I try to use this "fetch
profile" approach, what happens is that I end up with a list of
transactions in every association mapping. Clearly this does not scale
to systems with hundreds of transactions that touch the same data (which
is commonplace). So instead, we tried to guide people down the "express
what data you need, upfront, in your query" path, which not only avoids
this code scalability problem, but is also by nature more efficient.

What you might also know (but maybe you don't) is that Hibernate has
internally supported fetch profiles for quite a long time (we actually
have a special fetch profile that is used internally for the merge()
operation). We never actually exposed this to users, since in practice
users never seemed to ask for it, and because we in principle do things
that users actually want and ask for, not things that our competitors
marketing departments tell people they want.

It occurred to me today that you could avoid my objection just by
defining the fetch profile in its own section of the XML, instead of in
the association mappings. eg.

  <profile name="login">
     <association name="User.roles" fetch="join"/>
     <association name="User.orders" fetch="select"/>
  </profile>

Then just call session.setProfile("login"), and all criteria queries,
load(), get() and association fetches would obey the profile.

Frankly, I feel silly for not have considered to do it that way before.

The <profile> could also be a good place to make some other things
settable, eg, TX isolation mode, flushmode, TX timeout, etc.

WDYT? Is it a nice construct?


-------------------------------------------------------
All the advantages of Linux Managed Hosting--Without the Cost and Risk!
Fully trained technicians. The highest number of Red Hat certifications in
the hosting industry. Fanatical Support. Click to learn more
http://sel.as-us.falkag.net/sel?cmd=lnk&kid7521&bid$8729&dat1642
_______________________________________________
hibernate-devel mailing list
hibernate-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/hibernate-devel

Reply via email to