-->
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.  [ 2 posts ] 
Author Message
 Post subject: Suche eine Art "Restrictions.contains"
PostPosted: Thu Jun 14, 2007 10:46 am 
Newbie

Joined: Thu Jun 14, 2007 8:50 am
Posts: 2
Hallo, ich stehe vor folgendem Problem und hab im Forum nichts passendes gefunden:

Klasse A hat ein Set<String> S als Attribut. Jetzt suche ich zu einem gegebenen String X alle Objekte der Klasse A, bei denen X in A.S enthalten ist.

Das ganze möglichst mit Hibernate Criteria und Restrictions, oder auch Example. Wie gehts?

Danke für Eure Hilfe, und sorry, falls die Frage zu einfach ist - bin was Hibernate angeht ziemlicher Anfänger...

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  
 
 Post subject:
PostPosted: Fri Jun 15, 2007 6:35 am 
Expert
Expert

Joined: Tue Nov 23, 2004 7:00 pm
Posts: 570
Location: mostly Frankfurt Germany
"select s from SetCon s where ? in elements(s.set)"

Criteria müsste ich ausprobieren. Versuche es mal mit Restrictions.in

_________________
Best Regards
Sebastian
---
Training for Hibernate and Java Persistence
Tutorials for Hibernate, Spring, EJB, JSF...
eBook: Hibernate 3 - DeveloperGuide
Paper book: Hibernate 3 - Das Praxisbuch
http://www.laliluna.de


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

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.