Search in sources :

Example 1 with DocumentForOneToOne

use of com.blazebit.persistence.testsuite.entity.DocumentForOneToOne in project blaze-persistence by Blazebit.

the class SingleValuedAssociationOneToOneJoinTableTest method leftJoinDereferenedForeignJoinTableWithTableGroupJoins.

@Test
@Category({ NoDatanucleus.class, NoEclipselink.class, NoOpenJPA.class, NoHibernate42.class, NoHibernate43.class, NoHibernate50.class })
public void leftJoinDereferenedForeignJoinTableWithTableGroupJoins() {
    Assume.assumeTrue(supportsTableGroupJoins());
    CriteriaBuilder criteriaBuilder = cbf.create(em, DocumentForOneToOneJoinTable.class, "d").leftJoinOn(DocumentForOneToOne.class, "e").on("d.documentInfoJoinTable.id").eqExpression("e.id").end();
    assertEquals("SELECT d FROM DocumentForOneToOneJoinTable d LEFT JOIN DocumentForOneToOne e ON (d.documentInfoJoinTable.id = e.id)", criteriaBuilder.getQueryString());
    criteriaBuilder.getResultList();
}
Also used : CriteriaBuilder(com.blazebit.persistence.CriteriaBuilder) DocumentForOneToOne(com.blazebit.persistence.testsuite.entity.DocumentForOneToOne) Category(org.junit.experimental.categories.Category) Test(org.junit.Test)

Example 2 with DocumentForOneToOne

use of com.blazebit.persistence.testsuite.entity.DocumentForOneToOne in project blaze-persistence by Blazebit.

the class SingleValuedAssociationOneToOneJoinTableTest method leftJoinDereferenedForeignJoinTable.

@Test
@Category({ NoDatanucleus.class, NoEclipselink.class, NoOpenJPA.class, NoHibernate51.class, NoHibernate52.class, NoHibernate53.class })
public void leftJoinDereferenedForeignJoinTable() {
    Assume.assumeFalse(supportsTableGroupJoins());
    Assume.assumeTrue(jpaProvider.supportsEntityJoin());
    CriteriaBuilder criteriaBuilder = cbf.create(em, DocumentForOneToOneJoinTable.class, "d").leftJoinOn(DocumentForOneToOne.class, "e").on("d.documentInfoJoinTable.id").eqExpression("e.id").end();
    assertEquals("SELECT d FROM DocumentForOneToOneJoinTable d LEFT JOIN DocumentForOneToOne e ON (EXISTS (SELECT 1 FROM d.documentInfoJoinTable _synth_subquery_0 WHERE _synth_subquery_0.id = e.id))", criteriaBuilder.getQueryString());
    criteriaBuilder.getResultList();
}
Also used : CriteriaBuilder(com.blazebit.persistence.CriteriaBuilder) DocumentForOneToOne(com.blazebit.persistence.testsuite.entity.DocumentForOneToOne) Category(org.junit.experimental.categories.Category) Test(org.junit.Test)

Example 3 with DocumentForOneToOne

use of com.blazebit.persistence.testsuite.entity.DocumentForOneToOne in project blaze-persistence by Blazebit.

the class PaginationOneToOneTest method setUpOnce.

@Override
public void setUpOnce() {
    cleanDatabase();
    transactional(new TxVoidWork() {

        @Override
        public void work(EntityManager em) {
            DocumentForOneToOne doc1 = new DocumentForOneToOne("doc1");
            DocumentForOneToOne doc2 = new DocumentForOneToOne("doc2");
            Person p1 = new Person("owner");
            doc1.setOwner(p1);
            doc2.setOwner(p1);
            DocumentInfo o1 = new DocumentInfo(1L, doc2, "Karl1");
            DocumentInfo o2 = new DocumentInfo(2L, doc1, "Karl2");
            em.persist(p1);
            em.persist(doc1);
            em.persist(doc2);
            em.persist(o1);
            em.persist(o2);
        }
    });
}
Also used : EntityManager(javax.persistence.EntityManager) TxVoidWork(com.blazebit.persistence.testsuite.tx.TxVoidWork) DocumentForOneToOne(com.blazebit.persistence.testsuite.entity.DocumentForOneToOne) Person(com.blazebit.persistence.testsuite.entity.Person) DocumentInfo(com.blazebit.persistence.testsuite.entity.DocumentInfo)

Aggregations

DocumentForOneToOne (com.blazebit.persistence.testsuite.entity.DocumentForOneToOne)3 CriteriaBuilder (com.blazebit.persistence.CriteriaBuilder)2 Test (org.junit.Test)2 Category (org.junit.experimental.categories.Category)2 DocumentInfo (com.blazebit.persistence.testsuite.entity.DocumentInfo)1 Person (com.blazebit.persistence.testsuite.entity.Person)1 TxVoidWork (com.blazebit.persistence.testsuite.tx.TxVoidWork)1 EntityManager (javax.persistence.EntityManager)1