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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T13:26:55+00:00 2026-06-04T13:26:55+00:00

My application is written in Seam(2.2.1.CR2) and in a recent update I implemented a

  • 0

My application is written in Seam(2.2.1.CR2) and in a recent update I implemented a field called points for my User entity. This field should hold points aggregated from a numerous other fields and actions, so since I have a database with tons of users I thought that updating these users on the fly would be a good idea. I did this by assigning the new column in the User entity to -1 and then whenever getPoints is invoked throw an Event and update the points, but only one time.

@Entity(name = "User")
public class User {

@Column(nullable = false, columnDefinition = "int(11) default -1")
    private int points;

public int getPoints() {
        if (points == -1) {
            Events.instance().raiseEvent(AppreciatedInitialUpdate.EVENT_NAME, this);
        }
        return points;
    }
}

I then created a pointsBean:

@Name("pointsBean")    
@AutoCreate
public class PointsBean implements Serializable, AppreciatedInitialUpdate {

    @Logger
    private Log log;

    @In
    EntityManager entityManager

    @Observer(AppreciatedInitialUpdate.EVENT_NAME)
    public void handleAppreciatedInitialUpdate(User User) {
        this.calculateInitialPoints(user);
    }

    private void calculateInitialPoints(User user) {

        int likes = 0;

        List<Flag> appreciateFlags = user.getAppreciateFlags();
        likes = appreciateFlags.size();

        user.setLikes(likes);
        entityManager.merge(user);
        log.info("Initial update of points for user " + user.getId() + ". Now he/she has " + points);
    }           
}

But as my title states when doing like this the entity is not persisted and if I flush then i get an Exception:

[org.hibernate.LazyInitializationException] could not initialize proxy - no Session
org.hibernate.LazyInitializationException: could not initialize proxy - no Session
    at org.hibernate.proxy.AbstractLazyInitializer.initialize(AbstractLazyInitializer.java:62)
    at org.hibernate.proxy.AbstractLazyInitializer.getImplementation(AbstractLazyInitializer.java:116)
    at org.hibernate.proxy.pojo.javassist.JavassistLazyInitializer.invoke(JavassistLazyInitializer.java:166) 

I’m probably missing something crucial here. What am I doing wrong?

// Jakob

  • 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-04T13:26:57+00:00Added an answer on June 4, 2026 at 1:26 pm

    Probably the user variable was retrieved from the database in an older session, that was already closed, so when you call user.getAppreciateFlags();, that is probably a LAZY database reference, it tries to retrieve them from the database, and since the session is closed, that error happens.

    One quick fix (not sure if its the best one), is to merge the user in the session before the getAppeciateFlags call, so the code will be:

    entityManager.merge(user);
    List<Flag> appreciateFlags = user.getAppreciateFlags();
    likes = appreciateFlags.size();
    user.setLikes(likes);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this application written in JSF 2.0 facelets and it has the following
I have Windows application written in VB 2010.Here, user may select any file from
I've written an e-commerce web application using Seam 2.2, JPA, and JSF that, of
I have written a few Drools rules for my Seam application and am wondering
We have an application written in C language which interacts with Oracle database. This
I have written an application using Seam 2.2.1 & MySQL which is working. I
I have a large application written using .Net remoting for file transfer. This was
I have an application written using C++ Builder 5 that uses the TDocument class.
I have an application written in pure/basic Java without GUI. I have three classes
I have a web application written in ASP.NEt/C# and javascript. It uses session variables.

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.