annotation to filter results of a @OneToMany association

前端 未结 4 573
忘掉有多难
忘掉有多难 2020-11-27 07:10

I have parent/child relationship between two tables, and the corresponding mapping in my Java classes. The tables roughly look like that:

A (ref number, stuf         


        
4条回答
  •  青春惊慌失措
    2020-11-27 07:39

    If I am understanding the question right, there is a way to do this with javax.persistence annotations (I used this on a ManyToOne myself, and tailored the answer from here):

    @JoinColumns({
        @JoinColumn(name = "A_REF", referencedColumnName = "REF"),
        @JoinColumn(name = "B_TABLE_NAME.OTHER", referencedColumnName = "'123'")})
    @OneToMany
    private Set bs;
    

    Note the single quotes in the referencedColumnName, this is the value you are looking for.

    More information here.

提交回复
热议问题