@Override public Contracts getContractForPosition(Long id) { org.hibernate.Session sess = sessionFactory.getCurrentSession(); sess.enableFetchProfile("clients-with-contracts"); ContragentsInContract client = (ContragentsInContract) sess.get(ContragentsInContract.class, id); return client.getContract(); }
public List<Contracts> getContractsForClient(Long id) { org.hibernate.Session sess = sessionFactory.getCurrentSession(); sess.enableFetchProfile("clients-with-rolesCont"); sess.enableFetchProfile("clients-with-contracts"); Clients client = (Clients) sess.get(Clients.class, id); List<Contracts> returnList = new ArrayList<Contracts>(); List<ContragentsInContract> contrList = client.getParticipantInContracts(); for (ContragentsInContract con : contrList) { returnList.add(con.getContract()); } return returnList; }