Note that there are some explanatory texts on larger screens.

plurals
  1. POSpring Hibernate two different DAO connections
    primarykey
    data
    text
    <p>I have one common project that is dependent to an application called application1. I configured in this way the xmls that each project has a distinct jdbc properties file ( different filename ), which directs to different database. Postgres and MySQL. I created the following snippet:</p> <pre><code>@RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(locations = {"/applicationContext.xml", "/common-applicationContext.xml"}) @Transactional public class AppTest extends AbstractTransactionalJUnit4SpringContextTests{ static Logger log = Logger.getLogger(App.class.getName()); @Resource(name = "testDao") private IDAO dao;//Traces testDao, which originates in common package @Resource(name = "testApplication1Dao") private IDAO daoApplication1;//Traces dao from application1 package @Test public void AppContextTest(){ SessionFactory sf1 = dao.getHibernateTemplate().getSessionFactory(); SessionFactory sf2 = daoApplication1.getHibernateTemplate().getSessionFactory(); </code></pre> <ol> <li>The classes TestDao and TestApplication1Dao, are extending IDAO. Common interface.</li> <li>testApplication1Dao->Postgres, configured in applicationContext.xml and in pgsql.jdbc.properties</li> <li>testDao->Mysql, configured in common-applicationContext.xml and in mysql.jdbc.properties.</li> </ol> <p>Why debugging with eclipse, I see that dao and daoApplicatio1 are same objects? Should they? How can I print on screen, the connections and properties behind each of the dao objects?</p> <p>Thanks in advance</p> <p><strong>EDIT(1)</strong></p> <p>From common project:</p> <pre><code>import org.springframework.stereotype.Repository; @Repository("testDao") public class TestDao extends AbstractDao {} </code></pre> <p>From application1 project:</p> <pre><code>import org.springframework.stereotype.Repository; import gr.org.infrastructure.common.db.AbstractDao; @Repository("testApplication1Dao") public class TestApplication1Dao extends AbstractDao {} </code></pre> <p>and the AbstractDao is an extension of IDAO ( interface ), nothing bizzare...:</p> <pre><code>@Transactional(propagation=Propagation.REQUIRED) public abstract class AbstractDao implements IDAO { private HibernateTemplate hibernateTemplate; private boolean rollbacked; public AbstractDao() { super(); this.rollbacked = false; // TODO Auto-generated constructor stub } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload