You can easily add extra conditions:
| @AssertTrue(message="second number must be larger than the first")
| public boolean checkNumbers() {
| System.out.println("number1=" + number1 + " number2=" + number2);
| return number2 > number1;
| }
|
Hibernate will check the condition at persist() time. Unfortunately, it
doesn't handle it a way that is very friendly to your application. (from the
perspective of being transparent) You'll have to add a bit of code to the
application for that. Here's an overridden persist on EntityHome:
| @Transactional
| @Override
| public String persist()
| {
| ClassValidator validator =
Validators.instance().getValidator(YourEntity.class, "yourEntity");
| InvalidValue[] ivs = validator.getInvalidValues(getInstance());
| if (ivs.length>0) {
| facesMessages.add(ivs);
| return null;
| }
|
| return super.persist();
| }
|
View the original post :
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3996766#3996766
Reply to the post :
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3996766
_______________________________________________
jboss-user mailing list
[email protected]
https://lists.jboss.org/mailman/listinfo/jboss-user