key « DAO « JPA Q&A





1. Get list by primary keys (plural) - Generic DAO    forum.hibernate.org

public List getListByPrimaryKey(Class clazz, String pkProperty, List keys) { Session ses = sessionFactory.getCurrentSession(); return ses.createCriteria(clazz) .add(Restrictions.in(pkProperty, keys)) ...

2. Where to check foreign key existance: DAO object or Service?    forum.hibernate.org

I have an UserDAO and an CountryDAO object. When I insert an User object into database, first I must check if the Country for that user exists in database (if nobody deleted it). If I check this in insertUser() method from UserDAO object, I must get a reference of CountryDAO object. This seems wrong to me, because I tight couple two ...