@OrderColumn annotation in Hibernate 3.5

前端 未结 3 1567
醉梦人生
醉梦人生 2020-11-27 04:10

I\'m trying to use the @OrderColumn annotation with Hibernate 3.5

@OneToMany(mappedBy = \"parent\",fetch=FetchType.EAGER, cascade=CascadeType.AL         


        
3条回答
  •  谎友^
    谎友^ (楼主)
    2020-11-27 04:18

    You should try to specify OrderColumn on the owner of the association. Or in your mapping you put the owner on the child, the owner should be the parent (on a bidirectionnal association, the owner is the one which doesn't have the keyword mappedBy, here you put this keyword on the parent's class, then you mean the parent's class is not the owner)

    In your children class you should have the keyword mappedBy on the parentCollection. But not on the childrenCollection.
    And in your parent class you should have the annotation @JoinTable, something like this :

    @OneToMany(mappedBy = "parent",fetch=FetchType.EAGER, cascade=CascadeType.ALL)
    @OrderColumn(name = "pos")
    @JoinTable( name = "", joinColumns = @JoinColumn(  )
    private List childrenCollection;
    

提交回复
热议问题