You can find the full source code for this website in the Seam package in the directory /examples/wiki. It is licensed under the LGPL.
| Online: | 25 Members of 4546 |
| Forum: Seam Users |
06. Jun 2008, 18:37 CET | Link |
Hi I've a Candidate and a CandidateTest entities for each Candidate I've many CandidateTests.
@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "candidate")
public Set<CandidateTest> getCandidateTests() {
return this.candidateTests;
}
I've a CandidateHome SFSS with Conversation scope (manual flushmode)
I've a candidatePage.xhtml as well from this page I'm calling a del(CandidateTest ct) method using a4j:commandButton
this method remove the CandidateTest from the collection: candidate.getCandidateTests().remove(ct); (I implemented the equals method and it actualy removing it)
after that in the screen I've a h:commandButton that calls the action candidateHome.update()
for unkown reason it won't delete the CandidateTest from the DB...
any ideas?
Thanks a lot!!!
I tried to added Hibernate Extention to Cascade(delete orphem) but then I'm getting deleted entity passed to persist Exception..
Try:
Regards
I tried that. (don't forget I'm in manuel flush mode) I thought it should happen automaticly if I will use em.merge(candidate) and that's what the candidateHome.update() shoudl do..
anyhow if I'm calling em.remove(ct); before candidateHome.update(); I'm getting deleted entity passed to persist Exception
any other idea?
btw , I'm using seam 2.0.2sp1 jboss 4.2.1 hibernate 3.2.6 RC3.2.1
To avoid the deleted entity exception limit the cascade to CascadeType.Persist
Why? I would my Merge to casecade.. when I update() Candidate I would like it to recognize that I removed 1 CandidateTest from candidate.getCandidateTests() and it should've been deleted...
It will recognize that it has been deleted because you are deleting both from the collection and in the em:
well , it doesn't work , after I update() the Candidate I get an exception..
any other idea?
Please, post your exception message and maybe the stacktrace. I think this should work fine.
I found the problem,
CandidateTest has also refrence to Test (Entity Bean) I'd to remove the CandidateTest also from test.getCandidateTests() and then I'd to use getEntityManager.remove(candidatetest) or using hibernate delete orphern cascade extention instead..
thanks anyway