Search in sources :

Example 11 with TestForIssue

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

the class InformixDialectTestCase method testCurrentTimestampFunction.

@Test
@TestForIssue(jiraKey = "HHH-10800")
public void testCurrentTimestampFunction() {
    Map<String, SQLFunction> functions = dialect.getFunctions();
    SQLFunction sqlFunction = functions.get("current_timestamp");
    Type firstArgumentType = null;
    Mapping mapping = null;
    assertEquals(StandardBasicTypes.TIMESTAMP, sqlFunction.getReturnType(firstArgumentType, mapping));
    firstArgumentType = null;
    List arguments = Collections.emptyList();
    SessionFactoryImplementor factory = null;
    assertEquals("current", sqlFunction.render(firstArgumentType, arguments, factory));
}
Also used : Type(org.hibernate.type.Type) SessionFactoryImplementor(org.hibernate.engine.spi.SessionFactoryImplementor) Mapping(org.hibernate.engine.spi.Mapping) List(java.util.List) SQLFunction(org.hibernate.dialect.function.SQLFunction) Test(org.junit.Test) TestForIssue(org.hibernate.testing.TestForIssue)

Example 12 with TestForIssue

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

the class InformixDialectTestCase method testCurrentDateFunction.

@Test
@TestForIssue(jiraKey = "HHH-10800")
public void testCurrentDateFunction() {
    Map<String, SQLFunction> functions = dialect.getFunctions();
    SQLFunction sqlFunction = functions.get("current_date");
    Type firstArgumentType = null;
    Mapping mapping = null;
    assertEquals(StandardBasicTypes.DATE, sqlFunction.getReturnType(firstArgumentType, mapping));
    firstArgumentType = null;
    List arguments = Collections.emptyList();
    SessionFactoryImplementor factory = null;
    assertEquals("today", sqlFunction.render(firstArgumentType, arguments, factory));
}
Also used : Type(org.hibernate.type.Type) SessionFactoryImplementor(org.hibernate.engine.spi.SessionFactoryImplementor) Mapping(org.hibernate.engine.spi.Mapping) List(java.util.List) SQLFunction(org.hibernate.dialect.function.SQLFunction) Test(org.junit.Test) TestForIssue(org.hibernate.testing.TestForIssue)

Example 13 with TestForIssue

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

the class SQLServer2005DialectTestCase method testAppendLockHintUpgradeNoTimeout.

@Test
@TestForIssue(jiraKey = "HHH-9635")
public void testAppendLockHintUpgradeNoTimeout() {
    final String expectedLockHint = "tab1 with (updlock, rowlock, nowait)";
    LockOptions lockOptions = new LockOptions(LockMode.UPGRADE);
    lockOptions.setTimeOut(LockOptions.NO_WAIT);
    String lockHint = dialect.appendLockHint(lockOptions, "tab1");
    assertEquals(expectedLockHint, lockHint);
}
Also used : LockOptions(org.hibernate.LockOptions) Test(org.junit.Test) TestForIssue(org.hibernate.testing.TestForIssue)

Example 14 with TestForIssue

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

the class QueryBuilderTest method testMissingDialectFunction.

@Test
@TestForIssue(jiraKey = "HHH-10737")
@FailureExpected(jiraKey = "HHH-10737")
public void testMissingDialectFunction() {
    doInJPA(this::entityManagerFactory, em -> {
        Human human = new Human();
        human.setId(200L);
        human.setName("2");
        human.setBorn(new Date());
        em.persist(human);
        em.getTransaction().commit();
        CriteriaBuilder cb = em.getCriteriaBuilder();
        CriteriaQuery<HumanDTO> criteria = cb.createQuery(HumanDTO.class);
        Root<Human> root = criteria.from(Human.class);
        criteria.select(cb.construct(HumanDTO.class, root.get(Human_.id), root.get(Human_.name), cb.function("convert", String.class, root.get(Human_.born), cb.literal(110))));
        em.createQuery(criteria).getResultList();
    });
}
Also used : CriteriaBuilder(javax.persistence.criteria.CriteriaBuilder) Date(java.util.Date) Test(org.junit.Test) FailureExpected(org.hibernate.testing.FailureExpected) TestForIssue(org.hibernate.testing.TestForIssue)

Example 15 with TestForIssue

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

the class QueryBuilderTest method testMultiselectWithPredicates.

@Test
@TestForIssue(jiraKey = "HHH-8699")
// For now, restrict to H2.  Selecting w/ predicate functions cause issues for too many dialects.
@RequiresDialect(value = H2Dialect.class, jiraKey = "HHH-9092")
public void testMultiselectWithPredicates() {
    EntityManager em = getOrCreateEntityManager();
    em.getTransaction().begin();
    CriteriaBuilderImpl cb = (CriteriaBuilderImpl) em.getCriteriaBuilder();
    CriteriaQuery<Customer> cq = cb.createQuery(Customer.class);
    Root<Customer> r = cq.from(Customer.class);
    cq.multiselect(r.get(Customer_.id), r.get(Customer_.name), cb.concat("Hello ", r.get(Customer_.name)), cb.isNotNull(r.get(Customer_.age)));
    TypedQuery<Customer> tq = em.createQuery(cq);
    tq.getResultList();
    em.getTransaction().commit();
    em.close();
}
Also used : EntityManager(javax.persistence.EntityManager) CriteriaBuilderImpl(org.hibernate.query.criteria.internal.CriteriaBuilderImpl) Customer(org.hibernate.jpa.test.metamodel.Customer) Test(org.junit.Test) TestForIssue(org.hibernate.testing.TestForIssue) RequiresDialect(org.hibernate.testing.RequiresDialect)

Aggregations

TestForIssue (org.hibernate.testing.TestForIssue)649 Test (org.junit.Test)647 Session (org.hibernate.Session)357 EntityManager (javax.persistence.EntityManager)97 List (java.util.List)91 Transaction (org.hibernate.Transaction)88 MetadataSources (org.hibernate.boot.MetadataSources)47 ArrayList (java.util.ArrayList)38 CriteriaBuilder (javax.persistence.criteria.CriteriaBuilder)38 Query (org.hibernate.Query)28 MetadataImplementor (org.hibernate.boot.spi.MetadataImplementor)25 Metadata (org.hibernate.boot.Metadata)24 StandardServiceRegistryBuilder (org.hibernate.boot.registry.StandardServiceRegistryBuilder)24 StandardServiceRegistry (org.hibernate.boot.registry.StandardServiceRegistry)23 Map (java.util.Map)22 CollectionEntry (org.hibernate.engine.spi.CollectionEntry)19 HashMap (java.util.HashMap)18 SessionImplementor (org.hibernate.engine.spi.SessionImplementor)18 PersistentClass (org.hibernate.mapping.PersistentClass)18 HibernateException (org.hibernate.HibernateException)16