Hibernate, EHCache, Read-Write cache, adding item to a list
Posted
by Walter White
on Stack Overflow
See other posts from Stack Overflow
or by Walter White
Published on 2010-03-13T16:50:47Z
Indexed on
2010/03/13
16:55 UTC
Read the original article
Hit count: 441
Hi all,
I have an entity that has a collection in it. The collection is a OneToMany unidirectional relationship storing who viewed a particular file. The problem I am having is that after I load the entity and try to update the collection, I don't get any errors, but the collection is never updated:
Entity:
@OneToMany(cascade = CascadeType.PERSIST)
@JoinTable
protected List<User> users;
File Servlet
@In
private EntityQuery<File> File_findById;
...
File file = File_findById(fileId);
file.getUsers().add(user);
session.update(file);
Even though I call session.update(file)
and I see stuff in hibernate logs, I don't see anything in the database indicating that it was saved.
Walter
© Stack Overflow or respective owner