-
1. Re: How to persist collection attribute
dthibau1 Dec 15, 2008 2:45 PM (in response to girlcoder)Your problem here is that your attribute is associated with 2 Hibernate's session !!
(perharps in 2 seam's component ?)
-
2. Re: How to persist collection attribute
girlcoder Dec 15, 2008 3:10 PM (in response to girlcoder)How to check if I have 2 sessions ?
I when I changed the way to add to Set attribute
I had another exception here:Different object with the same identifier value was already associeted with the session
Have you got any idea ?
-
3. Re: How to persist collection attribute
ganton516 Dec 16, 2008 6:38 AM (in response to girlcoder)Without seeing the entity code, I would guess that what you need is a CascadeType.PERSIST on the parent entity.
i.e:
private Set<T> myStuff; @ManyToMany(cascade={CascadeType.PERSIST}) public Set<T> getMyStuff() { return myStuff; } public void setMyStuff(Set<T> newStuff) { myStuff = newStuff; }
This should cause any changes to the
sub entity
to be persisted when the parent entity is.Hope this helps
g
-
4. Re: How to persist collection attribute
girlcoder Dec 16, 2008 8:58 AM (in response to girlcoder)I have this on first entity:
private Set<CbShortCode> cbShortCodes = new HashSet<CbShortCode>(0); @ManyToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "cbServices") public Set<CbShortCode> getCbShortCodes() { return this.cbShortCodes; } public void setCbShortCodes(Set<CbShortCode> cbShortCodes) { this.cbShortCodes = cbShortCodes; }
and this on second:
@ManyToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY) @JoinTable(name = "cb_shoco_services", schema = "public", joinColumns = { @JoinColumn(name = "addr", nullable = false, updatable = false) }, inverseJoinColumns = { @JoinColumn(name = "service_id", nullable = false, updatable = false) }) public Set<CbService> getCbServices() { return this.cbServices; } public void setCbServices(Set<CbService> cbServices) { this.cbServices = cbServices; }
generated from existng database - Seam Generate Entities
do I have to change something here ?
-
5. Re: How to persist collection attribute
tiagoemerick Jun 14, 2010 8:27 AM (in response to girlcoder)Hi guys.
sorry for revive an old topic, but i do not understand how this problem occurs in seam.
David THIBAU, you said that my attribute is associated with 2 Hibernate's sessions.
how it's possible when seam is managing my sessions?
David THIBAU wrote on Dec 15, 2008 14:45:
Your problem here is that your attribute is associated with 2 Hibernate's session !!
(perharps in 2 seam's component ?)Click HELP for text formatting instructions. Then edit this text and check the preview.