-
1. Re: validation and persisting
pmuir Aug 14, 2007 4:13 PM (in response to mvlach)Throw an exception which causes a roll back, or, IMO a better option is to use the manual flush mode pattern./
-
2. Re: validation and persisting
mvlach Aug 14, 2007 4:27 PM (in response to mvlach)Where can I read some about manual flushing ?
Only set
@Begin(flushMode....)
and
em.flush()
?
Or something special ?
Thanks Mila -
-
4. Re: validation and persisting
mvlach Aug 15, 2007 3:05 AM (in response to mvlach)But how to do with this situation:
there is no @Begin annotated method. Page is displayed and when clicking the button actionlistener is called.
public String save() {
}
How to do in this situation ?
Thanks Mila -
5. Re: validation and persisting
christian.bauer Aug 15, 2007 3:13 AM (in response to mvlach)Easy: Don't modify your data. If you do not have a conversation, then the entity instances have to be loaded by you from the database and it is you who are modifying these instances. Do your validation before you modify the instances.
-
6. Re: validation and persisting
christian.bauer Aug 15, 2007 3:14 AM (in response to mvlach)If you want more specific help, as always, post your code.
-
7. Re: validation and persisting
mvlach Aug 15, 2007 3:35 AM (in response to mvlach)There is code....
@Name("requestAction") @Stateful @Restrict("#{identity.loggedIn}") public class RequestAction implements RequestActionLocal, Serializable { ....
.... @ValidatedMethod(formName = "editForm", validators = { @CustomValidator(validatorClass = RequestSaveValidator.class, mapping = { "category", "requestType", "request" }) }) @End(beforeRedirect = true) public String update() { log.info("adding the request #0", request); em.refresh(category); em.refresh(requestType); if (!requestType.getRequests().contains(request)) { requestType.getRequests().add(request); } request.setCategory(category); request.setAuthor(loggedUser); request.setCreated(new Date()); request.setRequestType(requestType); em.persist(request); em.flush(); return DefaultActions.EDITED; } @Begin(join = true, flushMode=FlushModeType.MANUAL) public String loadDetail() { edit(); return DefaultActions.LOADED; }
-
8. Re: validation and persisting
christian.bauer Aug 15, 2007 4:07 AM (in response to mvlach)And? All I can see is that you probably do not know how refresh() is used properly (in 5 years of Hibernate I never needed it).
-
9. Re: validation and persisting
mvlach Aug 15, 2007 4:16 AM (in response to mvlach)I remove the resfresh, but problem is,when validation failed some attributes are set and persisted to the entity Requst.
-
10. Re: validation and persisting
christian.bauer Aug 15, 2007 5:26 AM (in response to mvlach)Then that's the problem of how @ValidatedMethod works, which I guess is something you wrote.