views:

20

answers:

1

I have the following class defined as a bean:

@Repository("userDao")
public class UserDao extends JdoDaoSupport implements IUserDao {...}

The class JdoDaoSupport requires a persistenceManagerFactory injected into it.

I've declared the persistenceManagerFactory bean in XML, how do I inject it to my superclass using annotations?


JdoDaoSupport class (snipped):

public abstract class JdoDaoSupport extends DaoSupport {
   public final void setPersistenceManagerFactory
                           (PersistenceManagerFactory persistenceManagerFactory) {
   this.jdoTemplate = createJdoTemplate(persistenceManagerFactory);
}
A: 

I finally came across a good recommendation. It is to not use JdoDaoSupport, this is only used in cases when it's absolutely necessary (as it ties your class to the spring framework). Instead just dependency inject the PersistenceManagerFactory into your class, thus negating the benefit of extending JdoDaoSupport.

David Parks