Hello,
I have a problem when using a Hibernate Validator with PersistentClassConstraint and the s:validateAll Tag.
When accessing a property of a class which uses this validator within a JSF Page an error occurs due that the Validation Exception is not handled by the s:validateAll Tag. The exception is thrown when the entityManager tries to commit the entity.
Is there a way to validate the whole entity before commiting?
I tried to solve the problem by using a custom JSF validator but in that case it seams that I'm losing some state, because the EntityHome instance returns false for the mehod isManaged after a wrong validation.
I'm using jBoss SEAM 1.2.1.GA and code generated by "seam generate-entities".
The custom hibernate validator annotation:
@ValidatorClass(SerialValidator.class)
@Target(value = ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
@Documented
public @interface Serial {
String message() default "Wrong Serial";
}
@Entity
@Table(name = "machine")
@Name("machine")
@Serial
public class Machine implements java.io.Serializable
...
<s:decorate id="serialDecoration" template="/layout/edit.xhtml">
<ui:define name="label">#{messages.serial}</ui:define>
<h:inputText id="serial" value="#{machineHome.instance.serial}"
required="true">
<a:support event="onblur" reRender="machine" />
</h:inputText>
</s:decorate>
I don't think Hibernate class level validators are currently supported by s:validate/s:validateAll. You can add a feature request in JIRA if you like.