public void testBlobZeroLengthByteArray() throws Exception {
// test with 0 length bytes
byte[] bytes = new byte[0];
EntityManager em = emf.createEntityManager();
Blobs lobs = new Blobs();
em.getTransaction().begin();
lobs.setLobNotNullable(bytes);
lobs.setLobNullable(bytes);
em.persist(lobs);
try {
em.getTransaction().commit();
} catch (Exception e) {
if (getDBDictionary() instanceof SybaseDictionary) {
assertTrue(e instanceof RollbackException);
return;
} else {
throw e;
}
}
em.close();
em = emf.createEntityManager();
em.getTransaction().begin();
Query query = em.createQuery("select e from Blobs e");
lobs = (Blobs)query.getSingleResult();
assertTrue(lobs.getLobNullable() == null || lobs.getLobNullable().length == 0);
assertTrue(lobs.getLobNotNullable() == null || lobs.getLobNotNullable().length == 0);
for (int i = 0; i < bytes.length; i++) {
assertEquals(bytes[i], lobs.getLobNullable()[i]);
}
em.remove(lobs);
em.getTransaction().commit();
em.close();
}