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

How to use
SelectedFieldsLockingPolicy
in
org.eclipse.persistence.descriptors

Best Java code snippets using org.eclipse.persistence.descriptors.SelectedFieldsLockingPolicy (Showing top 20 results out of 315)

origin: org.eclipse.persistence/com.springsource.org.eclipse.persistence

/**
 * PUBLIC:
 * Set the locking policy a selected fields locking policy.
 * A field locking policy is base on locking on the specified fields by comparing with their previous values to detect field-level collisions.
 * Note: the unit of work must be used for all updates when using field locking.
 * @see SelectedFieldsLockingPolicy
 */
public void useSelectedFieldsLocking(Vector fieldNames) {
  SelectedFieldsLockingPolicy policy = new SelectedFieldsLockingPolicy();
  policy.setLockFieldNames(fieldNames);
  setOptimisticLockingPolicy(policy);
}
origin: org.eclipse.persistence/org.eclipse.persistence.core

/**
 * PUBLIC: Set the field names to lock on. All fields in this list will be
 * compared when Updating. If the value of any of the fields does not match
 * the value in memory, an OptimisticLockException will be thrown.
 *
 * Note: An Automatic update will not be done on this field, only a
 * comparison occurs.
 */
public void setLockFieldNames(List<String> lockFieldNames) {
  for (String name : lockFieldNames) {
    addLockFieldName(name);
  }
}
origin: org.eclipse.persistence/com.springsource.org.eclipse.persistence

/**
 * INTERNAL:
 * returns the lock fields to compare based on the passed in table.
 */
protected Vector getFieldsToCompare(org.eclipse.persistence.internal.helper.DatabaseTable table, AbstractRecord transRow, AbstractRecord modifyRow) {
  return getLockFields(table);
}
origin: org.eclipse.persistence/org.eclipse.persistence.core

/**
 * INTERNAL: It is responsible for initializing the policy;
 */
@Override
public void initialize(AbstractSession session) {
  super.initialize(session);
  List<DatabaseField> lockFields = getLockFields();
  int size = lockFields.size();
  for (int index = 0; index < size; index++) {
    DatabaseField field = lockFields.get(index);
    field = descriptor.buildField(field);
    lockFields.set(index, field);
    List<DatabaseField> fieldsForTable = getLockFieldsByTable().get(field.getTable());
    if (fieldsForTable == null) {
      fieldsForTable = org.eclipse.persistence.internal.helper.NonSynchronizedVector.newInstance();
      getLockFieldsByTable().put(field.getTable(), fieldsForTable);
    }
    fieldsForTable.add(field);
  }
}
origin: org.eclipse.persistence/com.springsource.org.eclipse.persistence

/**
 * INTERNAL:
 * Values to be included in the locking mechanism are added to the translation row.
 * For changed fields the normal build row is ok as only changed fields matter.
 */
public void addLockValuesToTranslationRow(ObjectLevelModifyQuery query) throws DatabaseException{
  Object object;
  verifyUsage(query.getSession());
  if (query.isDeleteObjectQuery()) {
    object = query.getObject();
  } else {
    object = query.getBackupClone();
  }
  for (Iterator vectors = getLockFieldsByTable().values().iterator(); vectors.hasNext();) {
    for (Enumeration fields = ((Vector)vectors.next()).elements();
         fields.hasMoreElements();) {
      DatabaseField field = (DatabaseField)fields.nextElement();
      DatabaseMapping mapping = descriptor.getObjectBuilder().getMappingForField(field);
      //Bug5892889, Exception will be thrown if no matched database field found
      if(mapping == null ){
        throw DatabaseException.specifiedLockingFieldsNotFoundInDatabase(field.getQualifiedName());
      }else{
        mapping.writeFromObjectIntoRow(object, query.getTranslationRow(), query.getSession());
      }
    }
  }
}
origin: com.haulmont.thirdparty/eclipselink

  throw ValidationException.optimisticLockingSelectedColumnNamesNotSpecified(descriptor.getJavaClass());
} else {
  SelectedFieldsLockingPolicy policy = new SelectedFieldsLockingPolicy();
      throw ValidationException.optimisticLockingSelectedColumnNamesNotSpecified(descriptor.getJavaClass());
    } else {
      policy.addLockFieldName(selectedColumn.getName());
origin: com.haulmont.thirdparty/eclipselink

/**
 * INTERNAL: It is responsible for initializing the policy;
 */
@Override
public void initialize(AbstractSession session) {
  super.initialize(session);
  List<DatabaseField> lockFields = getLockFields();
  int size = lockFields.size();
  for (int index = 0; index < size; index++) {
    DatabaseField field = lockFields.get(index);
    field = descriptor.buildField(field);
    lockFields.set(index, field);
    List<DatabaseField> fieldsForTable = getLockFieldsByTable().get(field.getTable());
    if (fieldsForTable == null) {
      fieldsForTable = org.eclipse.persistence.internal.helper.NonSynchronizedVector.newInstance();
      getLockFieldsByTable().put(field.getTable(), fieldsForTable);
    }
    fieldsForTable.add(field);
  }
}
origin: org.eclipse.persistence/org.eclipse.persistence.core

public void addLockValuesToTranslationRow(ObjectLevelModifyQuery query) throws DatabaseException {
  Object object;
  verifyUsage(query.getSession());
  if (query.isDeleteObjectQuery()) {
    object = query.getObject();
  for (Iterator<List<DatabaseField>> fields = getLockFieldsByTable().values().iterator(); fields.hasNext();) {
    for (DatabaseField field : fields.next()) {
      DatabaseMapping mapping = descriptor.getObjectBuilder().getMappingForField(field);
origin: org.eclipse.persistence/org.eclipse.persistence.core

/**
 * PUBLIC:
 * Set the locking policy a selected fields locking policy.
 * A field locking policy is base on locking on the specified fields by comparing with their previous values to detect field-level collisions.
 * Note: the unit of work must be used for all updates when using field locking.
 * @see SelectedFieldsLockingPolicy
 */
public void useSelectedFieldsLocking(Vector fieldNames) {
  SelectedFieldsLockingPolicy policy = new SelectedFieldsLockingPolicy();
  policy.setLockFieldNames(fieldNames);
  setOptimisticLockingPolicy(policy);
}
origin: org.eclipse.persistence/com.springsource.org.eclipse.persistence

/**
 * INTERNAL:
 * It is responsible for initializing the policy;
 */
public void initialize(AbstractSession session) {
  super.initialize(session);
  List lockFields = getLockFields();
  int size = lockFields.size();
  for (int index = 0; index < size; index++) {
    DatabaseField field = (DatabaseField)lockFields.get(index);
    field = descriptor.buildField(field);
    lockFields.set(index, field);
    Vector fieldsForTable = (Vector)getLockFieldsByTable().get(field.getTable());
    if (fieldsForTable == null) {
      fieldsForTable = org.eclipse.persistence.internal.helper.NonSynchronizedVector.newInstance();
      getLockFieldsByTable().put(field.getTable(), fieldsForTable);
    }
    fieldsForTable.addElement(field);
  }
}
origin: com.haulmont.thirdparty/eclipselink

public void addLockValuesToTranslationRow(ObjectLevelModifyQuery query) throws DatabaseException {
  Object object;
  verifyUsage(query.getSession());
  if (query.isDeleteObjectQuery()) {
    object = query.getObject();
  for (Iterator<List<DatabaseField>> fields = getLockFieldsByTable().values().iterator(); fields.hasNext();) {
    for (DatabaseField field : fields.next()) {
      DatabaseMapping mapping = descriptor.getObjectBuilder().getMappingForField(field);
origin: org.eclipse.persistence/org.eclipse.persistence.core

/**
 * INTERNAL: returns the lock fields to compare based on the passed in
 * table.
 */
@Override
protected List<DatabaseField> getFieldsToCompare(org.eclipse.persistence.internal.helper.DatabaseTable table, AbstractRecord transRow, AbstractRecord modifyRow) {
  return getLockFields(table);
}
origin: com.haulmont.thirdparty/eclipselink

/**
 * PUBLIC: Set the field names to lock on. All fields in this list will be
 * compared when Updating. If the value of any of the fields does not match
 * the value in memory, an OptimisticLockException will be thrown.
 * 
 * Note: An Automatic update will not be done on this field, only a
 * comparison occurs.
 */
public void setLockFieldNames(List<String> lockFieldNames) {
  for (String name : lockFieldNames) {
    addLockFieldName(name);
  }
}
origin: com.haulmont.thirdparty/eclipselink

/**
 * PUBLIC:
 * Set the locking policy a selected fields locking policy.
 * A field locking policy is base on locking on the specified fields by comparing with their previous values to detect field-level collisions.
 * Note: the unit of work must be used for all updates when using field locking.
 * @see SelectedFieldsLockingPolicy
 */
public void useSelectedFieldsLocking(Vector fieldNames) {
  SelectedFieldsLockingPolicy policy = new SelectedFieldsLockingPolicy();
  policy.setLockFieldNames(fieldNames);
  setOptimisticLockingPolicy(policy);
}
origin: com.haulmont.thirdparty/eclipselink

/**
 * INTERNAL: returns the lock fields to compare based on the passed in
 * table.
 */
@Override
protected List<DatabaseField> getFieldsToCompare(org.eclipse.persistence.internal.helper.DatabaseTable table, AbstractRecord transRow, AbstractRecord modifyRow) {
  return getLockFields(table);
}
origin: org.eclipse.persistence/com.springsource.org.eclipse.persistence

/**
 * PUBLIC:
 * Set the field names to lock on.  All fields in this list will be compared when Updating.
 * If the value of any of the fields does not match the value in memory, an
 * OptimisticLockException will be thrown.
 *
 * Note: An Automatic update will not be done on this field, only a comparison occurs.
 */
public void setLockFieldNames(Vector lockFieldNames) {
  for (Enumeration enumtr = lockFieldNames.elements(); enumtr.hasMoreElements();) {
    addLockFieldName((String)enumtr.nextElement());
  }
}
origin: org.eclipse.persistence/org.eclipse.persistence.core

/**
 * PUBLIC: Add a field name to lock on. All fields in this list will be
 * compared when updating if the value of any of the fields does not match
 * the value in memory, an OptimisticLockException will be thrown.
 *
 * Note: An Automatic update will not be done on this field, only a
 * comparison occurs.
 */
public void addLockFieldName(String fieldName) {
  getLockFields().add(new DatabaseField(fieldName));
}
origin: com.haulmont.thirdparty/eclipselink

/**
 * PUBLIC: Add a field name to lock on. All fields in this list will be
 * compared when updating if the value of any of the fields does not match
 * the value in memory, an OptimisticLockException will be thrown.
 * 
 * Note: An Automatic update will not be done on this field, only a
 * comparison occurs.
 */
public void addLockFieldName(String fieldName) {
  getLockFields().add(new DatabaseField(fieldName));
}
origin: org.eclipse.persistence/com.springsource.org.eclipse.persistence

/**
 * PUBLIC:
 * Add a fieldname to lock on.  All fields in this list will be compared when Updating
 * if the value of any of the fields does not match the value in memory, an
 * OptimisticLockException will be thrown.
 *
 * Note: An Automatic update will not be done on this field, only a comparison occurs.
 */
public void addLockFieldName(String fieldName) {
  getLockFields().addElement(new DatabaseField(fieldName));
}
origin: org.eclipse.persistence/com.springsource.org.eclipse.persistence

protected void addOptimisticLockingLines(NonreflectiveMethodDefinition method, OptimisticLockingPolicy policy) {
  String policyClassName = policy.getClass().getName();
  String packageName = policyClassName.substring(0, policyClassName.lastIndexOf('.'));
  if (packageName.equals("org.eclipse.persistence.descriptors")) {
    policyClassName = Helper.getShortClassName(policy);
  }
  method.addLine(policyClassName + " lockingPolicy = new " + policyClassName + "();");
  if (policy instanceof SelectedFieldsLockingPolicy) {
    SelectedFieldsLockingPolicy fieldPolicy = (SelectedFieldsLockingPolicy)policy;
    for (Enumeration fieldsEnum = fieldPolicy.getLockFields().elements();
         fieldsEnum.hasMoreElements();) {
      DatabaseField field = (DatabaseField)fieldsEnum.nextElement();
      method.addLine("lockingPolicy.addLockFieldName(\"" + field.getQualifiedName() + "\");");
    }
  } else if (policy instanceof VersionLockingPolicy) {
    VersionLockingPolicy versionPolicy = (VersionLockingPolicy)policy;
    method.addLine("lockingPolicy.setWriteLockFieldName(\"" + versionPolicy.getWriteLockField().getQualifiedName() + "\");");
    if (versionPolicy.isStoredInObject()) {
      method.addLine("lockingPolicy.storeInObject();");
    }
    if (policy instanceof TimestampLockingPolicy) {
      TimestampLockingPolicy timestampPolicy = (TimestampLockingPolicy)policy;
      if (timestampPolicy.usesLocalTime()) {
        method.addLine("lockingPolicy.useLocalTime();");
      }
    }
  }
  method.addLine("descriptor.setOptimisticLockingPolicy(lockingPolicy);");
}
org.eclipse.persistence.descriptorsSelectedFieldsLockingPolicy

Javadoc

Purpose: An implementation of the OptimisticLockingPolicy interface. This policy compares selected fields in the WHERE clause when doing an update or a delete. If any field has been changed, an optimistic locking exception will be thrown. Note that the fields specified must be mapped and not be primary keys.

NOTE: This policy can only be used inside a unit of work.

Most used methods

  • <init>
    PUBLIC: Create a new selected fields locking policy. A field locking policy is based on locking on t
  • addLockFieldName
    PUBLIC: Add a fieldname to lock on. All fields in this list will be compared when Updating if the va
  • getLockFields
    INTERNAL: returns the lock fields based on the passed in table
  • getLockFieldsByTable
    INTERNAL: returns the lock fields
  • setLockFieldNames
    PUBLIC: Set the field names to lock on. All fields in this list will be compared when Updating. If t
  • verifyUsage

Popular in Java

  • Making http requests using okhttp
  • addToBackStack (FragmentTransaction)
  • getContentResolver (Context)
  • notifyDataSetChanged (ArrayAdapter)
  • GridBagLayout (java.awt)
    The GridBagLayout class is a flexible layout manager that aligns components vertically and horizonta
  • FileWriter (java.io)
    A specialized Writer that writes to a file in the file system. All write requests made by calling me
  • UUID (java.util)
    UUID is an immutable representation of a 128-bit universally unique identifier (UUID). There are mul
  • ZipFile (java.util.zip)
    This class provides random read access to a zip file. You pay more to read the zip file's central di
  • Annotation (javassist.bytecode.annotation)
    The annotation structure.An instance of this class is returned bygetAnnotations() in AnnotationsAttr
  • JTable (javax.swing)
  • Top plugins for WebStorm
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