use of org.hibernate.testing.RequiresDialectFeature in project hibernate-orm by hibernate.
the class CompositeUserTypeTest method testLessThanOperator.
/**
* 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 testLessThanOperator() {
final Session s = openSession();
try {
final Query q = s.createQuery("from Transaction where value < :amount");
q.setParameter("amount", new MonetoryAmount(BigDecimal.ZERO, Currency.getInstance("EUR")));
q.list();
} catch (IllegalArgumentException e) {
assertTyping(QuerySyntaxException.class, e.getCause());
//expected
} finally {
s.close();
}
}
use of org.hibernate.testing.RequiresDialectFeature in project hibernate-orm by hibernate.
the class CompositeUserTypeTest method testLessOrEqualOperator.
/**
* 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 testLessOrEqualOperator() {
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();
}
}
use of org.hibernate.testing.RequiresDialectFeature in project hibernate-orm by hibernate.
the class ExtraLazyTest method testSQLQuery.
@Test
@RequiresDialectFeature(DialectChecks.DoubleQuoteQuoting.class)
public void testSQLQuery() {
Session s = openSession();
Transaction t = s.beginTransaction();
User gavin = new User("gavin", "secret");
User turin = new User("turin", "tiger");
gavin.getSession().put("foo", new SessionAttribute("foo", "foo bar baz"));
gavin.getSession().put("bar", new SessionAttribute("bar", "foo bar baz 2"));
s.persist(gavin);
s.persist(turin);
s.flush();
s.clear();
List results = s.getNamedQuery("userSessionData").setParameter("uname", "%in").list();
assertEquals(results.size(), 2);
gavin = (User) ((Object[]) results.get(0))[0];
assertEquals(gavin.getName(), "gavin");
assertEquals(gavin.getSession().size(), 2);
s.createQuery("delete SessionAttribute").executeUpdate();
s.createQuery("delete User").executeUpdate();
t.commit();
s.close();
}
use of org.hibernate.testing.RequiresDialectFeature in project hibernate-orm by hibernate.
the class ASTParserLoadingTest method testSimpleSelectWithLimitAndOffset.
@Test
@RequiresDialectFeature(value = DialectChecks.SupportLimitAndOffsetCheck.class, comment = "dialect does not support offset and limit combo")
public void testSimpleSelectWithLimitAndOffset() throws Exception {
// just checking correctness of param binding code...
Session session = openSession();
Transaction t = session.beginTransaction();
session.createQuery("from Animal").setFirstResult(2).setMaxResults(1).list();
t.commit();
session.close();
}
use of org.hibernate.testing.RequiresDialectFeature in project hibernate-orm by hibernate.
the class BulkManipulationTest method testInsertWithGeneratedTimestampVersion.
@Test
@RequiresDialectFeature(value = DialectChecks.SupportsParametersInInsertSelectCheck.class, comment = "dialect does not support parameter in INSERT ... SELECT")
public void testInsertWithGeneratedTimestampVersion() {
// Make sure the env supports bulk inserts with generated ids...
if (!supportsBulkInsertIdGeneration(TimestampVersioned.class)) {
SkipLog.reportSkip("bulk id generation not supported", "test bulk inserts with generated id and generated timestamp");
return;
}
Session s = openSession();
Transaction t = s.beginTransaction();
TimestampVersioned entity = new TimestampVersioned("int-vers");
s.save(entity);
s.createQuery("select id, name, version from TimestampVersioned").list();
t.commit();
s.close();
Long initialId = entity.getId();
//Date initialVersion = entity.getVersion();
s = openSession();
t = s.beginTransaction();
int count = s.createQuery("insert into TimestampVersioned ( name ) select name from TimestampVersioned").executeUpdate();
t.commit();
s.close();
assertEquals("unexpected insertion count", 1, count);
s = openSession();
t = s.beginTransaction();
TimestampVersioned created = (TimestampVersioned) s.createQuery("from TimestampVersioned where id <> :initialId").setLong("initialId", initialId.longValue()).uniqueResult();
t.commit();
s.close();
assertNotNull(created.getVersion());
//assertEquals( "version was not seeded", initialVersion, created.getVersion() );
s = openSession();
t = s.beginTransaction();
s.createQuery("delete TimestampVersioned").executeUpdate();
t.commit();
s.close();
}
Aggregations