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

  • Home
  • SEARCH
  • 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 6121207
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T15:45:29+00:00 2026-05-23T15:45:29+00:00

I am working on a project using the Play!Framework, and I an encoutering some

  • 0

I am working on a project using the Play!Framework, and I an encoutering some issues with JPA. It seems that it doesn’t save my List, or doesn’t manage to retrieve it from the DB.

Here is my User class :

@Entity
public class User extends Model {
    public String login;
    public String password;
    public String name;
    public String email;
    @ElementCollection
    public List<Long> eventStreamIds;
    @Transient
    UserEventBuffer eventBuffer;

    public User(String login, String password, String name, String email, ArrayList<Long> eventStreamIds) {
        this.login = login;
        this.password = password;
        this.name = name;
        this.email = email;
        this.eventStreamIds = eventStreamIds;
            UserEventBuffer eventBuffer = new UserEventBuffer();
        }
}

I have another class, a ModelManager, which constructor is as following :

public ModelManager() {
    User u = new User("user1", "pwd", "Alex", "test@test.com");
    EventStreamMC eb = new EventStreamMC("http://www.wservice.com/stream1");
    streams.add(eb);
    u.eventStreamIds.add(eb.id);
    Logger.info("before : " + u.eventStreamIds.size());
    u.save();
    User u2 = User.find("byLoginAndPassword", "user1", "pwd").first();
    Logger.info("after : " + u2.eventStreamIds.size());
}

(My EventStreamMC also extends Model and has an @Entity tag, so its Long id is automatically generated)
When i run this code, here is the result :

before = 1
after = 0

So the List is empty after the call to the find() method.

How can I make it work ?

  • 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-23T15:45:29+00:00Added an answer on May 23, 2026 at 3:45 pm

    ID are generated only on save and eb is never saved in your code. ed.id will be empty when you add it to your list.

    EDIT :

    I’ll go a little further in my explanations.

    The first logger is returning 1 since it is a Java List Object. It is a plain list, you add an element and the size increases. No surprises, here. Plain java. And absolutly nothing to do with Play!.

    Second logger is not displaying anything since ID are generated on commit precisly. And since, you are still in the same transaction, no save is performed until the very end of the execution. If you really want this to work in the same http request/transaction, use this :

    Model.em().getTransaction().commit();
    

    For more information, check out official Play documentation on Transactions.

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

Sidebar

Related Questions

I'm working on an iOS application that needs to play some sounds using the
I'm working on a project using Windows 2008, .NET 3.5 and WCF for some
I am working on a project using Hadoop and it seems to natively incorporate
I am working on a game project using Microsoft XNA framework, although this question
I'm currently working on a project that's using the Dropkick.js plugin to style select
I am working on a project using rails 2.1.1. With the new release of
I am working on a project using Castle Active Record. I stumbled across the
I'm working on a project using C++, Boost, and Qt. I understand how to
I am working on a project using Groovy, and I would like to take
I'm working on a project using Scala running Selenium tests as part of 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.