Example usage for org.hibernate.sql JoinType RIGHT_OUTER_JOIN

List of usage examples for org.hibernate.sql JoinType RIGHT_OUTER_JOIN

Introduction

In this page you can find the example usage for org.hibernate.sql JoinType RIGHT_OUTER_JOIN.

Prototype

JoinType RIGHT_OUTER_JOIN

To view the source code for org.hibernate.sql JoinType RIGHT_OUTER_JOIN.

Click Source Link

Usage

From source file:com.devnexus.ting.repository.jpa.PresentationRepositoryImpl.java

License:Apache License

@Override
public List<Presentation> findPresentations(PresentationSearchQuery presentationSearchQuery) {

    Session session = (Session) entityManager.getDelegate();

    final Criteria rootCriteria = session.createCriteria(Presentation.class);
    final Criteria eventCriteria = rootCriteria.createCriteria("event");

    if (presentationSearchQuery.getEvent() != null
            && presentationSearchQuery.getEvent().getEventKey() != null) {
        eventCriteria.add(// w  ww  . j  ava 2 s  .c  o  m
                Restrictions.eq("eventKey", presentationSearchQuery.getEvent().getEventKey()).ignoreCase());
    }

    if (presentationSearchQuery.getTrack() != null) {
        if (presentationSearchQuery.getTrack().getId() != null) {
            rootCriteria.createAlias("track", "t", JoinType.INNER_JOIN,
                    Restrictions.eq("t.id", presentationSearchQuery.getTrack().getId()));
        } else if (presentationSearchQuery.getTrack().getName() != null) {
            rootCriteria.createAlias("track", "t", JoinType.INNER_JOIN,
                    Restrictions.eq("t.name", presentationSearchQuery.getTrack().getName()).ignoreCase());
        }
    } else {
        rootCriteria.createAlias("track", "t", JoinType.RIGHT_OUTER_JOIN);
    }

    if (!presentationSearchQuery.getPresentationTags().isEmpty()) {
        final Criteria tagsCriteria = rootCriteria.createCriteria("presentationTags");
        tagsCriteria.add(Restrictions.in("name", presentationSearchQuery.getPresentationTagNames()));
    }

    return rootCriteria.list();
}