Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- août 11, 2016 4:13:51 PM org.springframework.context.support.ClassPathXmlApplicationContext prepareRefresh
- INFOS: Refreshing org.springframework.context.support.ClassPathXmlApplicationContext@68de145: startup date [Thu Aug 11 16:13:51 CEST 2016]; root of context hierarchy
- août 11, 2016 4:13:51 PM org.springframework.beans.factory.xml.XmlBeanDefinitionReader
- <?xml version="1.0" encoding="UTF-8"?>
- <beans xmlns="http://www.springframework.org/schema/beans"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xmlns:aop="http://www.springframework.org/schema/aop"
- xmlns:tx="http://www.springframework.org/schema/tx"
- xmlns:context="http://www.springframework.org/schema/context"
- xsi:schemaLocation="
- http://www.springframework.org/schema/beans
- http://www.springframework.org/schema/beans/spring-beans.xsd
- http://www.springframework.org/schema/tx
- http://www.springframework.org/schema/tx/spring-tx.xsd
- http://www.springframework.org/schema/aop
- http://www.springframework.org/schema/aop/spring-aop.xsd
- http://www.springframework.org/schema/context
- http://www.springframework.org/schema/context/spring-context.xsd">
- <context:component-scan base-package="Dao"></context:component-scan>
- <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
- <property name="driverClassName" value="com.mysql.jdbc.Driver"/>
- <property name="url" value="jdbc:mysql://localhost:3306/project?useSSL=false"/>
- <property name="username" value="root"/>
- <property name="password" value=""/>
- </bean>
- <bean id="factory" class="org.springframework.orm.hibernate5.LocalSessionFactoryBean">
- <property name="dataSource" ref="dataSource"/>
- <property name="hibernateProperties">
- <props>
- <prop
- key="hibernate.dialect">org.hibernate.dialect.MySQL5Dialect</prop>
- <prop key="hibernate.show_sql">true</prop>
- </props>
- </property>
- <property name="annotatedClasses">
- <list>
- <value>Dao.ActionDao</value>
- <value>mapping.Action</value>
- </list>
- </property>
- </bean>
- <bean id="transactionManager"
- class="org.springframework.orm.hibernate5.HibernateTransactionManager">
- <property name="sessionFactory" ref="factory"/>
- </bean>
- <tx:annotation-driven transaction-manager="transactionManager"/>
- </beans>
- package Dao;
- import java.util.List;
- import org.hibernate.Criteria;
- import org.hibernate.Session;
- import org.hibernate.SessionFactory;
- import org.hibernate.cfg.Configuration;
- import org.hibernate.criterion.Restrictions;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.stereotype.Repository;
- import org.springframework.transaction.annotation.Transactional;
- import mapping.Action;
- @Repository
- @Transactional
- public class ActionDao {
- private SessionFactory factory;
- public Action getById(int id)
- {Session session=factory.getCurrentSession();
- return (Action) session.get(Action.class, id);
- }
- @SuppressWarnings("unchecked")
- public List<Action> selectAll(){
- List<Action> theActions = factory.getCurrentSession().createQuery("from Action").getResultList();
- return theActions;
- }
- public void saveorupdate(Action contact)
- {
- factory.getCurrentSession().saveOrUpdate(contact);
- }
- public void delete(int id)
- {
- Action c = getById(id);
- factory.getCurrentSession().delete(c);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement