-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Kind of "Restriction.contains" wanted...
PostPosted: Thu Jun 14, 2007 11:08 am 
Newbie

Joined: Thu Jun 14, 2007 8:50 am
Posts: 2
Hi, I am a Hibernate noob and I am facing the following problem I could not solve by searching the forum:

Class C (see below) has a Set<String> S member. Let X be a String. Now I want to get all instances of C from the database, where C.S contains X.

Is there a way to get it via the Criteria, Restrictions, or Example classes. How?

Thanks for help, and sorry if this question is too easy or would have been answered by more intensive searching the forum...

Code:
import java.util.Set;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;

import org.hibernate.annotations.CollectionOfElements;

@Entity
public class SetContainingClass {

    private Long id;

    private Set<String> set;

    public SetContainingClass() {
    }

    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    @CollectionOfElements
    public Set<String> getSet() {
        return set;
    }

    public void setSet(Set<String> set) {
        this.set = set;
    }

}


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.