Hi,
I still try to query for objects containing a certain object. I can't imagine that there isn't ANY way to solve my problem, but maybe I should try to descibe it more precisely.
I have one object, containing an array of a second object.
Code:
class Event
{
...
private String eventName;
private Array guests;
...
public Array Guests
{
get { return guests; }
set { guests = value; }
}
...
}
class Guest
{
private long id;
private String name;
...
public String Name
{
get ...
set ...
}
...
}
And the mapping file for the Event-Object
<array name="Event" table="event_guest" cascade="all">
<key column="eventid"/>
<index column="idx"/>
<many-to-many class="guest" column="guestid" />
</array>
Database Structure
Code:
event
----------------------------------------------
eventID | eventname
5 | Concert
event_guest
---------------------------------------------
eventid | guestid | idx
5 | 1 | 0
5 | 2 | 1
5 | 3 | 2
guest
--------------------------------------------
guestid | name
1 | 'Frank'
2 | 'Smith'
3 | 'Jonson'
Now I want to query for all events, the guest 'Smith' wants to visit. (In this example only the "Concert" event)
I could query for something like
Code:
"from Event as ev where ev.Guests[1].Name = 'Smith'"
That works fine :-), but I do not want to spezify the index. I need something indexless like
Code:
from Event as ev where ev.Guests[].Name = 'Smith'
Yes, that does not work, but does anyone has any idea how to do this.
Your help would be very appriciated
Thank you
SunX