-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: FetchType not working
PostPosted: Tue Apr 10, 2007 11:04 am 
Senior
Senior

Joined: Mon Jul 24, 2006 8:43 am
Posts: 160
Hi,
I set Fetchtype.LAZY for my OneToOne relationships on both sides of the relationship.

I turn on SQL tracing. I read one side of the relationship into memory using em.refresh() or em.find(), hibernate still executes multiples SQL statements to read the specific entity and any tables (i.e. other entities) that it may be associated to.

My objective is to only read the actual Entity into memory no relationships as this introduces a performance problem.

Any ideas?

the relavant code is:

Code:
@Entity
public class Address  {
   
    private Company company;
    // One to One Rel
    @OneToOne(mappedBy="address", fetch=FetchType.LAZY)
    public Company getCompany(){
        return company;
    }

    public void setCompany(Company company){
        this.company = company;
    }

}


@Entity
public void Company {
    private Address address;

    @OneToOne(fetch=FetchType.LAZY)
    @JoinColumns({
        @JoinColumn(name="I_ADDRESS_ADDRESS", referencedColumnName="I"),
        @JoinColumn(name="C_ADDRESS_ADDRESS", referencedColumnName="C")})
    public Address getAddress() {
        return address;
    }
   
    public void setAddress(Address address){
        this.address = address;
    }
}


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 31, 2007 12:39 pm 
Senior
Senior

Joined: Mon Jul 24, 2006 8:43 am
Posts: 160
Folks anybody any ideas on this?


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.