具有连接条件的休眠条件

时间:2018-09-05 13:38:06

标签: java hibernate filter multilingual hibernate-criteria

对于相同的“ emp_id”,数据库中的值分别为english(“ en”)和spanish(“ sp”)。但是即使在hibenate标准中将语言设置为“ en” (英语),输出也会给出给定“ emp_id ”(英语和西班牙语)的所有值。但是我需要标准中设置的值的值。 ,如果我将标准设置为“ en”,则应将“ emp_id”的值设置为“ en”(英语)。请参考域和条件代码

Emp域类:-

    @OneToMany(fetch = FetchType.LAZY, targetEntity = Multilingual.class)
    @JoinColumn(name = "emp_id")        
    private Set<Multilingual> multilinguals = new HashSet<>();

服务类别:-

List<Map<String, Object>> filters = requestParam.getFilter();
        ServiceResponse<List<Team>> sr = new ServiceResponse<>();
        if (filters == null || filters.isEmpty()) {
            filters = new ArrayList<>();
        }
        Map<String, Object> criteria = new HashMap<>();
        criteria.put("expression", "alias");
        criteria.put("property", "multilinguals");
        criteria.put("value", "multilinguals");
        filters.add(criteria);
        criteria = new HashMap<>();
        criteria.put("expression", "eq");
        criteria.put("property", "lan");
        criteria.put("value", "en");
        filters.add(criteria);
        requestParam.setFilter(filters);
        sr.setResponse(teamDao.getByCriteria(filters));
        return sr;

多语言域类:-

@Entity
@Table(name="multilingual")
public class Multilingual implements Serializable {
    @Id
    @Column(name = "id", unique = true, nullable = false)
    @GeneratedValue
    private Integer id;

    @Column(name = "lan", nullable = true, length = 50)
    private String lan;

    @Column(name = "name", nullable = true, length = 255)
    private String name; 

    @ManyToOne(fetch = FetchType.EAGER)
    @JoinColumn(name = "emp_id", insertable=true, updatable=true)
    private Emp emp;

0 个答案:

没有答案