atom feed6 messages in net.java.dev.glassfish.usersRe: Samples for Lazy loading
FromSent OnAttachments
glas...@javadesktop.orgFeb 3, 2008 9:56 am 
SahooFeb 3, 2008 11:50 pm 
glas...@javadesktop.orgFeb 4, 2008 5:48 am 
glas...@javadesktop.orgFeb 5, 2008 6:39 am 
glas...@javadesktop.orgFeb 5, 2008 11:23 am 
glas...@javadesktop.orgFeb 12, 2010 6:56 am 
Subject:Re: Samples for Lazy loading
From:glas...@javadesktop.org (glas@javadesktop.org)
Date:Feb 4, 2008 5:48:19 am
List:net.java.dev.glassfish.users

Thank you for answer but this tutorial does not help me.

I have some experiences with Jboss and Hibernate and now I am trying Glassfish
and Toplink, everything is working fine with one important exception - lazy
fetching.

Here is the minimal example:

In persistence.xml is added: <property name="toplink.weaving" value = "static"/>

Company o----> Country

@Entity public class Company implements Serializable { ... private Country country; ... @ManyToOne(fetch=FetchType.LAZY) @JoinColumn(name="country_id", nullable=false) public Country getCountry() { return country; } public void setCountry(Country country) { this.country = country; } }

Country does not have any special annotation, it is simple entity bean.

Facade Session Beans are generated by Netbeans and does not contains nothing
special - only was added findByCode() to CountryFacade.

My application client contains: @EJB private static CompanyFacadeRemote companyFacade; @EJB private static CountryFacadeRemote countryFacade; ... Country country = countryFacade.findByCode("CZ"); // loaded successfuly Company f = new Company(); f.setCountry( country ); f.setName( "MyCompany" ); companyFacade.create(f); (for edit() is the same result)

oracle.toplink.essentials.exceptions.DescriptorException Exception Description: A NullPointerException was thrown while extracting a
value through the method [_toplink_getcountry_vh] in the object
[cz.qds.ea1.ebs.Company]. Internal Exception: java.lang.NullPointerException Mapping: oracle.toplink.essentials.mappings.OneToOneMapping[country] Descriptor: RelationalDescriptor(cz.qds.ea1.ebs.Company -->
[DatabaseTable(COMPANY)])

When I remove LAZY attribute in Company all is working without error so problem
is with LAZY fetching.

Thank you very much. Leos [Message sent by forum member 'leosurban' (leosurban)]

http://forums.java.net/jive/thread.jspa?messageID=257247