Package daos.common
Class GroupResultDao
- java.lang.Object
-
- daos.common.AbstractDao
-
- daos.common.GroupResultDao
-
@Singleton public class GroupResultDao extends AbstractDao
DAO for GroupResult
-
-
Field Summary
-
Fields inherited from class daos.common.AbstractDao
jpa
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.IntegercountByBatch(Batch batch)GroupResultcreate(GroupResult groupResult)java.util.List<GroupResult>findAllByBatch(Batch batch)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.GroupResultfindById(java.lang.Long id)voidrefresh(GroupResult groupResult)voidremove(GroupResult groupResult)voidupdate(GroupResult groupResult)java.lang.LongupdateGroupSession(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).
-
-
-
Method Detail
-
create
public GroupResult create(GroupResult groupResult)
-
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
-
-