Package org.qi4j.api.unitofwork

Examples of org.qi4j.api.unitofwork.UnitOfWork.newQuery()


        newItemType( uow, "Necklace" );
        uow.complete();

        uow = unitOfWorkFactory.newUnitOfWork();
        QueryBuilder<ItemType> qb = queryBuilderFactory.newQueryBuilder( ItemType.class );
        Iterable<ItemType> initialList = copyOf( uow.newQuery( qb ));

        assertTrue( "Band is not in the initial list", hasItemTypeNamed( "Band", initialList ) );
        assertTrue( "Bracelet is not in the initial list", hasItemTypeNamed( "Bracelet", initialList ) );
        assertTrue( "Necklace is not in the initial list", hasItemTypeNamed( "Necklace", initialList ) );
View Full Code Here


        newItemType( uow, "Watch" );
        uow.complete();

        uow = unitOfWorkFactory.newUnitOfWork();
        qb = queryBuilderFactory.newQueryBuilder( ItemType.class );
        Iterable<ItemType> listAfterFirstQueryAndAdd = copyOf( uow.newQuery( qb ) );

        assertTrue( "Band is not in the list after the first query and add", hasItemTypeNamed( "Band", listAfterFirstQueryAndAdd ) );
        assertTrue( "Bracelet is not in the list after the first query and add", hasItemTypeNamed( "Bracelet", listAfterFirstQueryAndAdd ) );
        assertTrue( "Necklace is not in the list after the first query and add", hasItemTypeNamed( "Necklace", listAfterFirstQueryAndAdd ) );
        assertTrue( "Watch is not in the list after the first query and add", hasItemTypeNamed( "Watch", listAfterFirstQueryAndAdd ) );
View Full Code Here

        newItemType( uow, "Ear ring" );
        uow.complete();

        uow = unitOfWorkFactory.newUnitOfWork();
        Iterable<ItemType> finalList = copyOf( uow.newQuery( qb ) );
        assertTrue( "Band is not in the final list", hasItemTypeNamed( "Band", finalList ) );
        assertTrue( "Bracelet is not in the final list", hasItemTypeNamed( "Bracelet", finalList ) );
        assertTrue( "Necklace is not in the final list", hasItemTypeNamed( "Necklace", finalList ) );
        assertTrue( "Watch is not in the final list", hasItemTypeNamed( "Watch", finalList ) );
        assertTrue( "Ear ring is not in the final list", hasItemTypeNamed( "Ear ring", finalList ) );
View Full Code Here

     */
    protected Query createQuery( Module module, Class clazz )
    {
        UnitOfWork uow = module.newUnitOfWork();
        QueryBuilder qb = module.newQueryBuilder( clazz );
        return uow.newQuery( qb );
    }

    private Module findModule( EntityDetailDescriptor descriptor )
    {
        String lName = descriptor.module().layer().descriptor().name();
View Full Code Here

        uow.complete();

        uow = module.newUnitOfWork();

        QueryBuilder<Post> queryBuilder = module.newQueryBuilder( Post.class );
        Query<Post> query = uow.newQuery( queryBuilder );
        assertEquals( 1, query.count() );
        post = query.find();
        assertNotNull( post );
        assertEquals( title, post.title().get() );
View Full Code Here

        assertNotNull( post );
        assertEquals( title, post.title().get() );

        post = templateFor( Post.class );
        queryBuilder = module.newQueryBuilder( Post.class ).where( eq( post.title(), title ) );
        query = uow.newQuery( queryBuilder );
        assertEquals( 1, query.count() );
        post = query.find();
        assertNotNull( post );
        assertEquals( title, post.title().get() );
View Full Code Here

        assertNotNull( post );
        assertEquals( title, post.title().get() );

        post = templateFor( Post.class );
        queryBuilder = module.newQueryBuilder( Post.class ).where( eq( post.title(), "Not available" ) );
        query = uow.newQuery( queryBuilder );
        assertEquals( 0, query.count() );

        post = templateFor( Post.class );
        queryBuilder = module.newQueryBuilder( Post.class ).where( ne( post.title(), "Not available" ) );
        query = uow.newQuery( queryBuilder );
View Full Code Here

        query = uow.newQuery( queryBuilder );
        assertEquals( 0, query.count() );

        post = templateFor( Post.class );
        queryBuilder = module.newQueryBuilder( Post.class ).where( ne( post.title(), "Not available" ) );
        query = uow.newQuery( queryBuilder );
        assertEquals( 1, query.count() );

        post = templateFor( Post.class );
        queryBuilder = module.newQueryBuilder( Post.class ).where( not( eq( post.title(), "Not available" ) ) );
        query = uow.newQuery( queryBuilder );
View Full Code Here

        query = uow.newQuery( queryBuilder );
        assertEquals( 1, query.count() );

        post = templateFor( Post.class );
        queryBuilder = module.newQueryBuilder( Post.class ).where( not( eq( post.title(), "Not available" ) ) );
        query = uow.newQuery( queryBuilder );
        post = query.find();
        assertNotNull( post );
        assertEquals( title, post.title().get() );

        post = templateFor( Post.class );
View Full Code Here

        assertNotNull( post );
        assertEquals( title, post.title().get() );

        post = templateFor( Post.class );
        queryBuilder = module.newQueryBuilder( Post.class ).where( eq( post.author().get().nickname(), "eskatos" ) );
        query = uow.newQuery( queryBuilder );
        assertEquals( 1, query.count() );
        post = query.find();
        assertNotNull( post );
        assertEquals( title, post.title().get() );
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.