Commit bf90958f by Tuomas Riihimäki

All places might not have a map

1 parent d39c210f
......@@ -30,6 +30,7 @@ import javax.persistence.criteria.*;
import fi.codecrew.moya.beans.EventBean;
import fi.codecrew.moya.model.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
......@@ -64,9 +65,11 @@ public class PlaceFacade extends IntegerPkGenericFacade<Place> {
Root<Place> root = cq.from(Place.class);
LanEvent event = eventBean.getCurrentEvent();
cq.where(
cb.equal(root.get(Place_.id), id),
cb.equal(root.get(Place_.map).get(EventMap_.event), eventBean.getCurrentEvent())
cb.or(cb.equal(root.get(Place_.map).get(EventMap_.event), event),
cb.equal(root.get(Place_.product).get(Product_.event), event))
);
return super.getSingleNullableResult(getEm().createQuery(cq));
}
......@@ -306,18 +309,17 @@ public class PlaceFacade extends IntegerPkGenericFacade<Place> {
subq.where(
placeJoin.get(Place_.id).isNotNull(),
cb.equal(placeJoin.get(Place_.map).get(EventMap_.event), eventBean.getCurrentEvent())
);
);
ProductFlag[] flags = {ProductFlag.CREATE_NEW_PLACE_WHEN_BOUGHT};
ProductFlag[] flags = { ProductFlag.CREATE_NEW_PLACE_WHEN_BOUGHT };
cq.where(
cb.or(
root.get(Product_.id).in(subq),
root.get(Product_.productFlags).in(Arrays.asList(flags))
),
),
cb.equal(root.get(Product_.event), eventBean.getCurrentEvent())
);
);
cq.orderBy(cb.asc(root.get(Product_.name)));
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!