// Path: src/main/java/org/lbogdanov/poker/core/Constants.java
// public static final int SESSION_CODE_DEFAULT_LENGTH = 10;


import com.google.common.base.Strings;
import static org.lbogdanov.poker.core.Constants.SESSION_CODE_DEFAULT_LENGTH;
import static org.lbogdanov.poker.util.Settings.SESSION_CODE_LENGTH;
import java.security.SecureRandom;
import java.util.Random;
import javax.inject.Inject;
import javax.inject.Singleton;
import org.lbogdanov.poker.core.*;
import com.avaje.ebean.EbeanServer;
import com.avaje.ebean.ExpressionList;
import com.avaje.ebean.Query;
import com.avaje.ebean.annotation.Transactional;
                    .where().eq("code", code)
                    .findUnique();
    }

    /**
     * {@inheritDoc}
     */
    @Override
    @Transactional(readOnly = true)
    public PagingList<Session> find(User user, String name, String orderBy, boolean ascending, int pageSize) {
        // TODO union with sessions where the user has participated
        Query<Session> query = ebean.find(Session.class);
        ExpressionList<Session> expr = query.where().eq("author", user);
        if (!Strings.isNullOrEmpty(name)) {
            expr = expr.ilike("name", name);
        }
        query = ascending ? expr.orderBy().asc(orderBy) : expr.orderBy().desc(orderBy);
        return new EbeanPagingList<Session>(query.findPagingList(pageSize));
    }

    /**
     * {@inheritDoc}
     */
    @Override
    @Transactional
    public Session create(String name, String description, String estimations) {
        Session session = new Session();
        session.setName(name);
        session.setDescription(description);
        session.setEstimates(estimations);
// Path: src/main/java/org/lbogdanov/poker/core/Constants.java
// public static final int SESSION_CODE_DEFAULT_LENGTH = 10;


// Path: src/main/java/org/lbogdanov/poker/core/impl/SessionServiceImpl.java
import com.google.common.base.Strings;
import static org.lbogdanov.poker.core.Constants.SESSION_CODE_DEFAULT_LENGTH;
import static org.lbogdanov.poker.util.Settings.SESSION_CODE_LENGTH;
import java.security.SecureRandom;
import java.util.Random;
import javax.inject.Inject;
import javax.inject.Singleton;
import org.lbogdanov.poker.core.*;
import com.avaje.ebean.EbeanServer;
import com.avaje.ebean.ExpressionList;
import com.avaje.ebean.Query;
import com.avaje.ebean.annotation.Transactional;

                    .where().eq("code", code)
                    .findUnique();
    }

    /**
     * {@inheritDoc}
     */
    @Override
    @Transactional(readOnly = true)
    public PagingList<Session> find(User user, String name, String orderBy, boolean ascending, int pageSize) {
        // TODO union with sessions where the user has participated
        Query<Session> query = ebean.find(Session.class);
        ExpressionList<Session> expr = query.where().eq("author", user);
        if (!Strings.isNullOrEmpty(name)) {
            expr = expr.ilike("name", name);
        }
        query = ascending ? expr.orderBy().asc(orderBy) : expr.orderBy().desc(orderBy);
        return new EbeanPagingList<Session>(query.findPagingList(pageSize));
    }

    /**
     * {@inheritDoc}
     */
    @Override
    @Transactional
    public Session create(String name, String description, String estimations) {
        Session session = new Session();
        session.setName(name);
        session.setDescription(description);
        session.setEstimates(estimations);
        session.setCode(newCode(SESSION_CODE_LENGTH.asInt().or(SESSION_CODE_DEFAULT_LENGTH)));