@Override protected void prepareBootstrapRegistryBuilder(BootstrapServiceRegistryBuilder builder) { super.prepareBootstrapRegistryBuilder(builder); builder.with( new Integrator() { @Override public void integrate( Configuration configuration, SessionFactoryImplementor sessionFactory, SessionFactoryServiceRegistry serviceRegistry) { integrate(serviceRegistry); } @Override public void integrate( MetadataImplementor metadata, SessionFactoryImplementor sessionFactory, SessionFactoryServiceRegistry serviceRegistry) { integrate(serviceRegistry); } private void integrate(SessionFactoryServiceRegistry serviceRegistry) { serviceRegistry .getService(EventListenerRegistry.class) .getEventListenerGroup(EventType.POST_COMMIT_DELETE) .appendListener(postCommitDeleteEventListener); serviceRegistry .getService(EventListenerRegistry.class) .getEventListenerGroup(EventType.POST_COMMIT_UPDATE) .appendListener(postCommitUpdateEventListener); serviceRegistry .getService(EventListenerRegistry.class) .getEventListenerGroup(EventType.POST_COMMIT_INSERT) .appendListener(postCommitInsertEventListener); } @Override public void disintegrate( SessionFactoryImplementor sessionFactory, SessionFactoryServiceRegistry serviceRegistry) {} }); }
@Override protected void configure(Configuration cfg) { super.configure(cfg); final MessageInterpolator messageInterpolator = new MessageInterpolator() { public String interpolate(String s, Context context) { return "Oops"; } public String interpolate(String s, Context context, Locale locale) { return interpolate(s, context); } }; final javax.validation.Configuration<?> configuration = Validation.byDefaultProvider().configure(); configuration.messageInterpolator(messageInterpolator); ValidatorFactory vf = configuration.buildValidatorFactory(); cfg.getProperties().put("javax.persistence.validation.factory", vf); cfg.setProperty("javax.persistence.validation.mode", "AUTO"); }
@Override public void configure(Configuration cfg) { super.configure(cfg); cfg.setPhysicalNamingStrategy(new TestingNamingStrategy()); }
@Override protected void configure(Configuration cfg) { super.configure(cfg); cfg.addResource("org/hibernate/test/annotations/id/sequences/orm.xml"); }
protected void configure(Configuration cfg) { super.configure(cfg); cfg.setProperty(Environment.ENABLE_LAZY_LOAD_NO_TRANS, "true"); }
public void configure(Configuration cfg) { super.configure(cfg); cfg.setProperty("hibernate.event.merge.entity_copy_observer", "allow"); }