[jboss-user] [JBoss/Spring Integration] - Problem persisting data using Spring + Hibernate JPA

suneetshah do-not-reply at jboss.com
Sun Mar 25 00:23:03 EDT 2007


I am getting the following exception when I try to insert a record into mysql. I am using Spring 2.03 with Hibernate JPA. I have pasted my code below and the config files.

Any help would be greatly appreciated.


---- service class ----

public class ServiceMgr {

protected ServiceDAO serviceDao;
public ServiceMgr() { 	}
public ServiceMgr(ServiceDAO serviceDao) {
	this.serviceDao = serviceDao;

public Service getService(String id) {
		return serviceDao.findById(id);

@Transactional( propagation = Propagation.REQUIRED, readOnly = false )
  public void addService(Service serv)  {

---- DOA Impl class ----

public class ServiceDAOBean implements ServiceDAO {

 private static final Log log = LogFactory.getLog(ServiceDAOBean.class);

	private EntityManager entityManager;
	private EntityManagerFactory emf;

    public void setEntityManager(EntityManager em) {
    	entityManager = em;
    public void setEntityManagerFactory(EntityManagerFactory emf) {
    	this.emf = emf;
@Transactional( propagation = Propagation.REQUIRED, readOnly = false )
	public void persist(Service transientInstance) {
		log.debug("persisting Service instance");
		try {
			log.debug("persist successful");
		} catch (RuntimeException re) {
			log.error("persist failed", re);
			throw re;

---- Spring applicationContext.xml ----
<beans xmlns="http://www.springframework.org/schema/beans"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
    					http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd
    					http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd">

		<constructor-arg ref="serviceDAO"></constructor-arg>



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

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4031362#4031362

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4031362

More information about the jboss-user mailing list