X-Git-Url: https://juplo.de/gitweb/?p=website;a=blobdiff_plain;f=dist%2Fhibernate4-maven-plugin-1.1.1%2Fxref%2Fde%2Fjuplo%2Fplugins%2Fhibernate4%2FValidationConfiguration.html;fp=dist%2Fhibernate4-maven-plugin-1.1.1%2Fxref%2Fde%2Fjuplo%2Fplugins%2Fhibernate4%2FValidationConfiguration.html;h=6668e1fd8c676af83e2e6543a7014d7aa7e434c4;hp=0000000000000000000000000000000000000000;hb=a53595184bd6e57bdc45292cc92c393c4e2dfe6e;hpb=c48c9ee0e9faa89a4c0a5323b367b9f5a6abe602 diff --git a/dist/hibernate4-maven-plugin-1.1.1/xref/de/juplo/plugins/hibernate4/ValidationConfiguration.html b/dist/hibernate4-maven-plugin-1.1.1/xref/de/juplo/plugins/hibernate4/ValidationConfiguration.html new file mode 100644 index 00000000..6668e1fd --- /dev/null +++ b/dist/hibernate4-maven-plugin-1.1.1/xref/de/juplo/plugins/hibernate4/ValidationConfiguration.html @@ -0,0 +1,67 @@ + + + +ValidationConfiguration xref + + + +
View Javadoc
+1   package de.juplo.plugins.hibernate4;
+2   
+3   import javax.validation.Validation;
+4   
+5   import org.hibernate.cfg.Configuration;
+6   import org.hibernate.cfg.beanvalidation.TypeSafeActivatorAccessor;
+7   import org.hibernate.dialect.Dialect;
+8   import org.hibernate.metamodel.source.MappingException;
+9   
+10  
+11  /**
+12   * This integration is usually performed by BeanValidationIntegrator.
+13   * Unfortunately, that integration will only be activated upon
+14   * initialization of the ServiceRegistry, which initializes
+15   * DatasourceConnectionProviderImpl, which looks up the datasource,
+16   * which requires a JNDI context ...
+17   * We therefore reimplement the relevant parts of BeanValidatorIntegrator.
+18   * Since that must occur after secondPassCompile(), which is invoked by
+19   * Configuration.generateSchemaCreationScript, which is invoked by
+20   * SchemaExport, some fancy subclassing is needed to invoke the integration
+21   * at the right time.
+22   * @author Mark Robinson <mark@mrobinson.ca>
+23   * @author Frank Schimmel <frank.schimmel@cm4all.com>
+24   */
+25  public class ValidationConfiguration extends Configuration
+26  {
+27    private static final long serialVersionUID = 1L;
+28  
+29  
+30    @Override
+31    protected void secondPassCompile() throws MappingException
+32    {
+33      super.secondPassCompile();
+34  
+35      try
+36      {
+37        TypeSafeActivatorAccessor.applyRelationalConstraints(
+38            Validation.buildDefaultValidatorFactory(),
+39            classes.values(),
+40            getProperties(),
+41            ((Class<Dialect>)Class.forName(getProperty(Hbm2DdlMojo.DIALECT))).newInstance()
+42            );
+43      }
+44      catch (Exception e)
+45      {
+46        throw new RuntimeException(e);
+47      }
+48    }
+49  
+50    public String getTypeDefs()
+51    {
+52      return typeDefs.entrySet().toString();
+53    }
+54  }
+
+
+ + +