Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6914087
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T09:18:09+00:00 2026-05-27T09:18:09+00:00

i have the following problem. I use Spring and JPA (Hibernate) to persist Data

  • 0

i have the following problem. I use Spring and JPA (Hibernate) to persist Data in a Database.
But i have an Error during saving the Data. My Database keeps empty after I create a new User. Here are the important files:

UserDao Interface:

import java.util.List;

public interface UserDao {
    public User findById(Integer id);
    public List<User> findAll();
    public User findByEmail(String email);
    public void save(User user);
}

UserDaoImpl:

@Repository
public class UserDaoImpl implements UserDao {

     @PersistenceContext
     private EntityManager em;

     @Override
     public User findById(Integer id) {
         return em.find(User.class, id);
     }

     @SuppressWarnings("unchecked")
     @Override
     public List<User> findAll() {
         return (List<User>)em.createQuery("from User u").getResultList();
     }

     @Override
     public User findByEmail(String email) {
         User user = null;
         try
         {
             user =  (User)em.createQuery("from User u where u.email = ?1").setParameter(1, email).getSingleResult();
         }
         catch(NoResultException e){}
         return user;
     }

     @Override
     @Transactional
     public void save(User user) {
         em.persist(user);
     }
}

Context.xml

 <?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:context="http://www.springframework.org/schema/context" xmlns:jee="http://www.springframework.org/schema/jee" xmlns:lang="http://www.springframework.org/schema/lang" xmlns:tx="http://www.springframework.org/schema/tx" xmlns:util="http://www.springframework.org/schema/util" 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/context  http://www.springframework.org/schema/context/spring-context-3.0.xsd http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-3.0.xsd http://www.springframework.org/schema/lang http://www.springframework.org/schema/lang/spring-lang-3.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.0.xsd" default-autowire="byName">

<context:component-scan base-package="de.bht.swp.lao.ocp" />
<context:annotation-config />

<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
    <property name="username" value="root" />
    <property name="password" value="root" />
    <property name="driverClassName" value="com.mysql.jdbc.Driver" />
    <property name="url" value="jdbc:mysql://localhost/ocp" />
</bean>

<bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
    <property name="persistenceUnitName" value="ocpPU" />
    <property name="dataSource" ref="dataSource"/>
    <property name="jpaVendorAdapter">
    <bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
         <property name="showSql" value="true" />
         <property name="generateDdl" value="true" />
         <property name="databasePlatform" value="org.hibernate.dialect.MySQL5InnoDBDialect" />
    </bean>
    </property>
    <property name="loadTimeWeaver" ref="loadTimeWeaver"></property>
</bean>

<bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager" >
    <property name="entityManagerFactory" ref="entityManagerFactory" />
</bean>

<tx:annotation-driven transaction-manager="transactionManager" proxy-target-class="true"/>

<context:load-time-weaver weaver- class="org.springframework.instrument.classloading.InstrumentationLoadTimeWeaver"/>

</beans>

persistence.xml

<?xml version="1.0" encoding="UTF-8"?>
    <persistence version="1.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"> 
    <persistence-unit name="ocpPU">
</persistence-unit>

When i create a new User i get the following Errorlog:

14:42:05,703 DEBUG [org.hibernate.event.def.AbstractSaveEventListener] - delaying identity-insert due to no transaction in progress
14:42:05,704 DEBUG [org.springframework.orm.jpa.EntityManagerFactoryUtils] - Closing JPA EntityManager
14:42:05,707 DEBUG [org.springframework.web.servlet.DispatcherServlet] - Rendering view  [org.springframework.web.servlet.view.RedirectView: unnamed; URL [/user/login.htm]] in   DispatcherServlet with name 'dispatcher'
 14:42:05,708 DEBUG [org.springframework.web.servlet.DispatcherServlet] - Successfully completed request

I think its a Trancation Error.
I´v already spent so much time in other channels. What means “delaying identity-insert due to no transaction in progress”?

thanks for the help beforehand
greeting

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T09:18:10+00:00Added an answer on May 27, 2026 at 9:18 am

    The problem is the @Repository in UserDaoImpl, remove it and make a bean

    <bean id="userDao" class="de.bht.swp.lao.ocp.user.UserDaoImpl" />
    

    in your Context.xml

    I can’t explain this behavior but this is the reason.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Trying to use JSTL but have the following problem: Index.xhtml page: <?xml version=1.0 encoding=UTF-8?>
I have a problem on the following situation: In my Spring, Hibernate application I
I have the following problem: I need to use XSLFO to generate a 2-column
I have a JPA/Spring application that uses Hibernate as the JPA provider. In one
I'm new in Spring Framework (2.5.6) and I have Hibernate integration problem on Glassfish
I have a following problem with entity mapping in JPA. I have two entities,
I have the following setup. Spring 3.0.5 Hibernate 3.5.6 MySql 5.1 To save a
I have a problem with Spring Security 3 and probably with i18n. I use
I have a problem with changing my spring/hibernate application from MySql to SQL Server.
I am using Hibernate in Spring MVC 3.05 and an Oracle database. I have

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.