use of org.hibernate.testing.RequiresDialect in project hibernate-orm by hibernate.
the class JoinTableWithDefaultSchemaTest method testGetTableDataForJoinTableWithDefaultSchema.
@Test
@TestForIssue(jiraKey = "HHH-10978")
@RequiresDialect(SQLServerDialect.class)
public void testGetTableDataForJoinTableWithDefaultSchema() {
StandardServiceRegistry ssr = new StandardServiceRegistryBuilder().applySetting(AvailableSettings.DEFAULT_CATALOG, "hibernate_orm_test").applySetting(AvailableSettings.USE_NEW_ID_GENERATOR_MAPPINGS, "false").build();
try {
final MetadataImplementor metadata = (MetadataImplementor) new MetadataSources(ssr).addAnnotatedClass(Task.class).addAnnotatedClass(Project.class).buildMetadata();
metadata.validate();
// first create the schema...
new SchemaExport().create(EnumSet.of(TargetType.DATABASE), metadata);
try {
// validate the schema
new SchemaValidator().validate(metadata);
} finally {
// cleanup
new SchemaExport().drop(EnumSet.of(TargetType.DATABASE), metadata);
}
} finally {
StandardServiceRegistryBuilder.destroy(ssr);
}
}
use of org.hibernate.testing.RequiresDialect in project hibernate-orm by hibernate.
the class NativeSQLQueriesTest method testEscapeColonInSQL.
@Test
@RequiresDialect(MySQL5Dialect.class)
public void testEscapeColonInSQL() throws QueryException {
Session s = openSession();
Transaction t = s.beginTransaction();
SQLQuery query = s.createSQLQuery("SELECT @row \\:= 1");
List list = query.list();
assertTrue(list.get(0).toString().equals("1"));
t.commit();
s.close();
}
use of org.hibernate.testing.RequiresDialect in project hibernate-orm by hibernate.
the class CustomRunner method convertSkipToIgnore.
protected Ignore convertSkipToIgnore(FrameworkMethod frameworkMethod) {
// @Skip
Skip skip = Helper.locateAnnotation(Skip.class, frameworkMethod, getTestClass());
if (skip != null) {
if (isMatch(skip.condition())) {
return buildIgnore(skip);
}
}
// @SkipForDialects & @SkipForDialect
for (SkipForDialect skipForDialectAnn : Helper.collectAnnotations(SkipForDialect.class, SkipForDialects.class, frameworkMethod, getTestClass())) {
for (Class<? extends Dialect> dialectClass : skipForDialectAnn.value()) {
if (skipForDialectAnn.strictMatching()) {
if (dialectClass.equals(dialect.getClass())) {
return buildIgnore(skipForDialectAnn);
}
} else {
if (dialectClass.isInstance(dialect)) {
return buildIgnore(skipForDialectAnn);
}
}
}
}
// @RequiresDialects & @RequiresDialect
final List<RequiresDialect> requiresDialects = Helper.collectAnnotations(RequiresDialect.class, RequiresDialects.class, frameworkMethod, getTestClass());
if (!requiresDialects.isEmpty() && !isDialectMatchingRequired(requiresDialects)) {
return buildIgnore(requiresDialects);
}
// @RequiresDialectFeature
RequiresDialectFeature requiresDialectFeatureAnn = Helper.locateAnnotation(RequiresDialectFeature.class, frameworkMethod, getTestClass());
if (requiresDialectFeatureAnn != null) {
try {
for (Class<? extends DialectCheck> checkClass : requiresDialectFeatureAnn.value()) {
if (!checkClass.newInstance().isMatch(dialect)) {
return buildIgnore(requiresDialectFeatureAnn);
}
}
} catch (RuntimeException e) {
throw e;
} catch (Exception e) {
throw new RuntimeException("Unable to instantiate DialectCheck", e);
}
}
return null;
}
use of org.hibernate.testing.RequiresDialect in project hibernate-orm by hibernate.
the class CustomRunner method buildIgnore.
private Ignore buildIgnore(List<RequiresDialect> requiresDialects) {
String ignoreMessage = "";
for (RequiresDialect requiresDialect : requiresDialects) {
ignoreMessage += getIgnoreMessage("@RequiresDialect non-match", requiresDialect.comment(), requiresDialect.jiraKey());
ignoreMessage += System.lineSeparator();
}
return new IgnoreImpl(ignoreMessage);
}
use of org.hibernate.testing.RequiresDialect in project hibernate-orm by hibernate.
the class HQLTest method test_hql_group_by_example_4.
@Test
@RequiresDialect(H2Dialect.class)
@RequiresDialect(PostgreSQL81Dialect.class)
@RequiresDialect(MySQL5Dialect.class)
public void test_hql_group_by_example_4() {
doInJPA(this::entityManagerFactory, entityManager -> {
Call call11 = new Call();
call11.setDuration(10);
call11.setTimestamp(Timestamp.from(LocalDateTime.of(2000, 1, 1, 0, 0, 0).toInstant(ZoneOffset.UTC)));
Phone phone = entityManager.createQuery("select p from Phone p where p.calls is empty ", Phone.class).getResultList().get(0);
phone.addCall(call11);
entityManager.flush();
entityManager.clear();
List<Object[]> personTotalCallDurations = entityManager.createQuery("select p, sum( c.duration ) " + "from Call c " + "join c.phone p " + "group by p", Object[].class).getResultList();
assertEquals(2, personTotalCallDurations.size());
});
}
Aggregations