hi,
I have a table CompanyList in my Oracle database :
CMP_ID INTEGER -- ID of company
CMP_NAME VARCHAR2 -- name of company
USR_ID INTEGER -- Foreign key to the USERS table
i have my Spring 3 MVC app all configured using annotations, my POJOs as well , my DAO objects (CompanyDao) using hibernate to retrieve for exemple a list of companies.
CompanyDao :
@Transactional
public Set<Company> findAllCompanys() throws DataAccessException {
return findAllCompanies(-1, -1);
}
@SuppressWarnings("unchecked")
@Transactional
public Set<Company> findAllCompanies(int startResult, int maxRows) throws DataAccessException {
Query query = createNamedQuery("findAllCompanies", startResult, maxRows);
return new LinkedHashSet<Company>(query.getResultList());
}
And my company domain :
@Entity
@NamedQueries( {
@NamedQuery(name = "findAllCompanies", query = "select myCompany from Company myCompany")})
...
public class Company implements Serializable {
...
Then I setup spring security, so all my pages require identification.
What is the best way to filter the rows returned by CompanyDao, using the USER ID of the current logged in user session ?