可以从一个Hibernate select中填充@Transient列表吗?

时间:2015-08-11 07:21:29

标签: java hibernate persistence hibernate-criteria

我有一份工作清单,我想过滤它。一个工作可以有一个领域,部门,职位,研究,经验......

我的工作实体:

        @Entity
        @Table(name="JOB")
        public class Job extends BaseEntity{
        @Column(name = "title", nullable = false, length = 256)
        @NotNull @NotEmpty @Size(max=256)
        @Expose
        private String title;

        @ManyToOne
        @JoinColumn(name="department_id")
        @Expose
        @Fetch(FetchMode.JOIN)
        private Department department;


        @ManyToOne
        @JoinColumn(name="position_id")
        @Expose
        @Fetch(FetchMode.JOIN)
        private Position position;


        @ManyToOne
        @JoinColumn(name="studies_id")
        @Expose
        @Fetch(FetchMode.JOIN)
        private Studies studies;


        @ManyToOne
        @JoinColumn(name="experience_id")
        @Expose
        @Fetch(FetchMode.JOIN)
        private Experience experience;


        @ManyToOne
        @JoinColumn(name="domain_id")
        @Expose
        @Fetch(FetchMode.JOIN)
        private Domain domain;


        @ManyToOne
        @JoinColumn(name="contract_type_id")
        @Expose
        @Fetch(FetchMode.JOIN)
        private ContractType contractType;

        @Transient
        private List<Studies> studiesList = new ArrayList<Studies>();


        @Transient
        private List<Department> departmentsList = new ArrayList<Department>();


       @Transient
       private List<Position> positionList = new ArrayList<Position>();


       @Transient
       private List<ContractType> contractTypeList = new ArrayList<ContractType>();


       @Transient
       private List<Experience> experienceList = new ArrayList<Experience>();


       @Transient
       private List<Domain> domainList = new ArrayList<Domain>();

对于每个作业属性,我执行findAll并发送到页面,供用户从中选择一个。它现在看起来像这样:

        job.setStudiesList(studiesService.findAll());
        job.setDepartmentsList(departamentService.findAll());
        job.setPositionList(positionService.findAll());
        job.setExperienceList(experienceService.findAll());
        job.setContractTypeList(contractTypeService.findAll());
        job.setDomainList(domainService.findAll());

当我加载页面时,它写了很多查询,我想在一个查询中编写所有findAll并将其放在@Transient列表中,这可能吗?如果是这样的话?

0 个答案:

没有答案