Class RangeOverlapsJdbcFunction

java.lang.Object
ch.tocco.nice2.persist.core.api.hibernate.query.AbstractJdbcFunction
ch.tocco.nice2.optional.calendar.impl.jdbc.RangeOverlapsJdbcFunction
All Implemented Interfaces:
JdbcFunction

@Component public class RangeOverlapsJdbcFunction extends AbstractJdbcFunction

Checks whether a calendar event overlaps a window, using the PostgreSQL range type int8range so that the query can use a range index. Expects exactly 4 arguments: pathStart and pathEnd have to be references to fields of type long, whereas windowStart and windowEnd have to be a literal (timestamp in milliseconds).

Both ranges are inclusive on their lower and exclusive on their upper bound ('[)'). Null bounds are treated as unbounded.

An instantaneous calendar event (same start and end) would be the empty range, which never overlaps anything. It is therefore built as '[]' instead, so that it matches every window containing its start. For a good performance a custom index on this expression (e.g. custom_index_calendar_event_range) has to use the exact same expression.

  • Constructor Details

    • RangeOverlapsJdbcFunction

      public RangeOverlapsJdbcFunction(TypeManager typeManager)
  • Method Details