Quote:
That's correct, what do you think of this API BTW?
Well I was very happy it was there so I really hadn't thought to hard about it, but since you asked I do have some feedback. The documentation says that really the only reason you should use setCriteriaQuery is to load associations, however, the API does not enforce this condition so the user could do something that's not allowed. Right now you have to read the docs to figure out that Criteria query isn't ment to be used for any old query. I would encapsulate the criteria creation behind the scenes so that it doesn't allow the user to get himself into trouble by doing things that the docs say don't do. Besides if it's there somebody will try to do something bizzare just becase they can. ;-)
For example:
Code:
List list = fullTextSession.createFullTextQuery( parser.parse( searchString ), MessageEntity.class ).eager( MessageEntity.class, "attachments" ).list();
Allow for multiple properties on a class.
Code:
List list = fullTextSession.createFullTextQuery( parser ).eager( Book.class, "authors", "pages" ).list();
Allow for eager() to be called more than once to load several relationships.
Code:
List list = fullTextSession.createFullTextQuery( parser ).include( RecordCollection.class, "linerNotes").eager( Album.class, "tracks" ).list();
You might want to allow for specifying to lazy load a relationship like:
Code:
List list = fullTextSession.createFullTextQuery( parser ).lazy( Book.class, "authors" ).list();
I use the terms eager and lazy to match up the the FetchMode annotations in JPA. Those are more about what the user wants to happen as opposed to the hibernate terms. Join and Select are what the library actually does to get a lazy or eager loading. They're just a little lower level lingo for my tastes.