hibernate - Remove join entities from proxy object on demand JPA -


i have class entity contains other class entities join result. should remove unwanted join proxy object on demand?

@entity @table(name = "jobs") public class job implements serializable{      @column(name = "id", nullable = true)     private int id ;      private string              deliveryconfigxml;      private string              djobconfigxml;      @temporal(temporaltype.timestamp)     @column(name = "date")     private date date;      @onetomany(mappedby = "processedjob")     private list<processedjob>  processedjobs;       @onetomany(mappedby = "deliveredjob")     private list<deliveredjob>  deliveredjobs; } 

when fetch entity database, give proxy object. then, using proxy object, can other entities through lazy loading.

list<deliveredjob> list = jobs.getdeliveredjobs(); //lazy loading 

as whole response through java jackson library, in cases, don't want these deliveredjobs , processedjob, due jackson, gives complete result.

how should result on demand? if set delivered jobs null in proxy object? if way, way solve problem or there other solutions?

you can try unproxy object.

if (entity instanceof hibernateproxy) {     entity = ((hibernateproxy) entity).gethibernatelazyinitializer()             .getimplementation(); } 

Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -