Spring Security + Hibernate Annotation Example

In this tutorial, previous Spring Security + Hibernate4 XML example will be reused, and convert it to a annotation-based example. Technologies used : Spring 3.2.8.RELEASE Spring Security 3.2.3.RELEASE Hibernate 4.2.11.Final MySQL Server 5.6 Tomcat 7 (Servlet 3.x container) Quick Note : Create a session factory with LocalSessionFactoryBuilder Inject session factory into a UserDao Integrate UserDao …

Read more

Spring Security + Hibernate XML Example

In this tutorial, we will show you how to integrate Hibernate 4 in Spring Security, XML configuration example. Note For annotation version, please read this Spring Security + Hibernate Annotation Example. Technologies used : Spring 3.2.8.RELEASE Spring Security 3.2.3.RELEASE Hibernate 4.2.11.Final MySQL Server 5.6 JDK 1.6 Maven 3 Eclipse 4.3 Quick Notes Create a session …

Read more

ClassNotFoundException: org.aspectj.weaver.reflect.ReflectionWorld$ReflectionWorldException

Spring + Hibernate4 integration, and transaction are managed by Spring AOP, example : spring-hibernate.xml <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" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd"> <bean id="txManager" class="org.springframework.orm.hibernate4.HibernateTransactionManager"> <property name="sessionFactory" ref="sessionFactory"></property> </bean> <tx:advice id="txAdvice" transaction-manager="txManager"> <tx:attributes> <tx:method name="get*" read-only="true" /> <tx:method name="*" /> </tx:attributes> </tx:advice> <aop:config> <aop:pointcut id="userDaoPointCut" expression="execution(* com.mkyong.users.service.*Dao.*(..))" /> <aop:advisor advice-ref="txAdvice" pointcut-ref="userDaoPointCut" /> …

Read more

Spring + Hibernate : No Session found for current thread

Integrates Spring 3 and Hibernate 4, the system shows the following message while performing database operation : org.hibernate.HibernateException: No Session found for current thread The sessionFactory is injected like this : spring-hibernate4.xml <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd"> <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/test" /> <property name="username" value="root" /> <property name="password" …

Read more