2

I have this question that's been bugging me all day. I have a function like this:

public void voidUsersByUserId(List<Integer> userIds) {
    Query query = getHibernateTemplate().getSessionFactory().getCurrentSession()
            .createSQLQuery("...")
            .setParameter("...",...)

    query.executeUpdate();
}

That I don't know where to put in my web application. I'm struggling with figuring out a good MVC location to put this.

This looks and begs to be put in the Users model, but it involves SQL. Is that a bad thing to make the model aware of the database it's residing on? Is it ok to have something like a UserAction.class that contains SQL scripts and other database related things that would deal with the Users table? The above function would be re-used in a variety of places, so modularity and testability are important.

Thanks!

Waffles
  • 97
  • 2
  • see also: [Staying OO and Testable while working with a database](http://programmers.stackexchange.com/questions/42792/staying-oo-and-testable-while-working-with-a-database) – gnat Apr 13 '15 at 09:50

0 Answers0