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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T21:09:50+00:00 2026-06-10T21:09:50+00:00

the question and problem is pretty simple, though annoying and I am looking for

  • 0

the question and problem is pretty simple, though annoying and I am looking for a global solution, because it’s application-wide problem for us.

The code below is really not interesting but I post it for clarification!

We use PostgreSQL database with JPA 2.0 and we generated all the facades and entities, of course we did some editing but not much really.

The problem is that every entity contains a Collection of its children, which however (for us only?) is NOT updated after creation a children element.
The objects are written to database, you can select them easily, but what we really would like to see is the refreshed collection of children in parent object.

Why is this happening? If we (manually) refresh the entity of parent em.refresh(parent) it does the trick but it would mean for us a lot of work in Facades I guess. But maybe there is no other way?

Thanks for support!

/* EDIT */

I guess it has to be some annotation problem or cache or something, but I’ve already tried

@OneToMany(mappedBy = "idquestion", orphanRemoval=true, fetch= FetchType.EAGER) 

and

@Cacheable(false)

didn’t work properly.

/* EDIT */

Some sample code for understanding.

Database level:

CREATE TABLE Question (
        idQuestion SERIAL,
        questionContent VARCHAR,    
    CONSTRAINT Question_idQuestion_PK PRIMARY KEY (idQuestion)
);

CREATE TABLE Answer (
        idAnswer SERIAL,
        answerContent VARCHAR,
        idQuestion INTEGER,
    CONSTRAINT Answer_idAnswer_PK PRIMARY KEY (idAnswer),
    CONSTRAINT Answer_idQuestion_FK FOREIGN KEY (idQuestion) REFERENCES Question(idQuestion)
);

Than we have generated some Entities in Netbeans 7.1, all of them look similar to:

@Entity
@Table(name = "question", catalog = "jobfairdb", schema = "public")
@XmlRootElement
@NamedQueries({ BLAH BLAH BLAH...})
public class Question implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @NotNull
    @GeneratedValue(strategy= GenerationType.IDENTITY)
    @Column(name = "idquestion", nullable = false)
    private Integer idquestion;
    @Size(max = 2147483647)
    @Column(name = "questioncontent", length = 2147483647)
    private String questioncontent;
    @OneToMany(mappedBy = "idquestion", orphanRemoval=true) 
    private Collection<Answer> answerCollection;

Getters... setters...

We use (again) generated facades for them, all implementing AbstractFacade like:

public abstract class CCAbstractFacade<T> {
    private Class<T> entityClass;

    public CCAbstractFacade(Class<T> entityClass) {
        this.entityClass = entityClass;
    }

    protected abstract EntityManager getEntityManager();

    public void create(T entity) {
        getEntityManager().persist(entity);
    }
  • 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-10T21:09:51+00:00Added an answer on June 10, 2026 at 9:09 pm

    The father entity is updated automatically if you use container managed transactions and you fetch the collection after the transaction is complete. Otherwise, you have to update yourself the collection.

    This article explains in detail this behaviour: JPA implementation patterns: Bidirectional associations

    EDIT:

    The simplest way to use Container Managed Transactions is to have transaction-type="JTA" in persistence.xml and use Container-Managed Entity Managers.

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

Sidebar

Related Questions

My question is pretty much summed up in the subject.The context is a problem
The title of the question pretty much states the problem. Is it possible?
I've got a question that probably has a pretty simple answer, but I didn't
This a pretty simple question (I assume). Probably a repost, but I couldn't find
Hopefully this is a pretty simple question for someone to answer. I have a
Guess this is a pretty simple problem. I've got a regex and php that
Pretty simple question. I've seen it mentioned in many places that using properties on
My question is pretty simple, but I am having a bad time finding a
OK. So I have a pretty simple question: I want to be able to
this may be a pretty simple question. I've created a VS Package and it

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.