0
Hello! I have a conceptual question. I have a method readDao(table) within the Object (access to the database) that returns a Hashset called resultRead with all objects in the database of that table. I also have a method insertRule(Object obj) within an Objectrule(business rule), which executes an Objectdao method, after the following verification:
if (!resultadoRead.contains(obj)) {
// executa a inserção do objeto no banco de dados.
ObjectDAO.insertDAO(obj);
}
My question is: For contains to work, do I need to implement the hashset and equals in the Object or DAO class? because in the DAO class, there are no attributes, only methods. Attributes belong to the Object.
Do I use inheritance? another way of checking? I abandon java because this question is very stupid?
Perhaps duplicate of How the equals method works?
– user28595
Other: How to override equals method?
– user28595
Related:How important it is to implement the hashcode method in Java?
– user28595