Announcement Announcement Module
Collapse
No announcement yet.
Spring + Abstract DAO Factory pattern Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Spring + Abstract DAO Factory pattern

    Hello,

    How would I go about implementing the abstract DAO factory pattern using Spring's dependency injection. I have my beans set up as:

    Code:
    	<!--Dao (Data Access Object) for application. -->
    	<bean id="jobDAO"
    		class="com.myapp.dao.JobDAO">
    		<property name="sessionFactory">
    			<ref local="sessionFactory" />
    		</property>
    	</bean>
    
    	<!--Manager for Job Functionality-->
    	<bean id="jobManager" class="com.myapp.service.JobBO">
    		<property name="jobDAO">
    			<ref local="jobDAO" />
    		</property>
    	</bean>
    Where the JobDAO is an abstract DAO. However, how do I inject a specific implementation of say JobDAOOracleImpl into my JobBO instead? Would I create beans like this instead?

    Code:
    	<!--Oracle Job DAO -->
    	<bean id="jobDAOOracle"
    		class="com.myapp.dao.JobDAOOracleImpl">
    		<property name="sessionFactory">
    			<ref local="sessionFactory" />
    		</property>
    	</bean>
    
    	<!--MySQL Job DAO -->
    	<bean id="jobDAOMySQL"
    		class="com.myapp.dao.JobDAOMySQLImpl">
    		<property name="sessionFactory">
    			<ref local="sessionFactory" />
    		</property>
    	</bean>
    
    	<!--Manager for Job Functionality-->
    	<bean id="jobManager" class="com.myapp.service.JobBO">
    		<property name="jobDAOOracle">
    			<ref local="jobDAOOracle" />
    		</property>
    	</bean>
    And explicitly set which DAO implementation I want in applicationContext? What is the best practice for this?

  • #2
    Spring Integration with AbstractDAO pattern

    Any solution to the above issue.??. I am also facing the similar issue. Could somebody help to resolve this issue

    Comment

    Working...
    X