Tabnine Logo
BeanValidationEventListener
Code IndexAdd Tabnine to your IDE (free)

How to use
BeanValidationEventListener
in
org.hibernate.cfg.beanvalidation

Best Java code snippets using org.hibernate.cfg.beanvalidation.BeanValidationEventListener (Showing top 20 results out of 315)

origin: hibernate/hibernate-orm

@SuppressWarnings( {"UnusedDeclaration"})
public static void applyCallbackListeners(ValidatorFactory validatorFactory, ActivationContext activationContext) {
  final Set<ValidationMode> modes = activationContext.getValidationModes();
  if ( ! ( modes.contains( ValidationMode.CALLBACK ) || modes.contains( ValidationMode.AUTO ) ) ) {
    return;
  }
  final ConfigurationService cfgService = activationContext.getServiceRegistry().getService( ConfigurationService.class );
  final ClassLoaderService classLoaderService = activationContext.getServiceRegistry().getService( ClassLoaderService.class );
  // de-activate not-null tracking at the core level when Bean Validation is present unless the user explicitly
  // asks for it
  if ( cfgService.getSettings().get( Environment.CHECK_NULLABILITY ) == null ) {
    activationContext.getSessionFactory().getSessionFactoryOptions().setCheckNullability( false );
  }
  final BeanValidationEventListener listener = new BeanValidationEventListener(
      validatorFactory,
      cfgService.getSettings(),
      classLoaderService
  );
  final EventListenerRegistry listenerRegistry = activationContext.getServiceRegistry()
      .getService( EventListenerRegistry.class );
  listenerRegistry.addDuplicationStrategy( DuplicationStrategyImpl.INSTANCE );
  listenerRegistry.appendListeners( EventType.PRE_INSERT, listener );
  listenerRegistry.appendListeners( EventType.PRE_UPDATE, listener );
  listenerRegistry.appendListeners( EventType.PRE_DELETE, listener );
  listener.initialize( cfgService.getSettings(), classLoaderService );
}
origin: hibernate/hibernate-orm

/**
 * Constructor used in an environment where validator factory is injected (JPA2).
 *
 * @param factory The {@code ValidatorFactory} to use to create {@code Validator} instance(s)
 * @param settings Configued properties
 */
public BeanValidationEventListener(ValidatorFactory factory, Map settings, ClassLoaderService classLoaderService) {
  init( factory, settings, classLoaderService );
}
origin: hibernate/hibernate-orm

builder.append( operation.getName() );
builder.append( " time for groups " );
builder.append( toString( groups ) );
builder.append( "\nList of constraint violations:[\n" );
for (ConstraintViolation<?> violation : constraintViolations) {
origin: hibernate/hibernate-orm

public boolean onPreUpdate(PreUpdateEvent event) {
  validate(
      event.getEntity(), event.getPersister().getEntityMode(), event.getPersister(),
      event.getSession().getFactory(), GroupsPerOperation.Operation.UPDATE
  );
  return false;
}
origin: org.hibernate/hibernate-annotations

public static void activateBeanValidation(EventListeners eventListeners, Properties properties) {
  ValidatorFactory factory = getValidatorFactory( properties );
  BeanValidationEventListener beanValidationEventListener = new BeanValidationEventListener( factory, properties );
  {
    PreInsertEventListener[] listeners = eventListeners.getPreInsertEventListeners();
    int length = listeners.length + 1;
    PreInsertEventListener[] newListeners = new PreInsertEventListener[length];
    System.arraycopy( listeners, 0, newListeners, 0, length - 1 );
    newListeners[length - 1] = beanValidationEventListener;
    eventListeners.setPreInsertEventListeners( newListeners );
  }
  {
    PreUpdateEventListener[] listeners = eventListeners.getPreUpdateEventListeners();
    int length = listeners.length + 1;
    PreUpdateEventListener[] newListeners = new PreUpdateEventListener[length];
    System.arraycopy( listeners, 0, newListeners, 0, length - 1 );
    newListeners[length - 1] = beanValidationEventListener;
    eventListeners.setPreUpdateEventListeners( newListeners );
  }
  {
    PreDeleteEventListener[] listeners = eventListeners.getPreDeleteEventListeners();
    int length = listeners.length + 1;
    PreDeleteEventListener[] newListeners = new PreDeleteEventListener[length];
    System.arraycopy( listeners, 0, newListeners, 0, length - 1 );
    newListeners[length - 1] = beanValidationEventListener;
    eventListeners.setPreDeleteEventListeners( newListeners );
  }
}
origin: hibernate/hibernate-orm

public boolean onPreInsert(PreInsertEvent event) {
  validate(
      event.getEntity(), event.getPersister().getEntityMode(), event.getPersister(),
      event.getSession().getFactory(), GroupsPerOperation.Operation.INSERT
  );
  return false;
}
origin: hibernate/hibernate-orm

public boolean onPreDelete(PreDeleteEvent event) {
  validate(
      event.getEntity(), event.getPersister().getEntityMode(), event.getPersister(),
      event.getSession().getFactory(), GroupsPerOperation.Operation.DELETE
  );
  return false;
}
origin: org.hibernate/com.springsource.org.hibernate

@SuppressWarnings( {"UnusedDeclaration"})
public static void activateBeanValidation(EventListenerRegistry listenerRegistry, Configuration configuration) {
  final Properties properties = configuration.getProperties();
  ValidatorFactory factory = getValidatorFactory( properties );
  BeanValidationEventListener listener = new BeanValidationEventListener(
      factory, properties
  );
  listenerRegistry.addDuplicationStrategy( DuplicationStrategyImpl.INSTANCE );
  listenerRegistry.appendListeners( EventType.PRE_INSERT, listener );
  listenerRegistry.appendListeners( EventType.PRE_UPDATE, listener );
  listenerRegistry.appendListeners( EventType.PRE_DELETE, listener );
  listener.initialize( configuration );
}
origin: hibernate/hibernate-orm

public void initialize(Map settings, ClassLoaderService classLoaderService) {
  if ( !initialized ) {
    ValidatorFactory factory = Validation.buildDefaultValidatorFactory();
    init( factory, settings, classLoaderService );
  }
}
origin: org.hibernate/hibernate-annotations

builder.append( operation.getName() );
builder.append( " time for groups " );
builder.append( toString( groups ) );
throw new ConstraintViolationException(
    builder.toString(), propagatedViolations
origin: org.hibernate/hibernate-annotations

public boolean onPreInsert(PreInsertEvent event) {
  validate(
      event.getEntity(), event.getSession().getEntityMode(), event.getPersister(),
      event.getSession().getFactory(), GroupsPerOperation.Operation.INSERT
  );
  return false;
}
origin: org.hibernate/com.springsource.org.hibernate.core

@SuppressWarnings( {"UnusedDeclaration"})
public static void activateBeanValidation(EventListenerRegistry listenerRegistry, Configuration configuration) {
  final Properties properties = configuration.getProperties();
  ValidatorFactory factory = getValidatorFactory( properties );
  BeanValidationEventListener listener = new BeanValidationEventListener(
      factory, properties
  );
  listenerRegistry.addDuplicationStrategy( DuplicationStrategyImpl.INSTANCE );
  listenerRegistry.appendListeners( EventType.PRE_INSERT, listener );
  listenerRegistry.appendListeners( EventType.PRE_UPDATE, listener );
  listenerRegistry.appendListeners( EventType.PRE_DELETE, listener );
  listener.initialize( configuration );
}
origin: org.hibernate/hibernate-annotations

/**
 * Constructor used in an environment where validator factory is injected (JPA2).
 *
 * @param factory The {@code ValidatorFactory} to use to create {@code Validator} instance(s)
 * @param properties Configued properties
 */
public BeanValidationEventListener(ValidatorFactory factory, Properties properties) {
  init( factory, properties );
}
origin: org.hibernate/com.springsource.org.hibernate

builder.append( operation.getName() );
builder.append( " time for groups " );
builder.append( toString( groups ) );
builder.append( "\nList of constraint violations:[\n" );
for (ConstraintViolation<?> violation : constraintViolations) {
origin: org.hibernate/hibernate-annotations

public boolean onPreDelete(PreDeleteEvent event) {
  validate(
      event.getEntity(), event.getSession().getEntityMode(), event.getPersister(),
      event.getSession().getFactory(), GroupsPerOperation.Operation.DELETE
  );
  return false;
}
origin: org.hibernate.orm/hibernate-core

@SuppressWarnings( {"UnusedDeclaration"})
public static void applyCallbackListeners(ValidatorFactory validatorFactory, ActivationContext activationContext) {
  final Set<ValidationMode> modes = activationContext.getValidationModes();
  if ( ! ( modes.contains( ValidationMode.CALLBACK ) || modes.contains( ValidationMode.AUTO ) ) ) {
    return;
  }
  final ConfigurationService cfgService = activationContext.getServiceRegistry().getService( ConfigurationService.class );
  final ClassLoaderService classLoaderService = activationContext.getServiceRegistry().getService( ClassLoaderService.class );
  // de-activate not-null tracking at the core level when Bean Validation is present unless the user explicitly
  // asks for it
  if ( cfgService.getSettings().get( Environment.CHECK_NULLABILITY ) == null ) {
    activationContext.getSessionFactory().getSessionFactoryOptions().setCheckNullability( false );
  }
  final BeanValidationEventListener listener = new BeanValidationEventListener(
      validatorFactory,
      cfgService.getSettings(),
      classLoaderService
  );
  final EventListenerRegistry listenerRegistry = activationContext.getServiceRegistry()
      .getService( EventListenerRegistry.class );
  listenerRegistry.addDuplicationStrategy( DuplicationStrategyImpl.INSTANCE );
  listenerRegistry.appendListeners( EventType.PRE_INSERT, listener );
  listenerRegistry.appendListeners( EventType.PRE_UPDATE, listener );
  listenerRegistry.appendListeners( EventType.PRE_DELETE, listener );
  listener.initialize( cfgService.getSettings(), classLoaderService );
}
origin: org.hibernate/hibernate-annotations

public void initialize(Configuration cfg) {
  if ( !initialized ) {
    ValidatorFactory factory = Validation.buildDefaultValidatorFactory();
    Properties props = cfg.getProperties();
    init( factory, props );
  }
}
origin: org.hibernate/com.springsource.org.hibernate.core

builder.append( operation.getName() );
builder.append( " time for groups " );
builder.append( toString( groups ) );
builder.append( "\nList of constraint violations:[\n" );
for (ConstraintViolation<?> violation : constraintViolations) {
origin: org.hibernate/hibernate-annotations

public boolean onPreUpdate(PreUpdateEvent event) {
  validate(
      event.getEntity(), event.getSession().getEntityMode(), event.getPersister(),
      event.getSession().getFactory(), GroupsPerOperation.Operation.UPDATE
  );
  return false;
}
origin: org.hibernate/com.springsource.org.hibernate

/**
 * Constructor used in an environment where validator factory is injected (JPA2).
 *
 * @param factory The {@code ValidatorFactory} to use to create {@code Validator} instance(s)
 * @param properties Configued properties
 */
public BeanValidationEventListener(ValidatorFactory factory, Properties properties) {
  init( factory, properties );
}
org.hibernate.cfg.beanvalidationBeanValidationEventListener

Javadoc

Event listener used to enable Bean Validation for insert/update/delete events.

Most used methods

  • <init>
    Constructor used in an environment where validator factory is injected (JPA2).
  • init
  • toString
  • validate
  • initialize

Popular in Java

  • Reading from database using SQL prepared statement
  • orElseThrow (Optional)
    Return the contained value, if present, otherwise throw an exception to be created by the provided s
  • getContentResolver (Context)
  • onCreateOptionsMenu (Activity)
  • DecimalFormat (java.text)
    A concrete subclass of NumberFormat that formats decimal numbers. It has a variety of features desig
  • SortedMap (java.util)
    A map that has its keys ordered. The sorting is according to either the natural ordering of its keys
  • Executor (java.util.concurrent)
    An object that executes submitted Runnable tasks. This interface provides a way of decoupling task s
  • ImageIO (javax.imageio)
  • Filter (javax.servlet)
    A filter is an object that performs filtering tasks on either the request to a resource (a servlet o
  • IsNull (org.hamcrest.core)
    Is the value null?
  • Top Sublime Text plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now