-->
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: Architectural suggestion
PostPosted: Thu Oct 23, 2003 3:44 pm 
Senior
Senior

Joined: Tue Oct 21, 2003 8:15 am
Posts: 186
A feature I miss from both Hibernate and, in fact, all OODBMS's is a "object graph selection" mechanism/language.

By this, I mean a way of specifying which parts of an object graph should be returned from the database. This has important value in terms of performance.

Following references outside the selected graph closure would happend in a lazy manner, while everything within the closure is preloaded.

For instance:

Person[] persons = session.select("from Person (include Addresses (include Streets)) where Addresses.Country = 'Australia'");

Or something like that...

Any thoughts about such a feature?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Oct 23, 2003 4:40 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
HQL "LEFT JOIN FETCH" construct.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Oct 24, 2003 3:50 am 
Senior
Senior

Joined: Tue Oct 21, 2003 8:15 am
Posts: 186
Ah - very clever!


Top
 Profile  
 
 Post subject:
PostPosted: Fri Oct 24, 2003 7:20 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
...but be aware that HQL currently only support one (1) FETCH per HQL.....

...but please raise a JIRA for having more than 1 FETCH per HQL so we can see how much people really want it ;)

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Fri Oct 24, 2003 4:35 pm 
Beginner
Beginner

Joined: Fri Aug 29, 2003 12:38 am
Posts: 22
Location: Phoenix, AZ
having more than one fetch per query would be VERY usefull.. for our uses we would mark EVERYTHING either lazy or proxy, then based on use case "fetch" the proper portions of the graph.


I would also like to see some variation on fetch profiles that could be used in conjuction with HQL. maby "named" profiles defined in the mapping files that could be used within the queries:

mapping:
Code:
<fetchprofile name="cat_kittens_and_mate" class="eg.Cat">
  <collection-fetch property="kittens"/>
  <property-fetch property="mate"/>
</fetchprofile>


query:
Code:
select cat  from eg.Cat cat where cat.something=value using fetch profile cat_kittens_and_mate


This would allow the system archetects to define what are acceptable fetch profiles and application developers would just use one of the predefined fetch profiles


Top
 Profile  
 
 Post subject:
PostPosted: Fri Oct 24, 2003 5:10 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Max mis-spoke. You can have as many FETCH joins as you like. But only one may be of a collection.


Top
 Profile  
 
 Post subject:
PostPosted: Sat Oct 25, 2003 5:51 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
ah the small gritty details - but it sure would be nice to express the fetch strategy explictly instead of via a bunch of "external" Hibernate.initialize() calls ;)

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Sat Oct 25, 2003 6:34 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
It would not be at all difficult and might indeed be quite nice to add fetch profiles to the Criteria API. eg.

Code:
session.createCriteria(Foo.class)
    .setFetchProfile("Foo.default")
    .add( Expression.isNotNull("bar") )
    .list();


the "fetch profile" would just be a named list of property names, and setFetchProfile() would be equivalent to calling setFetchMode("name", FetchMode.EAGER) for each.

This should be easy for whoever wants to implement it....


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.