Search in sources :

Example 36 with RequiresDialect

use of org.hibernate.testing.RequiresDialect in project hibernate-orm by hibernate.

the class SQLTest method test_sql_hibernate_entity_associations_named_query_example.

@Test
@RequiresDialect(H2Dialect.class)
@RequiresDialect(Oracle8iDialect.class)
@RequiresDialect(PostgreSQL82Dialect.class)
public void test_sql_hibernate_entity_associations_named_query_example() {
    doInJPA(this::entityManagerFactory, entityManager -> {
        Session session = entityManager.unwrap(Session.class);
        List<Object[]> tuples = session.getNamedQuery("find_person_with_phones_by_name").setParameter("name", "J%").list();
        for (Object[] tuple : tuples) {
            Person person = (Person) tuple[0];
            Phone phone = (Phone) tuple[1];
        }
        assertEquals(1, tuples.size());
    });
}
Also used : Phone(org.hibernate.userguide.model.Phone) Person(org.hibernate.userguide.model.Person) Session(org.hibernate.Session) Test(org.junit.Test) RequiresDialect(org.hibernate.testing.RequiresDialect)

Aggregations

RequiresDialect (org.hibernate.testing.RequiresDialect)36 Test (org.junit.Test)34 Session (org.hibernate.Session)18 TestForIssue (org.hibernate.testing.TestForIssue)13 EntityManager (javax.persistence.EntityManager)9 RequiresDialectFeature (org.hibernate.testing.RequiresDialectFeature)7 Callable (java.util.concurrent.Callable)6 CountDownLatch (java.util.concurrent.CountDownLatch)6 Transaction (org.hibernate.Transaction)6 HashMap (java.util.HashMap)5 Phone (org.hibernate.userguide.model.Phone)5 LockTimeoutException (javax.persistence.LockTimeoutException)4 List (java.util.List)3 LockOptions (org.hibernate.LockOptions)3 FailureExpected (org.hibernate.testing.FailureExpected)3 Call (org.hibernate.userguide.model.Call)3 Query (javax.persistence.Query)2 QueryTimeoutException (javax.persistence.QueryTimeoutException)2 MetadataSources (org.hibernate.boot.MetadataSources)2 StandardServiceRegistry (org.hibernate.boot.registry.StandardServiceRegistry)2