Confusion regarding adding fields in DAO & implementing the Runnable interface
posted 7 years ago
Hello, I am new to Hibernate & really having great trouble in understanding some issues.
My questions are:
i) Suppose I add some extra methods & fields in a particular DAO class & for some rows of the corresponding table I instantiate the Class & put them in some kind of collection. Now if I call the load() or get() method, does the system get the unique object already present in the system & stored in my collection or does it again instantiate the class from the table? Because in the first case I get the values which I put in my custom added fields which are not in the table & in the later case the custom added fields contain default values.
ii) Also I have to make the Class implement the Runnable interface since I have to store the objects of the class in some collection as tasks & periodically submit them to a thread pool (java.util.concurrent.ThreadPoolExecutor) for execution. Is this implementation going to hamper the normal working of Hibernate?
iii) It would really be better if I could extend the DAO class instead of making changes into it directly & have Hibernate create objects of it instead of the parent class. (For example I have Person table so there is a Person DAO class, I extend it in the SpecialPerson class & want Hibernate to make objects of SpecialPerson class directly). If it is possible then what are the changes that are needed to be done in the xml files or in some other files?