Spring MVC i dobre praktyki

0

Kochani! Poradźcie jak to powinno być...
Piszę sobie aplikacje MVC w Springu i mam dwa głupie pytanka...

  1. Czy w servisach odwoływać się przez DAO czy serwisy do innych obiektów?
  2. Gdzie stosować annotacje @Transaction? Czy mogę stosować to gdzie chce - n.p. w metodach kontrolerów czy budować ekstra metody w serwisach objęte tą annotacją?

Pozdrawiam

Krzysiek

0

Na http://forum.springsource.org/ użytkownik csergiu77 mi odpowiedział tak:

You can use @Transactional at the business service layer.

It will not create any problem if you will have it on DAO layer as well cause then it will reuse the existing transaction if you don;t specify other or it will create a new transaction.

Regarding placing the DAO or the service it is up to you . I would use the second version using two DAO's but that is more related to the logic you want to use.If you need a bussines method in the other service use wire the service otherwise use the DAO for plain data access.

Znaczy się dalej głupi jestem i nic nie wiem :)

1 użytkowników online, w tym zalogowanych: 0, gości: 1