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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T05:30:51+00:00 2026-06-04T05:30:51+00:00

i have an application with a derby database and use eclipselink as the persistence

  • 0

i have an application with a derby database and use eclipselink as the persistence api.
Say i have a gui with a list of teams. Each team has a number of players on it. The relationship in the team class looks like this:

@OneToMany(mappedBy = "team", fetch = FetchType.LAZY, cascade = { CascadeType.ALL })
private List<player> players = new ArrayList<player>():

and the player class like this:

@ManyToOne(targetEntity = Team.class)
@JoinColumn(name = "teamID", nullable = false, referencedColumnName = "ID")
private Team team;

So i now start my application and it fills a list with all existing teams:

public List<Team> getTeams()
{
    TypedQuery<Team> query = em.createQuery("SELECT t FROM Team t",  Team.class);
    List<Team> teams = query.getResultList();
    return teams;
}

All is working right so far, only the teams are loaded, not the players. Say i now open a table with the players of a team by selecting a team and exectue the command for this. The table is filled with:

team.getPlayers();

So now all the players of this team are loaded, cause they are now needed.
But after i close the table they remain loaded, but i would like to “unload” them again so that they don’t remain in memory – how would i do this?

  • 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-04T05:30:52+00:00Added an answer on June 4, 2026 at 5:30 am

    If you want to get rid of managed entities from its context you can call EntityManager.clear() method (calling EntityManager.flush() before). This operation, however, removes all managed entities, which is not necessarily what you want, since this might cause additional database hits.

    If you are lucky and you can use JPA 2.0 there is a better option: EntityManager.detach(Object) method, which is removing given object from persistence context.

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

Sidebar

Related Questions

I have a Java app that has an embedded Derby database (no hibernate though).
I have been developing a Java application using J2EE and a Derby database. My
We have a Java desktop application that accesses a Derby database located on a
I have application that use mysql database, but now i need to port it
I use JavaDB (Derby) as an embedded database in my Java Swing application. I
I have a Java application that uses an Apache Derby database with the embedded
I have big problem with my small database(DERBY) application. I am getting such an
I have application which needs to use a dll (also written by me) which
I have Application X with Subform x1, x2, x3. The Subform has, because its
I have developed a Java Application that connects with a database (insert, select ...)

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.