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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T17:24:39+00:00 2026-05-25T17:24:39+00:00

I have a UserProfile entity which I need to save. after saving the entity

  • 0

I have a UserProfile entity which I need to save. after saving the entity in the database, I get the following exception:

Could not commit Hibernate transaction; nested exception is org.hibernate.TransactionException: Transaction not successfully started

Also when I see the table the entity is persisted instead of doing a rollback!

@Transactional(isolation=Isolation.REPEATABLE_READ)
public class HibernateUserProfileDAO implements UserProfileDAO {
    private org.hibernate.SessionFactory sessionFactory;
    public UserProfile getUserProfile(int userId) {
        org.hibernate.classic.Session session = sessionFactory.getCurrentSession();
        session.beginTransaction();
        UserProfile userProfile = new UserProfile();
        userProfile.setUserName("sury1");
        session.save(userProfile);
        session.getTransaction().commit();
        session.close();
        return userProfile;
    }
}

I’m using hibernate transaction manager

<bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
    <property name="sessionFactory" ref="sessionFactory"/>
</bean>

and my hibernate config is:

<bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
    <property name="dataSource" ref="dataSource"/>
    <property name="packagesToScan" value="com.springheatmvn.domain"/>
    <property name="hibernateProperties">
        <props>
            <prop key="hibernate.connection.pool_size">10</prop>
            <prop key="hibernate.connection.show_sql">true</prop>
            <prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
            <prop key="hibernate.hbm2ddl.auto">update</prop>
        </props>
    </property>     
</bean>

Can anyone pl. tell me what’s going on here?

  • 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-25T17:24:40+00:00Added an answer on May 25, 2026 at 5:24 pm

    I think you’ve fall a victim of dual transaction managements. If you are using Spring Transaction Management and Hibernate Transaction Management together in the same project, you are more likely to have this issue.

    Your code then should either be:

    Option 1. Hibernate transaction management

    public class HibernateUserProfileDAO implements UserProfileDAO {
        private org.hibernate.SessionFactory sessionFactory;
        public UserProfile getUserProfile(int userId) {
            org.hibernate.classic.Session session = sessionFactory.getCurrentSession();
            session.beginTransaction();
            UserProfile userProfile = new UserProfile();
            userProfile.setUserName("sury1");
            session.save(userProfile);
            session.getTransaction().commit();
            session.close();
            return userProfile;
        }
    }
    

    or Option 2. Spring transaction Management

    @Transactional
    public class HibernateUserProfileDAO implements UserProfileDAO {
        private org.hibernate.SessionFactory sessionFactory;
        public UserProfile getUserProfile(int userId) {
            org.hibernate.classic.Session session = sessionFactory.getCurrentSession();
            UserProfile userProfile = new UserProfile();
            userProfile.setUserName("sury1");
            session.save(userProfile);
            session.close();
            return userProfile;
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have following model: class UserProfile(models.Model): User profile model, cintains a Foreign Key, which
I already have a database with about 20 fields of userprofile information. Im not
I have several TextField columns on my UserProfile object which contain JSON objects. I've
I need to have a UserProfile class that it's just that, a user profile.
I have a class UserProfile defined which takes the default user as a foreign
I have a form to edit a UserProfile which is stored in mysql db.
In my domain model I have following Classes.A 'UserProfile' has one 'SecurityPrincipal' class SecurityPrincipal{
I have the following model set up: class UserProfile(models.Model): Additional attributes for users. url
I have the following models -- class UserProfile(models.Model): user = models.ForeignKey(User, unique=True) ... class
I have the following models: class UserProfile(models.Model): user = models.OneToOneField(User) score = models.PositiveIntegerField() class

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.