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
13
14
15
16
17
18
19
20
21
22
23
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 }