How to lazy fetch LOBs in Oracle Weblogic application server?
I'm running an application on a Weblogic App-Server (10.3.3) on an Oracle database (10g and later on 11g), and 开发者_如何转开发it appears that my application's memory isn't managed correctly, as after running it for a while it starts to repeatedly throw "gc overhead limit exceeded" exception.
I profiled my server with jvisualvm, and it appears that most of the heap consists of byte arrays, and these byte arrays are associated with one of my main entities as its 'data' member (BLOB in the DB).
I've tried to change that entity with something like this:
@Basic(fetch=LAZY)
@LOB
public byte[] getData() { return this.data; }
but then I always get null.
Is there anyway to lazy-fetch my LOBs?
Update
I'm using the default provider which comes with Weblogic application server. I didn't touch any JPA configuration on the server.
My code is very simple at the moment (sort of a sandbox), and it just finds my entity using em.find()
(according to the row id) and then I just call myEntity.getData()
which returns null.
It's me again, having problem logging in to the same user. Anyway, found a solution:
I switched the JPA Provider of my server to TopLink, but then the best I could get is a non-lazy fetching (but at least no null or exception).
Then I tried a different aproach. I created a new entity for the same table which holds my lob field, while my previous entity didn't hold the lob field, but the new entity. I connected them two with a one-to-one relationship and lazy fetching, and it worked!
It took me some time because only a specific mapping works, as you can see here:
@Entity
@Table(name="MY_TABLE")
public class A implements Serializable {
private Long id;
private ALob lob;
@Id
public Long getId() {return id;}
public void setId(Long id) {this.id = id;}
@OneToOne(fetch=LAZY)
@JoinColumn(name="ID", insertable=false, updatable=false)
public ALob getLob() {return lob;}
public void setLob(ALob lob) {this.lob = lob;}
}
@Entity
@Table(name="MY_TABLE")
public class ALob implements Serializable {
private Long id;
private byte[] data;
@Id
public Long getId() {return id;}
public void setId(Long id) {this.id = id;}
public byte[] getData() {return data;}
public void setData(byte[] data) {this.data = data;}
}
Oh and btw, it doesn't work with kodo, only TopLink.
精彩评论