Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » Fetching entities with their lazy Lob fields using a query?
Fetching entities with their lazy Lob fields using a query? [message #892449] Thu, 28 June 2012 09:15 Go to next message
Didier L is currently offline Didier LFriend
Messages: 2
Registered: June 2012
Junior Member
Hi all,

We have some Report entity that contains a PDF file stored as a BLOB. It is declared like this:

@Entity
public class Report {
	@Id
	private int id;

	@Column(name = "B_PDF")
	@Lob @Basic(fetch=FetchType.LAZY)
	private byte[] pdf;
...
}


So that we don't load the PDF when we don't need it (i.e. most of the time).

However for some feature we need to load several reports with their PDF so we'd like to perform a single query that loads everything. Is it possible using EclipseLink?

We already tried
JOIN FETCH r.pdf
(which used to work with OpenJPA) and
query.setHint("eclipselink.join-fetch", "r.pdf");

but both throw an exception saying that this field does not support joining.

We are using WebLogic 12c with the provided version of EclipseLink.
Re: Fetching entities with their lazy Lob fields using a query? [message #892549 is a reply to message #892449] Thu, 28 June 2012 15:15 Go to previous messageGo to next message
Chris Delahunt is currently offline Chris DelahuntFriend
Messages: 1389
Registered: July 2009
Senior Member
http://wiki.eclipse.org/EclipseLink/Development/2.1/AdvancedJPA_Queries/FetchGroup
details using fetch groups. All lazy attributes are excluded from the default fetch group. You can create a named fetch group that includes your lob field and any others you may need, and use it with the QueryHints.FETCH_GROUP_NAME to have it fetched.

You can also use the QueryHints.FETCH_GROUP_DEFAULT with a value of false so the default fetch group is not used and all lazy attributes (this still excludes lazy relationships) are loaded.

Best Regards,
Chris

[Updated on: Thu, 28 June 2012 15:18]

Report message to a moderator

Re: Fetching entities with their lazy Lob fields using a query? [message #892992 is a reply to message #892549] Mon, 02 July 2012 08:47 Go to previous message
Didier L is currently offline Didier LFriend
Messages: 2
Registered: June 2012
Junior Member
Thanks. I just notice that its configuration via eclipselink-orm.xml does not seem to be documented, which would be useful to keep the source code provider-independent (we need to remain compatible with WLS 10g)

Anyway in the end we switched to a native query that fetches those fields separately (+ an XML_TYPE).
Previous Topic:Connect with MS-SQL "lock"
Next Topic:not retrieving entity when an attribute of it has value 0.0
Goto Forum:
  


Current Time: Thu Mar 28 14:34:30 GMT 2024

Powered by FUDForum. Page generated in 0.03752 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top