KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
does anyone know if and how the solution for following question (which is written in the JPA API) can be written using the hibernate criteria API? To be more specific I have a Discussion entity that contains a list of participants (which is a list of usernames): @ElementCollection @Column(name = "user_name") @CollectionTable(name = "DISCUSSION_USER", joinColumns = @JoinColumn(name = "DISCUSSION_ID")) @OrderColumn(name = "ORDER_INDEX") private List<String> participants = new ArrayList<String>(); Now I need to retrieve all Discussions where a given username is a participant. If I would have created an entity for Participant this would be straightforward: Criteria crit = getSession().createCriteria(Discussion.class); crit.createAlias("participants", "p"); crit.add(Restrictions.eq("p.userName", portalUsername)); But I can't create an alias with a non entity...
Tags (comma-separated)
Save Edits
Cancel