Package org.qi4j.api.unitofwork

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


            UnitOfWork uow = module.newUnitOfWork( newUsecase( "Create sample data" ) );
            try
            {
                int i = 11; // starting at 11 for sortable tracking id prefix in lists
                QueryBuilder<Cargo> qb = module.newQueryBuilder( Cargo.class );
                for( Cargo cargo : uow.newQuery( qb ) )

                {
                    final String trackingId = cargo.trackingId().get().id().get();
                    final RouteSpecification routeSpec = cargo.routeSpecification().get();
                    routeSpec.print();
View Full Code Here


                    if( i == 12 )
                    {
                        Location origin = routeSpec.origin().get();
                        Location dest = routeSpec.destination().get();
                        Location badDest = null;
                        Query<Location> locations = uow.newQuery( module.newQueryBuilder( Location.class ) );
                        for( Location loc : locations )
                        {
                            if( !origin.equals( loc ) && !dest.equals( loc ) )
                            {
                                badDest = loc;
View Full Code Here

            Usecase usecase = UsecaseBuilder.newUsecase( "Populate Random Cargos" );
            UnitOfWork uow = module.newUnitOfWork( usecase );

            CargoAggregateRoot cargos = uow.get( CargoAggregateRoot.class, CargoAggregateRoot.CARGOS_ID );

            Query<Location> allLocations = uow.newQuery( module.newQueryBuilder( Location.class ) );
            int locationSize = (int) allLocations.count();

            // Make array for selection of location with random index
            final List<Location> locationList = new ArrayList<>();
            for( Location location : allLocations )
View Full Code Here

            uow.complete();

            uow = domainModule.newUnitOfWork();
            QueryBuilder<PretextEntity> queryBuilder = domainModule.newQueryBuilder( PretextEntity.class );
            queryBuilder = queryBuilder.where( eq( templateFor( PretextEntity.class ).reason(), "Testing purpose" ) );
            Query<PretextEntity> query = uow.newQuery( queryBuilder );
            pretext = query.find();
            if ( pretext == null ) {
                System.err.println( "ERROR: Unable to find pretext!" );
                exitStatus = -1;
            } else {
View Full Code Here

            try
            {
                QueryBuilder<Subject> builder = qbf.newQueryBuilder( Subject.class );
                SubjectEntity.SubjectState subject = templateFor( SubjectEntity.SubjectState.class );
                builder.where( eq( subject.schoolId(), schoolId ) );
                return uow.newQuery( builder );
            }
            finally
            {
                uow.pause();
            }
View Full Code Here

            try
            {
                QueryBuilder<Student> builder = qbf.newQueryBuilder( Student.class );
                StudentEntity.StudentState studentState = templateFor( StudentEntity.StudentState.class );
                builder.where( eq( studentState.schoolId(), schoolId ) );
                return uow.newQuery( builder );
            }
            finally
            {
                uow.pause();
            }
View Full Code Here

    }

    public void testQuery()
    {
        UnitOfWork uow = module.newUnitOfWork();
        Query<Car> query = uow.newQuery( module.newQueryBuilder( Car.class ) );
        for( Car car : query )
        {
            System.out.println( car.model() + " | " + car.manufacturer() + " | " + car.year() );
        }
    }
View Full Code Here

            UnitOfWork uow = uowf.newUnitOfWork( newUsecase( "### Create sample data" ) );
            try
            {
                int i = 11; // starting at 11 for sortable tracking id prefix in lists
                QueryBuilder<Cargo> qb = qbf.newQueryBuilder( Cargo.class );
                for( Cargo cargo : uow.newQuery( qb ) )
                {
                    String trackingId = cargo.trackingId().get().id().get();
                    ExpectedHandlingEvent nextEvent;
                    Date time;
                    String port;
View Full Code Here

            UnitOfWork uow = uowf.newUnitOfWork( usecase );

            CargosEntity cargos = uow.get( CargosEntity.class, CargosEntity.CARGOS_ID );

            QueryBuilder<Location> qb = qbf.newQueryBuilder( Location.class );
            Query<Location> allLocations = uow.newQuery( qb );
            int locationSize = (int) allLocations.count();

            // Make array for selection of location with random index
            final List<Location> locationList = new ArrayList<Location>();
            for( Location location : allLocations )
View Full Code Here

                module.newQueryBuilder( Manufacturer.class );

        Manufacturer template = templateFor( Manufacturer.class );
        builder.where( eq( template.name(), name ) );

        Query<Manufacturer> query = uow.newQuery( builder);
        return query.find();
    }
}

// END SNIPPET: repo
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.