[hibernate-issues] [Hibernate-JIRA] Resolved: (HV-344) Add example for configuring hibernate validator through Spring session factory bean

Hardy Ferentschik (JIRA) noreply at atlassian.com
Mon Jun 28 06:11:09 EDT 2010


     [ http://opensource.atlassian.com/projects/hibernate/browse/HV-344?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Hardy Ferentschik resolved HV-344.
----------------------------------

       Resolution: Won't Fix
    Fix Version/s: 4.1.0.Final

You can find already an example for Spring configuration on the Hibernate Validator Wiki - http://community.jboss.org/wiki/HibernateValidatorandSpring
It is pretty much identical to yours except the usage of {{PropertiesFactoryBean}}. I am happy to have spring configuration examples on the wiki, but don't want to include them into the Validator online manual.  

> Add example for configuring hibernate validator through Spring session factory bean
> -----------------------------------------------------------------------------------
>
>                 Key: HV-344
>                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HV-344
>             Project: Hibernate Validator
>          Issue Type: Improvement
>          Components: documentation
>    Affects Versions: 4.0.2.GA
>            Reporter: Roman Arkadijovych Muntyanu
>            Assignee: Hardy Ferentschik
>             Fix For: 4.1.0.Final
>
>   Original Estimate: 1h
>  Remaining Estimate: 1h
>
> Please add example for configuring hibernate validator through Spring session factory bean.
> (!) It is *mandatory* to perform explicit validation framework configuration for it to start working, if hibernate configuration has been performed through Spring session factory.
> The example may be like the following
> {code:xml}
> <!--Hibernate configuration properties for datasource-->
> <bean id="hibernateConfigProperties"
>       class="org.springframework.beans.factory.config.PropertiesFactoryBean">
>     <!--<property name="location" value="classpath:hibernate.properties"/>-->
>     <property name="locations">
>         <list>
>             <value>classpath:hibernate.properties</value>
>             <!--suppress SpringModelInspection -->
>             <!--<value>classpath:compass.properties</value>-->
>         </list>
>     </property>
>     <property name="properties">
>         <props>
>             <prop key="hibernate.dialect">${database.hibernate.dialect}</prop>
>             <prop key="javax.persistence.validation.group.pre-persist">javax.validation.groups.Default</prop>
>             <prop key="javax.persistence.validation.group.pre-update">javax.validation.groups.Default</prop>
>         </props>
>     </property>
> </bean>
> <!--  The session factory with all mappings -->
> <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
>     <property name="mappingResources">
>         <list>
>             <value>org.hibernate.example.TestDTO.hbm.xml</value>
>             ...
>         </list>
>     </property>
>     <property name="hibernateProperties" ref="hibernateConfigProperties"/>
>     <!-- Data source may be defined elsewhere-->
>     <property name="dataSource" ref="dataSource"/> 
>     <!-- This is how event-listeners are configured. 
>          It is important that references to actual objects are passed. -->
>     <property name="eventListeners">
>         <map>
>             <entry key="pre-update" value-ref="beanValidationEventListener"/>
>             <entry key="pre-insert" value-ref="beanValidationEventListener"/>
>         </map>
>     </property>
> </bean>
> <!-- Define bean validation event listener -->
> <bean id="beanValidationEventListener" class="org.hibernate.cfg.beanvalidation.BeanValidationEventListener"/>
> {code}

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        


More information about the hibernate-issues mailing list