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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T03:21:01+00:00 2026-06-01T03:21:01+00:00

I have a web app using Hibernate, and I am attempting to persist some

  • 0

I have a web app using Hibernate, and I am attempting to persist some data, but it is failing to persist within a Transaction despite using the @Transactional annotation.

My service class is as follows:

@Service("profileService")
public class ProfileService {
    private EntityManager entityManager;

    @Autowired
    private AccountService accountService;

    @Autowired
    private ProfileDAOImpl profileDao;

    @PersistenceContext
    public void setEntityManager(EntityManager em) {
        this.entityManager = em;
    }

    @Transactional
    public void addConnectionToAccount(SocialConnection sc) {
        entityManager.persist(sc);
    }

}

The addConnectionToAccount() method is being called from another Spring bean in a normal method, and the ProfileService class is currently being injected there:

public class HibernateConnectionRepository implements ConnectionRepository {

    @Inject
    private ProfileService profileService;

    @Override
    @Transactional
    public void addConnection(SocialConnection sc) {
        try {
            profileService.addConnectionToAccount(accountId, sc);
        } catch (Exception e) {
            e.printStackTrace();
        }

    }

I tried putting the @Transactional annotation on the calling method in the vain hope that it might make a difference but nothing.

Previously I have experienced problems like this its been because the object being persisted does not satisfy table restrictions (such as non-nullable columns as null) or because the method is being called from within the same class and the calling method is not Transactional, but neither of those are the case here..

Any ideas? it just fails silently, the logs are as follows:

2012-03-26 22:25:04,702 [http-bio-8085-exec-9] DEBUG com.mchange.v2.resourcepool.BasicResourcePool - trace com.mchange.v2.resourcepool.BasicResourcePool@1bc25c8 [managed: 3, unused: 2, excluded: 0] (e.g. com.mchange.v2.c3p0.impl.NewPooledConnection@e5b006)
2012-03-26 22:25:04,710 [http-bio-8085-exec-9] DEBUG org.hibernate.SQL - select SEQ_COUNT from SEQUENCE where SEQ_NAME = 'PO_SEQ' for update
2012-03-26 22:25:04,711 [http-bio-8085-exec-9] DEBUG org.hibernate.SQL - update SEQUENCE set SEQ_COUNT = ? where SEQ_COUNT = ? and SEQ_NAME = 'PO_SEQ'
2012-03-26 22:25:04,723 [http-bio-8085-exec-9] DEBUG com.mchange.v2.resourcepool.BasicResourcePool - trace com.mchange.v2.resourcepool.BasicResourcePool@1bc25c8 [managed: 3, unused: 2, excluded: 0] (e.g. com.mchange.v2.c3p0.impl.NewPooledConnection@e5b006)
2012-03-26 22:25:04,723 [http-bio-8085-exec-9] DEBUG org.hibernate.event.internal.AbstractSaveEventListener - Generated identifier: 2200, using strategy: org.hibernate.id.MultipleHiLoPerTableGenerator

UPDATE

Also wanted to mention that the HibernateConnectionRepository bean is not annotated and is actually being configured in an @Configuration class (if this makes any difference? not used @Configuration classes much).

The method to create the bean is as follows:

@Bean
@Scope(value = "request", proxyMode = ScopedProxyMode.INTERFACES)
public ConnectionRepository connectionRepository() {
    Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
    if (authentication == null) {
        throw new IllegalStateException("Unable to get a ConnectionRepository: no user signed in");
    }
    ApplicationUser user = (ApplicationUser) authentication.getPrincipal();
    return usersConnectionRepository().createConnectionRepository(String.valueOf(user.getAccountId()));
}

The bean is scoped to the logged in user, but may also be created multiple times for each user..

  • 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-01T03:21:02+00:00Added an answer on June 1, 2026 at 3:21 am

    The error was a problem with the aspects not firing properly.

    Related to this problem: Let eclipse use maven to compile/weave my code that occurs using new versions of Eclipse and M2E.

    The Eclipse clean wasnt weaving the aspects, so the transactional annotations werent being woven. It obviosuly worked intermittently because when i did a normal maven clean install (command line etc) then the weaving would be done (the Eclipse clean then un-did the weaving, so if i did maven clean install then an eclipse re-build it would not work).

    I fixed this by adding an AspectJ builder to my project in Eclipse, and now when I run clean/build automatically it weaves it correctly.

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

Sidebar

Related Questions

I have a tomcat app using hibernate. When I go into the WEB-INF and
I have some questions about using Hibernate in JSP web application. What should be
I have a web app that gathers some data from the user and saves
I'm using Maven 2 and Hibernate for a Java web app. I have a
I have a web app using forms authentication and I have restricted a folder
I have developed a web app using a webservice. Everything works fine in the
I am working on a web app using C# and asp.net I have been
I am developing a web app using servlets and jsps. I have a question
I inherited this gigantic legacy Java web app using Struts 1.2.4. I have a
I inherited this gigantic legacy Java web app using Struts 1.2.4. I have a

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.