开发者

hibernate query result to a predefined object?

It is possible in hibernate to get a result of a query to a mapped db object.

Is it possible to create a non-persistent object and get the query result into this object?

for example

session.createSQLQuery(select a,b,c from table).list.addEntity(myclass.class)

if myclass is:

publi开发者_高级运维c class myclass{

private int a;

private int b;

private int c; 
.
.
.
}


You can use AliasToBeanResultTransformer:

session.createSQLQuery("select a,b,c from table")
    .setResultTransformer(new AliasToBeanResultTransformer(myclass.class))
    .list();


No, Hibernate will only work with classes that are mapped ahead of time.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜