So here is my problem. I have two beans (one extends the other), and I have one DAO class for each to access their tables (using Hibernate). In most cases the queries will be identical so I also have an abstract DAO class (extended by the other two DAOs) which contains the majority of the queries. I had the methods returning beans of the super class which, if need be, I would cast to the subclass. To avoid this casting I want to switch to generics. I changed over the abstract class with no compiliation erros, but I've hit a bump. In the two beans I have a static String field "entityName" which I access to for the Hibernate calls (Bean.entityName). When I converted to generics the reference changed to T.entityName which now always references the super class. What I need is to access whichever class' entityName I happen to be using.
No matter what I set as AbstractBeanDAO <type> it always references SuperBean.entityName. There are times I need SubBean.entityName so I can access the correct table. How can I do this without having to duplicate code in the two DAO subclasses?