Package daos.common

Class GroupResultDao


  • @Singleton
    public class GroupResultDao
    extends AbstractDao
    DAO for GroupResult
    • Method Detail

      • update

        public void update​(GroupResult groupResult)
      • remove

        public void remove​(GroupResult groupResult)
      • refresh

        public void refresh​(GroupResult groupResult)
      • findById

        public GroupResult findById​(java.lang.Long id)
      • findAllByBatch

        public java.util.List<GroupResult> findAllByBatch​(Batch batch)
      • countByBatch

        public java.lang.Integer countByBatch​(Batch batch)
      • findAllMaxNotReached

        public java.util.List<GroupResult> findAllMaxNotReached​(Batch batch)
        Searches the database for GroupResults that fit the criteria: 1) are in the given batch, 2) are in state STARTED, 3) where the activeMemberCount < Batch's maxActiveMembers, 3) activeMemberCount + historyMemberCount < Batch's maxTotalMembers. Additionally the results are ordered by the activeMemberCount (highest first) and as a secondary sorting criteria it orders by historyMemberCount (highest first). We use a PESSIMISTIC_WRITE lock to let GroupResults always have the current activeMemberCount and historyMemberCount.
      • updateGroupSession

        public java.lang.Long updateGroupSession​(java.lang.Long groupResultId,
                                                 java.lang.Long expectedVersion,
                                                 java.lang.String sessionData)
        Atomically updates groupSessionData and increments groupSessionVersion, but only if the current version matches the expectedVersion (compare-and-set).
        Returns:
        The new groupSessionVersion if the update succeeded (exactly one row updated), null if the version mismatched