[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: [eclipselink-users] Mapping Question
|
Hello,
Collection mappings (OneToMany and ManyToMany) are lazy loaded by
default, so adding the FetchType.LAZY to them won't change anything
unless they were explicitly eager before. The fact that it is
terminating without an error is troubling, as Java should throw or log
an exception somewhere. I doubt though that it is connections - any
number of reads for a single tree will use the same connection, so it
could be an OutOfMemory or other JVM error.
Other than increasing the memory and the heap, you can make some of the
backward relationships also lazy - specifically the ManyToOne back
pointers. This will prevent the entire tree from being inadvertently
brought into memory when not needed. You can also look at where a
relationship is not strictly needed and unmap them - bringing them in
using a query instead when they are needed. For instance, in a
ManyToMany, it may not be necessary to have both sides mapped if the
application will only ever us it from one side.
Best Regards,
Chris
Roger wrote:
Hi
I have a series of entities representing a hierarchy. Entity1 has many Entity2
which in turn has many Entity3 which in turn ... etc, etc.
Entity1 maps Entity2 with a @OneToMany and Entity2 maps to Entity1 with
@ManyToOne and Fetch=FetchType.Lazy. This is repeated down the heirarchy.
So far, this has been working well since I'm usually starting at the top of
the hierarchy until this afternoon when I was lumbered with one of those
urgent, need it yesterday type of jobs. What I needed to do was to read
through the entities that live at the bottom level of the hierarchy. For each
entity, EclipseLink walked up the hierarchy (running with debug level
logging) and terminated midway through the query with
no obvious error messages, so whether it ran out of DB Connections or memory I
don't know. I tried adding fetch = FetchType.LAZY to the @OneToMany mappings
with no effect.
Is there anything I can do to stop EclipseLInk doing this and only walking
back up the hierarchy when I try to access the level above. In this particular
instance all the data I need is in the bottom level entity,
Regards
_______________________________________________
eclipselink-users mailing list
eclipselink-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/eclipselink-users