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.
updated:
entity class
...
@Entity
@NamedQuery(name = "isValutaKursExists", query = "SELECT id FROM CurrencyRate WHERE bankId = :bankNum")
@Table(name = "Currency")
public class Currency {
...