Reputation: 1043
is it like @Repository
or @Repository("DAOname")
?
which is appropriate? why?
and
one major doubt regarding update and delete method in DAO layer! Is it safe to have logics in DAO layer?
i mean, for eg: DAO layer
@Transactional
public void deleteMethod(List list)
{
for(list)
{
deleteNamedQuery(list);
}
}
Upvotes: 2
Views: 74
Reputation: 1043
Service Layer(put the Iterating logic in service )
@Override
public void deleteCheckedItems(List<Integer> selectdIdForDeletion, String userid) {
try
{
for(Integer id:selectdIdForDeletion)
{
dao.deleteMethod(id, userid); // called DAO method for delete
}
}catch(Exception e)
{
logger.info(e);
}
}
DAO Layer(removed the iterating delete logic )
@Transactional
public void deleteMethod(String id,String userid)
{
deleteNamedQuery(id,userid);
}
Upvotes: 0
Reputation: 8282
@Repository
public class UserDAO {}
in this case the bean if you perform a <context:component-scan base-package="your.package" />
will be named "userDAO"
@Repository("userRepository")
public class UserDAO {}
instead in this case will be named "userRepository". In few words are appropriate both solution, depends how you use it.
I suggest you not to add business logic within your DAO to maintain the Separation of Concern. See this link, in addition
A data access object (DAO) is an object that provides an abstract interface to some type of database or other persistence mechanism.
Upvotes: 3