left join fetch with long text fields

2 messages Options
Embed this post
Permalink
Daryl Stultz

left join fetch with long text fields

Reply Threaded More More options
Print post
Permalink
Hello,

I have entity B with field "myLongText" defined like so:

@Column(name = "mylongtext", length = -1)
private String myLongText;

In PostgreSQL the column is a varchar(0).

When I retrieve a list of B entities, I get myLongText as expected, selected
in one query. Suppose I have entity A with bCol, a collection of B. If I
select like so:

select distinct o from A as o
left join fetch o.bCol

the value of myLongText is retrieved with an individual query PER B
instance! Naturally this is pretty slow. Is there some way to annotate this
field so it is always retrieved in the main query? Do I need to put a real
limit on it? What would that be?

I think somebody explored this problem recently but I can't remember any key
words from the discussion to search on.

Thanks.

--
Daryl Stultz
_____________________________________
6 Degrees Software and Consulting, Inc.
http://www.6degrees.com
mailto:[hidden email]
Daryl Stultz

Re: left join fetch with long text fields

Reply Threaded More More options
Print post
Permalink
On Thu, Nov 5, 2009 at 11:52 AM, Daryl Stultz <[hidden email]> wrote:

> slow. Is there some way to annotate this field so it is always retrieved in
> the main query? Do I need to put a real limit on it? What would that be?
>
> Setting
length = 1000000000
seems to do the trick (leaving database column as varchar(0)). A billion
characters ought to be enough for my purposes (if JPA does any checking),
but I still wonder if there's a better way.

--
Daryl Stultz
_____________________________________
6 Degrees Software and Consulting, Inc.
http://www.6degrees.com
mailto:[hidden email]