private static final String USER_ID = "INSERT_USER_ID_HERE";
public static void runExample(DfpServices dfpServices, DfpSession session, long userId)
throws Exception {
// Get the UserTeamAssociationService.
UserTeamAssociationServiceInterface userTeamAssociationService =
dfpServices.get(session, UserTeamAssociationServiceInterface.class);
// Create a statement to select all user team associations for a user.
StatementBuilder statementBuilder = new StatementBuilder()
.where("WHERE userId = :userId ")
.orderBy("userId ASC, teamId ASC")
.limit(StatementBuilder.SUGGESTED_PAGE_LIMIT)
.withBindVariableValue("userId", userId);
// Default for total result set size.
int totalResultSetSize = 0;
do {
// Get user team associations by statement.
UserTeamAssociationPage page = userTeamAssociationService.getUserTeamAssociationsByStatement(
statementBuilder.toStatement());
if (page.getResults() != null) {
totalResultSetSize = page.getTotalResultSetSize();
int i = page.getStartIndex();