本文整理汇总了Java中org.hibernate.transform.BasicTransformerAdapter类的典型用法代码示例。如果您正苦于以下问题:Java BasicTransformerAdapter类的具体用法?Java BasicTransformerAdapter怎么用?Java BasicTransformerAdapter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
BasicTransformerAdapter类属于org.hibernate.transform包,在下文中一共展示了BasicTransformerAdapter类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getResultTransformer
import org.hibernate.transform.BasicTransformerAdapter; //导入依赖的package包/类
@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);
}
};
}
示例2: getResultTransformer
import org.hibernate.transform.BasicTransformerAdapter; //导入依赖的package包/类
@Override
public ResultTransformer getResultTransformer() {
return new BasicTransformerAdapter() {
@Override
public Object transformTuple(Object[] tuple, String[] aliases) {
return new GetContainerableResult((String) tuple[0], (byte[]) tuple[2]);
}
};
}
示例3: getResultTransformer
import org.hibernate.transform.BasicTransformerAdapter; //导入依赖的package包/类
@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]);
}
};
}
示例4: projectionWithTransformer
import org.hibernate.transform.BasicTransformerAdapter; //导入依赖的package包/类
@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();
}