use of org.hibernate.test.sql.hand.ImageHolder in project hibernate-orm by hibernate.
the class NativeSQLQueriesTest method testImageTypeInSQLQuery.
@SkipForDialect(value = AbstractHANADialect.class, comment = "On HANA, this returns a blob for the image column which doesn't get mapped to a byte[]")
@Test
public void testImageTypeInSQLQuery() {
Session s = openSession();
Transaction t = s.beginTransaction();
byte[] photo = buildLongByteArray(15000, true);
ImageHolder holder = new ImageHolder(photo);
s.persist(holder);
t.commit();
s.close();
s = openSession();
t = s.beginTransaction();
byte[] photoRead = (byte[]) s.createSQLQuery(getPhotosSQL()).uniqueResult();
assertTrue(Arrays.equals(photo, photoRead));
s.delete(holder);
t.commit();
s.close();
}
use of org.hibernate.test.sql.hand.ImageHolder in project hibernate-orm by hibernate.
the class CustomSQLTestSupport method testImageProperty.
@Test
public void testImageProperty() {
Session s = openSession();
Transaction t = s.beginTransaction();
byte[] photo = buildLongByteArray(15000, true);
ImageHolder holder = new ImageHolder(photo);
s.save(holder);
t.commit();
s.close();
s = openSession();
t = s.beginTransaction();
holder = (ImageHolder) s.get(ImageHolder.class, holder.getId());
assertTrue(Arrays.equals(photo, holder.getPhoto()));
photo = buildLongByteArray(15000, false);
holder.setPhoto(photo);
s.save(holder);
t.commit();
s.close();
s = openSession();
t = s.beginTransaction();
holder = (ImageHolder) s.get(ImageHolder.class, holder.getId());
assertTrue(Arrays.equals(photo, holder.getPhoto()));
s.delete(holder);
t.commit();
s.close();
}
Aggregations