I am Querying a table using Hibernate by i get the error
"Exception in thread
"Thread-4" java.lang.OutOfMemoryError: Java heap space at
java.util.Arrays.copyOf(Arrays.java:3222) at
java.util.Arrays.copyOf(Arrays.java:3222)".
Here is My sample code.
public List<MyBean> loadData() {
Session s=CFactory.getSession();
s.beginTransaction();
List<MyBean> mybean=null;
try {
Query sry=s.createQuery("from MyBean where flag='NP'");
mybean=sry.list();
s.getTransaction().commit();
} catch (Exception e) {
e.printStackTrace();
}
return mybean;
}
My question is how can i query in a table that has a huge data and convert it to a list without getting out of memory error in hibernate?
Exception in thread "Thread-4" java.lang.OutOfMemoryError: Java heap space
at java.util.Arrays.copyOf(Arrays.java:3222)
at java.util.Arrays.copyOf(Arrays.java:3222)
at java.io.ByteArrayOutputStream.grow(ByteArrayOutputStream.java:113)
at java.io.ByteArrayOutputStream.ensureCapacity(ByteArrayOutputStream.java:93)
at java.io.ByteArrayOutputStream.write(ByteArrayOutputStream.java:140)
at org.hibernate.type.descriptor.java.DataHelper.extractBytes(DataHelper.java:170)
at org.hibernate.type.descriptor.java.DataHelper.extractBytes(DataHelper.java:170)
at org.hibernate.type.descriptor.java.PrimitiveByteArrayTypeDescriptor.wrap(PrimitiveByteArrayTypeDescriptor.java:124)
at org.hibernate.type.descriptor.java.PrimitiveByteArrayTypeDescriptor.wrap(PrimitiveByteArrayTypeDesciptor.java:41)
at org.hibernate.type.descriptor.sql.BlobTypeDescriptor$5.doExtract(BlobTypeDescriptor.java:115)
at org.hibernate.type.descriptor.sql.BasicExtractor.extract(BasicExtractor.java:64)
at org.hibernate.type.AbstractStandardBasicType.nullSafeGet(AbstractStandardBasicType.java:254)
at org.hibernate.type.AbstractStandardBasicType.nullSafeGet(AbstractStandardBasicType.java:250)
at org.hibernate.type.AbstractStandardBasicType.nullSafeGet(AbstractStandardBasicType.java:230)
at org.hibernate.type.AbstractStandardBasicType.hydrate(AbstractStandardBasicType.java:331)