简体   繁体   中英

Fetching entity of multiple level using criteria hibernate

I have the following structure:

A.java

private long id;
private String name;
private B bObj;
// getter-setter

B.java

private long id;
private List<B> bList;
//getter-setter

As you can see the structure is recursive.

Now I want to write a Criteria that fetches an object of A along with bObj , bObj.bList , bObj.bList.bList , bObj.bList.bList.bList & so on where no. of level of join is not known.

Any other way except Criteria is also welcome.

Can anyone help me?

if you set fetch type to LAZZY on List bList; it could be enough, but I don'tknow if it isn necessary to set Maximum outer join fetch depth for hibernate to max level of bLists.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM