I have a class that is persisting a Entity that holds remarks and a time.
Then when I query for the latest remark I get a internal error when the remark is larger than 1966 chars.
Here is a test class and entity that reproduces the problem on my system.
@Entity @Table(name = "TestEntity", schema = "mySchema") public class TestEntity { @Id private int id; @Basic @Lob private String remark; @Basic @Temporal(value = TemporalType.TIMESTAMP) private Date changeDate; public int getId() { return id; } public void setId(int id) { this.id = id; } public String getRemark() { return remark; } public void setRemark(String remark) { this.remark = remark; } public Date getChangeDate() { return changeDate; } public void setChangeDate(Date changeDate) { this.changeDate = changeDate; } } public class Test { private final EntityManagerFactory emf; private final EntityManager em; public Test() { emf = Persistence.createEntityManagerFactory("$objectdb/db/test.odb"); em = emf.createEntityManager(); } public static void main(String[] args) { Test t = new Test(); t.doit(); } public void doit() { for(int i=1;i<32766;i++) { em.getTransaction().begin(); TestEntity v = em.find(TestEntity.class, i); if(v==null) { v = new TestEntity(); v.setId(i); em.persist(v); } StringBuffer sb = new StringBuffer(); for(int j=0;j<=i;j++) { sb.append("X"); } String sbs = sb.toString(); v.setRemark(sbs); v.setChangeDate(new Date(System.currentTimeMillis())); em.getTransaction().commit(); em.getTransaction().begin(); CriteriaBuilder cb = em.getCriteriaBuilder(); CriteriaQuery<Object> q = cb.createQuery(); Root r = q.from(TestEntity.class); Path c = r.get("changeDate"); Expression me = cb.max(c); CriteriaQuery<Object> s = q.select(me); Predicate predicate = cb.isNotNull(c); q.where(predicate); TypedQuery<Object> tq = em.createQuery(s); Date mDate = (Date)tq.getSingleResult(); em.getTransaction().commit(); System.out.println("MaxDate = "+mDate+" i="+i); } } }
The Error output is
MaxDate = Sun Apr 24 00:49:47 EDT 2011 i=1962 MaxDate = Sun Apr 24 00:49:47 EDT 2011 i=1963 MaxDate = Sun Apr 24 00:49:47 EDT 2011 i=1964 MaxDate = Sun Apr 24 00:49:47 EDT 2011 i=1965 MaxDate = Sun Apr 24 00:49:47 EDT 2011 i=1966 MaxDate = Sun Apr 24 00:49:47 EDT 2011 i=1967 Exception in thread "main" [ObjectDB 2.2.2] Unexpected exception (Error 990) Generated by Java HotSpot(TM) 64-Bit Server VM 1.6.0_24 (on Linux 2.6.32-71.24.1.el6.x86_64). Please report this error on http://www.objectdb.com/database/issue/new com.objectdb.o.InternalException: null com.objectdb.o.InternalException at com.objectdb.o.BYR.s(BYR.java:113) at com.objectdb.o.BYR.J(BYR.java:353) at com.objectdb.o.VUT.k(VUT.java:545) at com.objectdb.o.REG.D(REG.java:339) at com.objectdb.o.EXR$d.c(EXR.java:131) at com.objectdb.o.VAR.an(VAR.java:769) at com.objectdb.o.VAR.am(VAR.java:712) at com.objectdb.o.BCN.y(BCN.java:282) at com.objectdb.o.BCN.i(BCN.java:251) at com.objectdb.o.PBI.A(PBI.java:141) at com.objectdb.o.PBI.p(PBI.java:111) at com.objectdb.o.OBI.U5(OBI.java:235) at com.objectdb.o.BQI.Ve(BQI.java:134) at com.objectdb.o.GQI.Us(GQI.java:130) at com.objectdb.o.PRG.aa(PRG.java:584) at com.objectdb.o.QRM.UR(QRM.java:256) at com.objectdb.o.MST.UR(MST.java:878) at com.objectdb.o.WRA.UR(WRA.java:286) at com.objectdb.o.WSM.UR(WSM.java:113) at com.objectdb.o.WRA.UR(WRA.java:286) at com.objectdb.o.WSN.UR(WSN.java:422) at com.objectdb.o.QRR.g(QRR.java:216) at com.objectdb.o.QRR.b(QRR.java:139) at com.objectdb.jpa.JpaQuery.getSingleResult(JpaQuery.java:607) at com.ibm.check.cmvc2git.Test.doit(Test.java:69) at com.ibm.check.cmvc2git.Test.main(Test.java:30)
This brigns up the question, what is the size limit for a persisted @Lob String in objectDB?