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