开发者

Hibernate - how to load into POJO which is not an entity

开发者 https://www.devze.com 2023-02-23 03:32 出处:网络
I have an entity named father and son1 and son2 who are mapped as collections inside father Lets say father has a,b,开发者_运维百科c properties son1 has a,d and son 2 has b,e

I have an entity named father and son1 and son2 who are mapped as collections inside father

Lets say father has a,b,开发者_运维百科c properties son1 has a,d and son 2 has b,e and I have a bean which contains a,b,d,e called MyBean in one query.

Can I use it in a simple query using addEntity(MyBean.class) where my MyBean is not an hibernate entity (POJO)?


the POJO is as simple as it gets without annotations

class POJO {

Object a,b,d,e;
//get and set's and empty c'tor etc 

}


use the new keyword and create the object in your search query

this only works for jpql


Can I use it in a simple query using addEntity(MyBean.class) where my MyBean is not an hibernate entity (POJO)?

I don't believe so. I believe that hibernate must know about all classes it persists via mappings.

0

精彩评论

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

关注公众号