-->
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: Datum Intervall Problem
PostPosted: Sat Jan 24, 2009 11:53 am 
Newbie

Joined: Sat Jan 24, 2009 10:11 am
Posts: 4
Hallo zusammen,
Ich habe folgendes Problem:
Ich möchte Hotel-Instanzen aus meiner Datenbank holen, welche in einem bestimmten Zeitintervall komplett verfügbar sind.
Ich habe eine Hotel-Instanz welche eine Collection namens availabilities besitzt. Die Kardinalität von Hotel zu Availabilities is 1:N, da ein Hotel mehrere Verfügbarkeiten haben kann. Verfügbar ist ein Hotel dann, wenn ein Eintrag in availabilities gemacht wird.
Wenn ich nun das anreise-datum und das abreise-datum eines benutzers entgegen nehme, möchte ich nur hotels aus der datenbank holen, welche an allen tagen dieses Zeit-Intervalls verfügbar sind (also für jeden tag einen eintrag in availabilities haben). bisher werden leider auch die hotels angezeigt die z.b. nur an einem tag in diesem zeitraum verfügbar sind.

hier die kritische hql-zeile:
Code:
"AND available.date BETWEEN :arrival AND :departure " +


und hier das gesamte HQL-Query:
Code:
Query q = db.createHqlQuery("SELECT hotel FROM Hotel as hotel " +
            "FETCH ALL PROPERTIES " +
            "INNER JOIN hotel.districts as district " +
            "LEFT JOIN district.location as location " +
            "LEFT JOIN location.state as state " +
            "LEFT JOIN state.country as country " +
            "LEFT JOIN hotel.catDescriptions as catDesc " +
            "LEFT JOIN hotel.availabilities as available " +
            "WHERE " +
            "location.id LIKE :location " +
            "AND district.id LIKE :district " +
            "AND state.id LIKE :state " +
            "AND country.id LIKE :country " +
            "AND catDesc.price BETWEEN :price1 AND :price2 " +
            "AND catDesc.roomCat.id=:category " +
            "AND hotel.stars BETWEEN :stars1 AND :stars2 " +
            "AND available.date in (:arrival) " +
            "AND available.roomCat.id=:availCategory " +
            "AND hotel.deleted=:deleted");


Ich muss mein Projekt fertig bekommen und würde mich deswegen riesig über eure Hilfe freuen!!!

Liebe Grüße,
iTob87


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.