Hibernate Projection approach in project


With using this approach we can get any of field of entity and this way is more efficient rather than get all entity fileds , example in below:

@Repository

public interface CompanyRepo extends JpaRepository<Company, Long> {

    Integer countById(long id);


    <T extends CompanyViewProtocol> Optional<T> findById(long id, Class<T> type);

}


public interface CompanyViewProtocol {

}


public interface ContactDetailView extends CompanyViewProtocol {

    CompanyContactDetail getContactDetail();

}


in there companyRepo.findById(1L,ContactDetailView.class)  

gives us CompanyContactDetail 


Comments

Popular posts from this blog

Installation instructions for some programs on linux ubuntu

Hibernate and Application Performance

write huge text into clob column in oracle