Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » Problem with indirect (lazy) mappings(trying to set to Lazy fetching type but getting validation errors)
Problem with indirect (lazy) mappings [message #510706] Thu, 28 January 2010 11:33 Go to next message
Carlos Conti is currently offline Carlos ContiFriend
Messages: 26
Registered: January 2010
Junior Member
Hi all, thanks in advance for your help.

I have checked the documentation from EclipseLink to configure the persistent unit in a static way so that I can load associated objects in a lazy way. However I am not being able to get through. This is the content of my persistence.xml file

<?xml version="1.0" encoding="UTF-8"?>
<persistence version="1.0" xmlns="" xmlns:xsi="" xsi:schemaLocation="">
 <persistence-unit name="JPAIncidencias" transaction-type="JTA">
      <property name="eclipselink.session.customizer" value="utils.JPAEclipseLinkSessionCustomizer"/>        
      <property name="eclipselink.logging.level" value="FINEST"/> 
      <property name="eclipselink.weaving" value="static"/> 
      <property name="eclipselink.weaving.lazy" value="true"/>
      <property name="eclipselink.weaving.changetracking" value="true"/> 
      <property name="eclipselink.weaving.fetchgroups" value="true"/> 
      <property name="eclipselink.weaving.internal" value="true"/> 
      <property name="eclipselink.weaving.eager" value="false"/>  

I am setting the entities in the following way:

Class A -> B (OneToMany)

public class A{
     private ArrayList toB;
     //getter and setter
public class B{
     private A toA;
     //getter and setter

and in the orm.xml got the following

<entity class="package.A">
		<table name="aa">
                                           <one-to-many fetch="LAZY" name="toB" target-entity="package.B" mapped-by="toA">
<entity class="package.B">
		<table name="bb">
                                           <many-to-one name="toA">
			<join-column name="A_ID" referenced-column-name="ID"/>

from B to A is eager by default, and from A to B lazy by default.

If possible would like to keep using ArrayList, but any [EclipseLink]List class arranged for maintaining indirection that works in not a very problematic way (regarding maintainance) will do fine. I used static weaving 'cause from the documentation I knew that it should only be defined once in the persistence.xml file.

Any hints on what I am doing wrong?

Thank you very much in advance.
Re: Problem with indirect (lazy) mappings [message #510734 is a reply to message #510706] Thu, 28 January 2010 13:56 Go to previous message
Chris Delahunt is currently offline Chris DelahuntFriend
Messages: 1294
Registered: July 2009
Senior Member

The JPA specification requires that collection attributes be either a Collection, Set, List or Map type, allowing providers to put in their own implementions transparently for lazy relations. EclipseLink does not strictly enforce this, which is why your collection type being ArrayList will work as long as it is not lazy. In order to be portable, you will need to change the toB type to be List, allowing EclipseLink to put its own IndirectList type when populating managed entities and still allowing your model to use ArrayList.

If you do not want to use the java.util.List and prefer a concrete type be specified, you would need to mark it as Transient and then use a customizer to create the mapping with native EclipseLink api.

Best Regards,
Previous Topic:Type conversion Oracle NVARCHAR2
Next Topic:User defined (custom) collections
Goto Forum:

Current Time: Sun Apr 22 07:02:06 GMT 2018

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

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