Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[eclipselink-users] Filtering OneToMany and ManyToOne relationship mappings

Hello.

I am about to change our project's JPA implementation from Hibernate to EclipseLink.
There is a tough relationship i am struggling to accomplish.

The case is similar as this (as much it might seems to make no much sense):

@Entity @Table(name="tb_role")
class Role {
  @Id
  private Long id;
 
  @Enumerated(STRING)
  private ProductType productType; // STANDARD, SPECIAL
  ...
}

@Entity @Table(name="rl_user_role")
class UserRole {
    ...
   @ManyToOne
   private Role role;

   private String comments;
   ...
}

@Entity @Table(name="tb_user")
class User {
     @Id
     private Long id;

     @ManyToOne
     // NEED to filter for SPECIAL (property or column value on Role)
     // DO NOT HAVE A LOCAL FK column, should use USER_ID on rl_user_role
     private UserRole claimForOthersRole;

     @OneToMany
     // NEED to filter for STANDARD (property or column value on Role)
     @JoinColumn(name = "user_id")
    
     private Set<UserRole> roles;

}


Do you guys have any clue on how could i accomplish this? I was trying to use Hibernate's @Where annotation, but i could just filter using columns on "rl_user_role" (Couldn't be nested).

Thank you

Luciano Santos

Back to the top