I have a question about the use of Fetch.JOIN I would like some advice on.
The gui I am developing is seperate from the business tier and therefore I am 'preparing' the objects I need so that I dont get Lazy exceptions.
99% of the non-lazy configuration is done using Fetch.JOIN as apposed to in the xml mappings because other systems access this shared business tier/service.
The result is I end up with queries like so with many JOIN modes:
Code:
List accounts = getSessionFactory().getCurrentSession()
.createCriteria(Account.class)
.add(Restrictions.eq("uuid", uuid))
.setFetchMode("parentAccountGroups", FetchMode.JOIN)
.setFetchMode("childAccountGroups", FetchMode.JOIN)
.setFetchMode("generalPositionLimit",FetchMode.JOIN)
.setFetchMode("generalClipSizeLimit",FetchMode.JOIN)
.setFetchMode("bookableInstrumentGroups",FetchMode.JOIN)
.setFetchMode("bookableInstrumentGroups.clipSizeLimit",FetchMode.JOIN)
.setFetchMode("bookableInstrumentGroups.positionLimit",FetchMode.JOIN)
.setFetchMode("type", FetchMode.SELECT)
.list();
Is this a good approach or should I use Hibernate.initialise instead of all the JOIN statements
best regards
JC