Hi,
I got a few problems indexing a somewhat complex usage of a map. I've got two classes in general constructed like this:
Code:
@Entity
@Table(name = "Users")
public class User {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long userId;
@MapKey(columns = { @Column(name = "UserProfileEntryKey") })
@OneToMany(fetch = LAZY, cascade = CascadeType.ALL)
@Cascade(value = org.hibernate.annotations.CascadeType.DELETE_ORPHAN)
private Map<String, UserProfileEntry> profile;
// getter and setters and so on
}
@Entity
public class UserProfileEntry {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@Enumerated(value = EnumType.ORDINAL)
@Basic(optional = false)
private PrivacyLevel level;
@ManyToOne(optional = false)
@IndexedEmbedded(depth = 1)
private User user;
@Basic(optional=false)
private String value;
// getters and setters....
}
So, you can see that I'm constructing a user profile. There are two requirements in our system that dictate this structure with the UserProfileEntries: 1. The profile should be changeable at runtime by adding or deleting fields and 2. the access restrictions (called PrivacyLevel) for each field shall be changeable by the user.
I need to construct a search on the user profiles that uses the UserProfileEntry.values for searching but has to respect the privacy level of each UserProfileEntry and that has to return User instances. Is there a preferred way to achieve this? I've tried several approaches including a custom field bridge that writes all user fields ordered by privacy level inside the User index but none of them did a correct index update on UserProfileEntry changes.
Thanks for the help
Johannes