Configure Hibernate validation for bean

Posted by sergionni on Stack Overflow See other posts from Stack Overflow or by sergionni
Published on 2010-05-14T15:04:34Z Indexed on 2010/05/14 16:24 UTC
Read the original article Hit count: 364

Hi.

I need to perform validation based on SQL query result.

Query is defined as annotation - as @NamedQuery in my entity bean.

According to Hibernate documentation(doc), there is possibility to validate bean on following operations:
pre-update
pre-insert
pre-delete

looks like:

<hibernate-configuration>
    <session-factory>
       ...
    <event type="pre-update">
       <listener class="org.hibernate.cfg.beanvalidation.BeanValidationEventListener"/>
    </event>
    <event type="pre-insert">
        <listener class="org.hibernate.cfg.beanvalidation.BeanValidationEventListener"/>
    </event>
    <event type="pre-delete">
        <listener class="org.hibernate.cfg.beanvalidation.BeanValidationEventListener"/>
    </event>
</hibernate-configuration>

The question is how to connect my bean with the validation configuration, described above.

© Stack Overflow or respective owner

Related posts about hibernate

Related posts about configuration