use of org.hibernate.testing.RequiresDialectFeature in project hibernate-orm by hibernate.
the class BasicHibernateAnnotationsTest method testType.
@Test
@RequiresDialectFeature(DialectChecks.SupportsExpectedLobUsagePattern.class)
public void testType() throws Exception {
Forest f = new Forest();
f.setName("Broceliande");
String description = "C'est une enorme foret enchantee ou vivais Merlin et toute la clique";
f.setLongDescription(description);
Session s;
Transaction tx;
s = openSession();
tx = s.beginTransaction();
s.persist(f);
tx.commit();
s.close();
s = openSession();
tx = s.beginTransaction();
f = (Forest) s.get(Forest.class, f.getId());
assertNotNull(f);
assertEquals(description, f.getLongDescription());
s.delete(f);
tx.commit();
s.close();
}
use of org.hibernate.testing.RequiresDialectFeature in project hibernate-orm by hibernate.
the class BasicHibernateAnnotationsTest method testVersioning.
@Test
@RequiresDialectFeature(DialectChecks.SupportsExpectedLobUsagePattern.class)
@SkipForDialect(value = TeradataDialect.class, comment = "One transaction hangs the other")
public void testVersioning() throws Exception {
Forest forest = new Forest();
forest.setName("Fontainebleau");
forest.setLength(33);
Session s;
Transaction tx;
s = openSession();
tx = s.beginTransaction();
s.persist(forest);
tx.commit();
s.close();
Session parallelSession = openSession();
Transaction parallelTx = parallelSession.beginTransaction();
s = openSession();
tx = s.beginTransaction();
forest = (Forest) parallelSession.get(Forest.class, forest.getId());
Forest reloadedForest = (Forest) s.get(Forest.class, forest.getId());
reloadedForest.setLength(11);
assertNotSame(forest, reloadedForest);
tx.commit();
s.close();
forest.setLength(22);
try {
parallelTx.commit();
fail("All optimistic locking should have make it fail");
} catch (OptimisticLockException e) {
if (parallelTx != null)
parallelTx.rollback();
} finally {
parallelSession.close();
}
s = openSession();
tx = s.beginTransaction();
s.delete(s.get(Forest.class, forest.getId()));
tx.commit();
s.close();
}
use of org.hibernate.testing.RequiresDialectFeature in project hibernate-orm by hibernate.
the class LobLocatorTest method testStreamResetBeforeParameterBinding.
/**
* Specific JDBC drivers (e.g. SQL Server) may not automatically rewind bound input stream
* during statement execution. Such behavior results in error message similar to:
* {@literal The stream value is not the specified length. The specified length was 4, the actual length is 0.}
*/
@Test
@TestForIssue(jiraKey = "HHH-8193")
@RequiresDialectFeature(DialectChecks.UsesInputStreamToInsertBlob.class)
public void testStreamResetBeforeParameterBinding() throws SQLException {
final Session session = openSession();
session.getTransaction().begin();
LobHolder entity = new LobHolder(session.getLobHelper().createBlob("blob".getBytes()), session.getLobHelper().createClob("clob"), 0);
session.persist(entity);
session.getTransaction().commit();
final Integer updatesLimit = 3;
for (int i = 1; i <= updatesLimit; ++i) {
session.getTransaction().begin();
entity = (LobHolder) session.get(LobHolder.class, entity.getId());
entity.setCounter(i);
entity = (LobHolder) session.merge(entity);
session.getTransaction().commit();
}
session.getTransaction().begin();
entity = (LobHolder) session.get(LobHolder.class, entity.getId());
entity.setBlobLocator(session.getLobHelper().createBlob("updated blob".getBytes()));
entity.setClobLocator(session.getLobHelper().createClob("updated clob"));
entity = (LobHolder) session.merge(entity);
session.getTransaction().commit();
session.clear();
session.getTransaction().begin();
checkState("updated blob".getBytes(), "updated clob", updatesLimit, (LobHolder) session.get(LobHolder.class, entity.getId()));
session.getTransaction().commit();
session.close();
}
use of org.hibernate.testing.RequiresDialectFeature in project hibernate-orm by hibernate.
the class ManyToOneReferencedColumnNameTest method testReoverableExceptionInFkOrdering.
@Test
@RequiresDialectFeature(DialectChecks.SupportsIdentityColumns.class)
public void testReoverableExceptionInFkOrdering() throws Exception {
//SF should not blow up
Vendor v = new Vendor();
Item i = new Item();
ZItemCost ic = new ZItemCost();
ic.setCost(new BigDecimal(2));
ic.setItem(i);
ic.setVendor(v);
WarehouseItem wi = new WarehouseItem();
wi.setDefaultCost(ic);
wi.setItem(i);
wi.setVendor(v);
wi.setQtyInStock(new BigDecimal(2));
Session s = openSession();
s.getTransaction().begin();
s.save(i);
s.save(v);
s.save(ic);
s.save(wi);
s.flush();
s.getTransaction().rollback();
s.close();
}
use of org.hibernate.testing.RequiresDialectFeature in project hibernate-orm by hibernate.
the class CompositeUserTypeTest method testGreaterOrEqualOperator.
/**
* Tests the {@code >=} operator on composite types. As long as we don't support it, we need to throw an exception
* rather than create a random query.
*/
@Test
@TestForIssue(jiraKey = "HHH-5946")
@RequiresDialectFeature(value = DialectChecks.DoesNotSupportRowValueConstructorSyntax.class)
public void testGreaterOrEqualOperator() {
final Session s = openSession();
try {
final Query q = s.createQuery("from Transaction where value >= :amount");
q.setParameter("amount", new MonetoryAmount(BigDecimal.ZERO, Currency.getInstance("USD")));
q.list();
} catch (IllegalArgumentException e) {
assertTyping(QuerySyntaxException.class, e.getCause());
//expected
} finally {
s.close();
}
}
Aggregations