Hi Jooqers,

Given repository implementation something similar to below, I want to 
clarify on how it behaves at run time. 

1) Would this cause any concurrency issues with the query object that is 
cached in to the queryMap. 
*Note: *When we debugged the application we found out that bind() operation 
is creating a new object, so it shouldn't be issue if multiple threads are 
accessing the same queryMap. But would like to get a expert advice also :)
2) Please identify any other potential issues with the implementation?

=======================

@Slf4j
@Repository
public class UserRepository {

  private static final String GET_USER_DETAILS = "get-user-details";

  private UserDao userDao;

  private Map<String, Query> queryMap = new HashMap<>();

  @Autowired
  private DSLContext dsl;

  @PostConstruct
  public void init() {
    initializeQueries();
    this.userDao = new UserDao(dsl.configuration());
  }

  protected void initializeQueries() {

    SelectForUpdateStep<? extends Record> selectUser = dsl
        .select(USER.NAME, USER.EMAIL)
        .from(USER)
        .where(USER.ID.eq(DSL.param("userId")))
        .and(USER.IS_ACTIVE.eq(Boolean.TRUE));

    queryMap.put(GET_USER_DETAILS, selectUser);
  }

  public User getUserById(long userId) {
    SelectForUpdateStep<? extends Record> selectUserQuery = 
this.getQuery(GET_USER_DETAILS);
    return selectUserQuery
        .bind("userId", userId)
        .fetchOne().into(User.class);
  }
}

=======================

Thank you in advance.

Regards,
Venkat.

-- 
You received this message because you are subscribed to the Google Groups "jOOQ 
User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to