Help

Controls

PermLinkWikiLink

Built with Seam

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.

Forum: Seam Users Forum ListTopic List
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..

8 Replies:
06. Jun 2008, 19:51 CET | Link

Try:


candidate.getCandidateTests().remove(ct);
em.remove(ct);

Regards

06. Jun 2008, 21:54 CET | Link

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

06. Jun 2008, 22:07 CET | Link

To avoid the deleted entity exception limit the cascade to CascadeType.Persist

Rating:  *
06. Jun 2008, 22:12 CET | Link

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...

06. Jun 2008, 22:21 CET | Link

It will recognize that it has been deleted because you are deleting both from the collection and in the em:

 
candidate.getCandidateTests().remove(ct);
em.remove(ct);
07. Jun 2008, 00:43 CET | Link

well , it doesn't work , after I update() the Candidate I get an exception..

any other idea?

08. Jun 2008, 15:37 CET | Link

Please, post your exception message and maybe the stacktrace. I think this should work fine.

08. Jun 2008, 15:45 CET | Link

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