Hello,
im having some problems creating a criteria for fetching a specific element. im using hibernate 3.6.6.Final
my classes:
Code:
class Topic {
@id
long id;
@oneToMany
@JoinColumn "topic_id"
list<SubTopic> subTopics;
}
Code:
class SubTopic {
@id
long id;
string content;
}
now im trying to load the subtopic with code="xyz" that belongs to the topic with id="123";
in plain sql i would just write a query like:
Code:
select * from subtopic join topic on topic.id = subtopic.topic_id where subtopic.code like 'xyz' and topic.id = 123;
but since we absolutely dont want a reference to the topic in our subtopic-class, this is not possible.
one solution would be to load the topic and then iterate through the subtopic-list, but this would be a problem if there would be several thousands subtopics for a topic.. any advices would be appreciated!