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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T17:20:06+00:00 2026-05-22T17:20:06+00:00

The collection on an entity in the cache is not refresh after a session.delete.

  • 0

The collection on an entity in the cache is not refresh after a session.delete.

Here is my relation :
– a model can have 0 to N bookmarks used for a specific user.
– the primaky key of a model is an id
– the primary key of the bookmark is the couple (idModele,loginUser)

The problem is that if i save a model 1 with one bookmark. They are put in the 2nd level cache. If i’m using bookmarkDao.delete in one transaction to remove this bookmark, it is still in modele.getBookmarks() even in a new transaction. The cache seems to not have been update.

Here are my hbm files:
Model

 <class name="Modele" table="modele"  batch-size="10">
<cache usage="read-write"/>
 <id name="id" column="id_composant" unsaved-value="0">
  <generator class="sequence">
    <param name="sequence">composant_id_composant_seq</param>
  </generator>
</id>

<set name="bookmarks" table="bookmark" cascade="all" access="field" >
  <cache usage="read-write"/>
  <key column="id_modele" />
  <element column="username" type="string"/>
</set>

Bookmark

 <class name="Bookmark" table="bookmark">  
 <cache usage="read-write"/>
<composite-id>
  <key-many-to-one name="modele" column="id_modele" access="field" />
  <key-property name="username" column="username"/>
</composite-id>
</class>

The classes

public class Bookmark implements Serializable {
private static final long serialVersionUID = 1L;

private Modele modele;
private String username;

public Modele getModele() {
    return modele;
}
public void setModele(Modele modele) {
    this.modele = modele;
}

public String getUsername() {
    return username;
}
public void setUsername(String username) {
    this.username = username;
}
@Override
public int hashCode() {

    final int prime = 31;
    int result = 1;
    result = prime * result + ((modele == null) ? 0 : modele.hashCode());
    result = prime * result + ((username == null) ? 0 : username.hashCode());
    return result;
}
@Override
public boolean equals(Object obj) {
    if (this == obj)
        return true;
    if (obj == null)
        return false;
    if (getClass() != obj.getClass())
        return false;
    Favori other = (Favori) obj;
    if (modele == null) {
        if (other.modele != null)
            return false;
    } else if (!modele.equals(other.modele))
        return false;
    if (username == null) {
        if (other.username != null)
            return false;
    } else if (!username.equals(other.username))
        return false;
    return true;
}

}

Do i miss something ?

I’m using Hibernate Core 3.6.3.Final & Ehcache 2.2.0 with Maven, spring core, tx…3.0.

Thanks in advance for your help.

  • 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-22T17:20:07+00:00Added an answer on May 22, 2026 at 5:20 pm

    The session is the first-level cache, not the second-level cache.

    Without more information about your config and the error you get, it’s hard to help more.

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

Sidebar

Related Questions

I have got an Entity model which contains a collection of Message objects which
I have a collection of custom entity objects one property of which is an
Basically each entity would have a collection of feeding behaviors that it would follow.
I have entity Recipes and it has a HasMany collection comments. In a MVC
I have an entity that has a collection in it. The collection is a
I have an entity class Foo foo that contains Collection<Bar> bars . I've tried
i have a table where a Collection has many Entities and an Entity has
Collection.clear() will delete children whenever Session flushes. What about OneToOne? Setting to null is
here my code- <asp:BoundField DataField=DayOfTheWeek HeaderText=Day ItemStyle-CssClass=Itemstyle/> from my collection entity I am getting
Here's my (simplified) model: Ticket -> Customer Callback (s) I have my Ticket mapped

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.