Ahoj.

Zapasim so spring + hibernate + deklarativnymi transakciami. V projekte mam niekolko DAO tried, ktore dedia od spolocnej triedy DaoBase spolocne veci ( session factory, template atd... ).

Beany su vsetky autowired, pouzivam component-scan.

@Component
public class DAOBase implements Serializable {

    protected HibernateTemplate hibernate;

    protected JdbcTemplate jdbc;

    protected SessionFactory sessionFactory;

  // @Autowired settre

}

@Component
public class DaoA extends DAOBase {

    //@Autowired
    private DaoB daob;

    //@Autowired
    public void setDaoB(DaoB db) {
        this.daob = db;
    }

}

... DaoB, ... DaoC, ... DaoD ...

Pokym nezapnem transakcie, autowiring funguje, tzn. bean DaoA ma nasetovane
vsetky zdedene atributy ( hibernate, jdbc, sessionFactory ) aj referenciu na DaoB. Funguje setter-injection aj attribute-injection, projekt normalne nabehne a funguje.

Problem nastane v momente, ked zapnem
<tx:annotation-driven transaction-manager="transactionManager"/>.

Vtedy zacne lietat vynimka "IllegalArgumentException: argument type mismatch" a tvrdi, ze:

"Error creating bean with name 'daoA':
Injection of autowired dependencies failed;
nested exception is org.springframework.beans.factory.BeanCreationException:
Could not autowire method: public void cz.test.DaoA.setDaoB(cz.test.DaoB);
nested exception is java.lang.IllegalArgumentException: argument type mismatch"

Predpokladam, ze to bude sposobene tym, ze samotne zapnutie transakcii sposobi, ze DaoA sa stane proxy a kontext uz potom nevidi ten setter. Otazne vsak je, ako to elegantne vyriesit.

Pokusne som zrusil dedicnost DaoBase->DaoA, ale problem nadalej trva.
Zvlastne je, ze ked si spravim malinky pidi-projekt s dvomi bean-ami a transakciami, tak to funguje, takze problem mozno ani priamo nesuvisi s DaoA/DaoBase, ale je niekde skryty.

Nezapasil ste niekto s niecim podobnym?

--
Diky

D

Odpovedet emailem