Announcement Announcement Module
Collapse
No announcement yet.
Problem with spring and hibernate Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Problem with spring and hibernate

    I'm currently making a prjet with spring hibernate strust, I have set the configuration file by adding spring and <context:annotation-config/> <context:component-scan base-package="classedao" but /> spring did not do dependency injection.
    Here is my code:

    Applicationcontext.xml
    <beans>
    .....................

    <tx:annotation-driven transaction-manager="transactionManager" />



    <context:component-scan base-package="clientDao" />
    <context:component-scan base-package="clientService" />
    <context:annotation-config />
    <beans>
    DAO
    @Repository("clientDaoImp")
    @Component
    public class ClientDaoImpl implements InterfaceDao {

    SessionFactory sessFact = HibernateUtil.getSessionFactory();
    Session sess = sessFact.getCurrentSession();

    @Override
    public void save(Object inst) {

    org.hibernate.Transaction tr = sess.beginTransaction();
    sess.save(inst);
    tr.commit();
    System.out.println("Successfully inserted");
    sessFact.close();

    }
    Service
    @Service
    public class ClientInterfaceImpl implements InterfaceService {

    @Autowired
    ClientDaoImpl clientDaoImp;



    @Transactional
    @Override
    public void save(Object inst) {

    Client cl = (Client) inst;
    clientDaoImp.save(cl);
    }

  • #2
    resolved

    Comment

    Working...
    X