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 8256375
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T01:50:46+00:00 2026-06-08T01:50:46+00:00

I created a basic Spring MVC / JPA / Hibernate app. I am trying

  • 0

I created a basic Spring MVC / JPA / Hibernate app. I am trying to save a UserProfile entity to test if I can actualy persist it, but nothing gets saved and no exception is thrown either.

In the controller method I create a simple UserProfile (which is an @Entity) and I am sending that to a service method. The UserProfileServiceImpl class is annotated with @Service and the addUserProfile(UserProfile profile) method is annotated with @Transactional.

In the service method, all I do is call a DAO method (class annotated with @Repository). In the DAO method all I do is call entityManager.persist(object), with object being the user profile object.

  • Nothing gets written to the server log and the log level is at INFO.
  • Nothing appears in the Mysql query log (and I know the query log works)
  • The entityManager gets properly injected.
  • The datasource is properly initiated, because when I enter faulty credentials I get SQLExceptions.

I hope you can tell me what’s wrong. I’ll post some of my code and config files below.

The service method:

// The service method gets called from the controller. 
// Its class is annotated with @Service

@Transactional(readOnly = false)
public void addUserProfile(UserProfile userProfile) {
    userProfileDao.save(userProfile);
}

The Dao method:

// The save(T object) method is in the GenericDaoJpa class, which is the superclass
// of the UserProfileDaoJPA class that is referenced from the service.
// I have established that the entityManager is there and the object is a
// UserProfile. The @Repository annotation is on the child class UserProfileDaoJpa.

public void save(T object) {
    entityManager.persist(object);
}

Main application-context.xml

<context:property-placeholder location="classpath*:**/*.properties"/>
<import resource="spring-jpa.xml"/>

The application-context-web.xml file

<mvc:annotation-driven />
<context:component-scan base-package="nl.codebasesoftware.produx" />

<bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
    <property name="prefix" value="/WEB-INF/views/"/>
    <property name="suffix" value=".jsp"/>
</bean>

spring-jpa.xml

<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close" p:driverClassName="${db.driverClassName}"
      p:url="${db.url}" p:username="${db.username}" p:password="${db.password}"/>

<bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"
      p:dataSource-ref="dataSource"/>

<bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager"
      p:entityManagerFactory-ref="entityManagerFactory"/>

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

<bean id="defaultLobHandler" class="org.springframework.jdbc.support.lob.DefaultLobHandler"/>

persistence.xml

<persistence-unit name="mysqlPersistenceUnit" transaction-type="RESOURCE_LOCAL">
    <provider>org.hibernate.ejb.HibernatePersistence</provider>
    <properties>
        <property name="hibernate.dialect" value="org.hibernate.dialect.MySQL5InnoDBDialect"/>
        <property name="hibernate.hbm2ddl.auto" value="create-drop"/>
    </properties>
</persistence-unit>

<!-- Needed to properly process @PersistenceContext -->
<bean class="org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor"/>

Somehow no SQL is sent to Mysql with this setup, but no exception is thrown either, so I have no idea what’s going on. Hope you can help 🙂

  • 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-06-08T01:50:48+00:00Added an answer on June 8, 2026 at 1:50 am

    i think you are missing transaction propagation at service. marking readonly=false just set session to auto flush. but setting up proper transaction propogation will make sure start of trnasaction and commit/rollback.

    after removing mode=”aspectj” it has started working because i think because of as per spring doc

    The default mode “proxy” will process annotated beans to be proxied
    using Spring’s AOP framework (following proxy semantics, as discussed
    above, applying to method calls coming in through the proxy only). The
    alternative mode “aspectj” will instead weave the affected classes
    with Spring’s AspectJ transaction aspect (modifying the target class
    byte code in order to apply to any kind of method call). AspectJ
    weaving requires spring-aspects.jar on the classpath as well as
    load-time weaving (or compile-time weaving) enabled. (See the section
    entitled Section 6.8.4.5, “Spring configuration” for details on how to
    set up load-time weaving.)

    and probably you have not configured load time weaving

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

Sidebar

Related Questions

Starting my way with STS and created a new basic Hello World Spring MVC
I am trying to follow the basic tutorial for Spring MVC but got lost
I'm trying to write a Spring configuration for some basic Google App Engine services.
I have created a basic Spring 3.1 - Hibernate 4 - Mysql 5.5 web
I am trying to get latitude and longitude of user. I created a basic
I'm trying to learn about grails with Google App Engine and JPA by following
I've been making some very basic MVC views to save some data. To date
This seems like it's basic Spring 101 stuff, but I can't seem to find
I am just working on a basic webapp that implements spring + hibernate entitymanager
I am currently learning Spring. So far I have created a basic application consisting

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.