I’m developing an application with nHibernate and MySQL.
I have a HQL command that runs every second, and in this command I do a “Inner Join Fetch”, like this:
“from Order o inner join fetch o.Customer order by o.Date”
It’s work fine but It fill all properties of “Customer”, and I have a lot of columns in DataBase (almost 40 columns). I need only some columns like Name, Address and Telephone to show in my presentation layer.
Is there any way to get only some properties doing a Fecth Join or another way to improve performace?
Thanks…
Cheers
If you are looking for some properties only, don’t use
join fetch, because that’s not what it’s for.Instead, select the properties you want and (optionally) hydrate a DTO with them. You don’t even need an explicit join:
That returns a tuple (
object[]) for each row, where the 1st element is the order, the 2nd is the customer name, etc.