Java 类org.hibernate.transform.BasicTransformerAdapter 实例源码

项目:engerek    文件:GetObjectResult.java   
@Override
public ResultTransformer getResultTransformer() {
    return new BasicTransformerAdapter() {
        @Override
        public Object transformTuple(Object[] tuple, String[] aliases) {
            return new GetObjectResult((String) tuple[0], (byte[]) tuple[1],
                    tuple.length > 2 ? (Short) tuple[2] : null,
                    tuple.length > 3 ? (Short) tuple[3] : null,
                    tuple.length > 4 ? (Short) tuple[4] : null,
                    tuple.length > 5 ? (Short) tuple[5] : null,
                    tuple.length > 6 ? (Short) tuple[6] : null,
                    tuple.length > 7 ? (Short) tuple[7] : null);
        }
    };
}
项目:engerek    文件:GetContainerableResult.java   
@Override
public ResultTransformer getResultTransformer() {
    return new BasicTransformerAdapter() {
        @Override
        public Object transformTuple(Object[] tuple, String[] aliases) {
            return new GetContainerableResult((String) tuple[0], (byte[]) tuple[2]);
        }
    };
}
项目:engerek    文件:GetCertificationWorkItemResult.java   
@Override
public ResultTransformer getResultTransformer() {
    return new BasicTransformerAdapter() {
        @Override
        public Object transformTuple(Object[] tuple, String[] aliases) {
            return new GetCertificationWorkItemResult((String) tuple[0], (Integer) tuple[1], (Integer) tuple[2]);
        }
    };
}
项目:midpoint    文件:GetObjectResult.java   
@Override
public ResultTransformer getResultTransformer() {
    return new BasicTransformerAdapter() {
        @Override
        public Object transformTuple(Object[] tuple, String[] aliases) {
            return new GetObjectResult((String) tuple[0], (byte[]) tuple[1],
                    tuple.length > 2 ? (Short) tuple[2] : null,
                    tuple.length > 3 ? (Short) tuple[3] : null,
                    tuple.length > 4 ? (Short) tuple[4] : null,
                    tuple.length > 5 ? (Short) tuple[5] : null,
                    tuple.length > 6 ? (Short) tuple[6] : null,
                    tuple.length > 7 ? (Short) tuple[7] : null);
        }
    };
}
项目:midpoint    文件:GetContainerableResult.java   
@Override
public ResultTransformer getResultTransformer() {
    return new BasicTransformerAdapter() {
        @Override
        public Object transformTuple(Object[] tuple, String[] aliases) {
            return new GetContainerableResult((String) tuple[0], (byte[]) tuple[2]);
        }
    };
}
项目:midpoint    文件:GetCertificationWorkItemResult.java   
@Override
public ResultTransformer getResultTransformer() {
    return new BasicTransformerAdapter() {
        @Override
        public Object transformTuple(Object[] tuple, String[] aliases) {
            return new GetCertificationWorkItemResult((String) tuple[0], (Integer) tuple[1], (Integer) tuple[2]);
        }
    };
}
项目:hibernate-demos    文件:HibernateSearchWithElasticsearchIT.java   
@Test
public void projectionWithTransformer() {
    EntityManager em = emf.createEntityManager();

    inTransaction( em, tx -> {
        FullTextEntityManager ftem = Search.getFullTextEntityManager( em );
        QueryBuilder qb = ftem.getSearchFactory()
                .buildQueryBuilder()
                .forEntity( VideoGame.class )
                .get();

        FullTextQuery query = ftem.createFullTextQuery(
                qb.keyword()
                .onField( "tags" )
                .matching( "round-based" )
                .createQuery(),
                VideoGame.class
        )
        .setProjection( "title", "publisher.name", "release" )
        .setResultTransformer( new BasicTransformerAdapter() {
            @Override
            public VideoGameDto transformTuple(Object[] tuple, String[] aliases) {
                return new VideoGameDto( (String) tuple[0], (String) tuple[1], (Date) tuple[2] );
            }
        } );

        VideoGameDto projection = (VideoGameDto) query.getSingleResult();
        assertThat( projection.getTitle() ).isEqualTo( "Tanaka's return" );
        assertThat( projection.getPublisherName() ).isEqualTo( "Samurai Games, Inc." );
        assertThat( projection.getRelease() ).isEqualTo( new GregorianCalendar( 2011, 2, 13 ).getTime() );
    } );

    em.close();
}
项目:midpoint    文件:GetObjectResult.java   
@Override
public ResultTransformer getResultTransformer() {
    return new BasicTransformerAdapter() {
        @Override
        public Object transformTuple(Object[] tuple, String[] aliases) {
            return new GetObjectResult((String) tuple[0], (byte[]) tuple[1],
                    tuple.length > 2 ? (Short) tuple[2] : null,
                    tuple.length > 3 ? (Short) tuple[3] : null,
                    tuple.length > 4 ? (Short) tuple[4] : null,
                    tuple.length > 5 ? (Short) tuple[5] : null,
                    tuple.length > 6 ? (Short) tuple[6] : null,
                    tuple.length > 7 ? (Short) tuple[7] : null);
        }
    };
}
项目:midpoint    文件:GetContainerableResult.java   
@Override
public ResultTransformer getResultTransformer() {
    return new BasicTransformerAdapter() {
        @Override
        public Object transformTuple(Object[] tuple, String[] aliases) {
            return new GetContainerableResult((String) tuple[0], (byte[]) tuple[2]);
        }
    };
}
项目:midpoint    文件:GetCertificationWorkItemResult.java   
@Override
public ResultTransformer getResultTransformer() {
    return new BasicTransformerAdapter() {
        @Override
        public Object transformTuple(Object[] tuple, String[] aliases) {
            return new GetCertificationWorkItemResult((String) tuple[0], (Integer) tuple[1], (Integer) tuple[2]);
        }
    };
}