开发者

which part of function should go in DAO layer and which in service layer

Initially I had the all the DAO in service layer. But to go the proper way i am making the separate DAO layer but i am little bit confused as to which things come in DAO and which in service layer

I had this function in service layer

public void confirmUser(String id)
{
      logger.debug("Confirming existing person");
      Session session = sessionFactory.getCurrentSessio开发者_JAVA百科n();
      String query = "FROM Registration WHERE uuid=:myuuid";
      Query query2 = session.createQuery(query);
      query2.setString("myuuid",id);
      Registration person = (Registration) query2.uniqueResult();
      person.setConfirmed(true);
      session.save(person);

}

Now i want to ask that does this same function go as it is in DAO function or something will remain in service layer as well


Generally your DAO would do the work for storing and retrieving the entities, while your service would do the business logic.

So confirmUser(id) would be on the service, and would do the call to setConfirmed(..) on the user.

The DAO would have getUserById(id) and saveOrUpdateUser(User) -- or something to that affect, depending upon your needs.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜