congrats Icon
New! Tabnine Pro 14-day free trial
Start a free trial
Tabnine Logo
EISOneToOneMapping
Code IndexAdd Tabnine to your IDE (free)

How to use
EISOneToOneMapping
in
org.eclipse.persistence.eis.mappings

Best Java code snippets using org.eclipse.persistence.eis.mappings.EISOneToOneMapping (Showing top 20 results out of 315)

origin: org.eclipse.persistence/org.eclipse.persistence.core

/**
 * INTERNAL:
 * Initialize the mapping.
 */
@Override
public void initialize(AbstractSession session) throws DescriptorException {
  super.initialize(session);
  // Must build foreign keys fields.
  List foreignKeyFields = getForeignKeyFields();
  int size = foreignKeyFields.size();
  for (int index = 0; index < size; index++) {
    DatabaseField foreignKeyField = (DatabaseField)foreignKeyFields.get(index);
    foreignKeyField = getDescriptor().buildField(foreignKeyField);
    foreignKeyFields.set(index, foreignKeyField);
  }
  initializeForeignKeys(session);
  if (shouldInitializeSelectionCriteria()) {
    initializeSelectionCriteria(session);
  } else {
    setShouldVerifyDelete(false);
  }
  setFields(collectFields());
}
origin: org.eclipse.persistence/com.springsource.org.eclipse.persistence

/**
 * INTERNAL:
 * Get a value from the object and set that in the respective field of the row.
 */
public void writeFromObjectIntoRow(Object object, AbstractRecord Record, AbstractSession session) {
  if (isReadOnly() || (!isForeignKeyRelationship())) {
    return;
  }
  AbstractRecord referenceRow = getIndirectionPolicy().extractReferenceRow(getAttributeValueFromObject(object));
  if (referenceRow == null) {
    // Extract from object.
    Object referenceObject = getRealAttributeValueFromObject(object, session);
    for (int i = 0; i < getForeignKeyFields().size(); i++) {
      DatabaseField sourceKey = getForeignKeyFields().get(i);
      DatabaseField targetKey = (DatabaseField)getSourceToTargetKeyFields().get(sourceKey);
      Object referenceValue = null;
      // If privately owned part is null then method cannot be invoked.
      if (referenceObject != null) {
        referenceValue = getReferenceDescriptor().getObjectBuilder().extractValueFromObjectForField(referenceObject, targetKey, session);
      }
      Record.add(sourceKey, referenceValue);
    }
  } else {
    for (int i = 0; i < getForeignKeyFields().size(); i++) {
      DatabaseField sourceKey = getForeignKeyFields().get(i);
      Record.add(sourceKey, referenceRow.get(sourceKey));
    }
  }
}
origin: org.eclipse.persistence/com.springsource.org.eclipse.persistence

/**
   * PUBLIC:
   * Define the source foreign key relationship in the one-to-one mapping.
   * This method is used to add foreign key relationships to the mapping.
   * Both the source foreign key field name and the corresponding
   * target primary key field name must be specified.
   */
public void addForeignKeyField(DatabaseField sourceForeignKeyField, DatabaseField targetKeyField) {
  this.getSourceToTargetKeyFields().put(sourceForeignKeyField, targetKeyField);
  this.getTargetToSourceKeyFields().put(targetKeyField, sourceForeignKeyField);
  this.getForeignKeyFields().add(sourceForeignKeyField);
  this.setIsForeignKeyRelationship(true);
}
origin: org.eclipse.persistence/com.springsource.org.eclipse.persistence

/**
 * INTERNAL:
 * The foreign keys primary keys are stored as database fields in the hashtable.
 */
protected void initializeForeignKeys(AbstractSession session) {
  HashMap newSourceToTargetKeyFields = new HashMap(getSourceToTargetKeyFields().size());
  HashMap newTargetToSourceKeyFields = new HashMap(getTargetToSourceKeyFields().size());
  Iterator iterator = getSourceToTargetKeyFields().entrySet().iterator();
  while (iterator.hasNext()) {
    Map.Entry entry = (Map.Entry)iterator.next();
    DatabaseField sourceField = (DatabaseField)entry.getKey();
    DatabaseField targetField = (DatabaseField)entry.getValue();
    sourceField = getDescriptor().buildField(sourceField);
    targetField = getReferenceDescriptor().buildField(targetField);
    newSourceToTargetKeyFields.put(sourceField, targetField);
    newTargetToSourceKeyFields.put(targetField, sourceField);
  }
  setSourceToTargetKeyFields(newSourceToTargetKeyFields);
  setTargetToSourceKeyFields(newTargetToSourceKeyFields);
}
origin: org.eclipse.persistence/com.springsource.org.eclipse.persistence

clone.setForeignKeyFields(org.eclipse.persistence.internal.helper.NonSynchronizedVector.newInstance(getForeignKeyFields().size()));
clone.setSourceToTargetKeyFields(new HashMap(getSourceToTargetKeyFields().size()));
clone.setTargetToSourceKeyFields(new HashMap(getTargetToSourceKeyFields().size()));
Map setOfFields = new HashMap(getTargetToSourceKeyFields().size());
for (Enumeration enumtr = getForeignKeyFields().elements(); enumtr.hasMoreElements();) {
  DatabaseField field = (DatabaseField)enumtr.nextElement();
  clone.getForeignKeyFields().addElement(fieldClone);
Iterator sourceKeyIterator = getSourceToTargetKeyFields().keySet().iterator();
while (sourceKeyIterator.hasNext()) {
  DatabaseField sourceField = (DatabaseField)sourceKeyIterator.next();
  DatabaseField targetField = (DatabaseField)getSourceToTargetKeyFields().get(sourceField);
    setOfFields.put(sourceField, sourceClone);
  clone.getSourceToTargetKeyFields().put(sourceClone, targetClone);
Iterator targetKeyIterator = getTargetToSourceKeyFields().keySet().iterator();
while (targetKeyIterator.hasNext()) {
  DatabaseField targetField = (DatabaseField)targetKeyIterator.next();
  DatabaseField sourceField = (DatabaseField)getTargetToSourceKeyFields().get(targetField);
    setOfFields.put(sourceField, sourceClone);
  clone.getTargetToSourceKeyFields().put(targetClone, sourceClone);
origin: org.eclipse.persistence/org.eclipse.persistence.core

/**
 * INTERNAL:
 * Selection criteria is created with source foreign keys and target keys.
 */
protected void initializePrivateOwnedCriteria() {
  if (!isForeignKeyRelationship()) {
    setPrivateOwnedCriteria(getSelectionCriteria());
  } else {
    Expression pkCriteria = getDescriptor().getObjectBuilder().getPrimaryKeyExpression();
    ExpressionBuilder builder = new ExpressionBuilder();
    Expression backRef = builder.getManualQueryKey(getAttributeName() + "-back-ref", getDescriptor());
    Expression newPKCriteria = pkCriteria.rebuildOn(backRef);
    Expression twistedSelection = backRef.twist(getSelectionCriteria(), builder);
    if (getDescriptor().getQueryManager().getAdditionalJoinExpression() != null) {
      // We don't have to twist the additional join because it's all against the same node, which is our base
      // but we do have to rebuild it onto the manual query key
      Expression rebuiltAdditional = getDescriptor().getQueryManager().getAdditionalJoinExpression().rebuildOn(backRef);
      if (twistedSelection == null) {
        twistedSelection = rebuiltAdditional;
      } else {
        twistedSelection = twistedSelection.and(rebuiltAdditional);
      }
    }
    setPrivateOwnedCriteria(newPKCriteria.and(twistedSelection));
  }
}
origin: org.eclipse.persistence/com.springsource.org.eclipse.persistence

  for (Enumeration enumeration = getFields().elements(); enumeration.hasMoreElements();) {
    DatabaseField field = (DatabaseField)enumeration.nextElement();
    if (row.get(field) == null) {
      return getIndirectionPolicy().nullValueFromRow();
ReadQuery targetQuery = getSelectionQuery();
if (targetQuery.isObjectLevelReadQuery() && (query.shouldCascadeAllParts() || (query.shouldCascadePrivateParts() && isPrivateOwned()) || (query.shouldCascadeByMapping() && this.cascadeRefresh))) {
  targetQuery = (ObjectLevelReadQuery)targetQuery.clone();
  ((ObjectLevelReadQuery)targetQuery).setShouldRefreshIdentityMapResult(query.shouldRefreshIdentityMapResult());
return getIndirectionPolicy().valueFromQuery(targetQuery, row, query.getSession());
origin: org.eclipse.persistence/com.springsource.org.eclipse.persistence

/**
 * INTERNAL:
 * Reads the private owned object.
 */
protected Object readPrivateOwnedForObject(ObjectLevelModifyQuery modifyQuery) throws DatabaseException {
  if (modifyQuery.getSession().isUnitOfWork()) {
    return getRealAttributeValueFromObject(modifyQuery.getBackupClone(), modifyQuery.getSession());
  } else {
    if (!shouldVerifyDelete()) {
      return null;
    }
    ReadObjectQuery readQuery = (ReadObjectQuery)getSelectionQuery().clone();
    readQuery.setSelectionCriteria(getPrivateOwnedCriteria());
    return modifyQuery.getSession().executeQuery(readQuery, modifyQuery.getTranslationRow());
  }
}
origin: org.eclipse.persistence/com.springsource.org.eclipse.persistence

/**
 * INTERNAL:
 * Extract the foreign key value from the source row.
 */
protected Vector extractForeignKeyFromRow(AbstractRecord row, AbstractSession session) {
  Vector key = new Vector();
  Iterator sourceKeyIterator = getSourceToTargetKeyFields().keySet().iterator();
  while (sourceKeyIterator.hasNext()) {
    DatabaseField field = (DatabaseField)sourceKeyIterator.next();
    Object value = row.get(field);
    // Must ensure the classification gets a cache hit.
    try {
      value = session.getDatasourcePlatform().getConversionManager().convertObject(value, getDescriptor().getObjectBuilder().getFieldClassification(field));
    } catch (ConversionException e) {
      throw ConversionException.couldNotBeConverted(this, getDescriptor(), e);
    }
    key.addElement(value);
  }
  return key;
}
origin: org.eclipse.persistence/org.eclipse.persistence.core

/**
 * PUBLIC:
 * Define the source foreign key relationship in the one-to-one mapping.
 * This method is used to add foreign key relationships to the mapping.
 * Both the source foreign key field name and the corresponding
 * target primary key field name must be specified.
 */
public void addForeignKeyFieldName(String sourceForeignKeyFieldName, String targetKeyFieldName) {
  this.addForeignKeyField(new DatabaseField(sourceForeignKeyFieldName), new DatabaseField(targetKeyFieldName));
}
origin: org.eclipse.persistence/org.eclipse.persistence.core

/**
 * INTERNAL:
 * The foreign keys primary keys are stored as database fields in the hashtable.
 */
protected void initializeForeignKeys(AbstractSession session) {
  HashMap newSourceToTargetKeyFields = new HashMap(getSourceToTargetKeyFields().size());
  HashMap newTargetToSourceKeyFields = new HashMap(getTargetToSourceKeyFields().size());
  Iterator iterator = getSourceToTargetKeyFields().entrySet().iterator();
  while (iterator.hasNext()) {
    Map.Entry entry = (Map.Entry)iterator.next();
    DatabaseField sourceField = (DatabaseField)entry.getKey();
    DatabaseField targetField = (DatabaseField)entry.getValue();
    sourceField = getDescriptor().buildField(sourceField);
    targetField = getReferenceDescriptor().buildField(targetField);
    newSourceToTargetKeyFields.put(sourceField, targetField);
    newTargetToSourceKeyFields.put(targetField, sourceField);
  }
  setSourceToTargetKeyFields(newSourceToTargetKeyFields);
  setTargetToSourceKeyFields(newTargetToSourceKeyFields);
}
origin: org.eclipse.persistence/org.eclipse.persistence.core

public Object clone() {
  EISOneToOneMapping clone = (EISOneToOneMapping)super.clone();
  clone.setForeignKeyFields(org.eclipse.persistence.internal.helper.NonSynchronizedVector.newInstance(getForeignKeyFields().size()));
  clone.setSourceToTargetKeyFields(new HashMap(getSourceToTargetKeyFields().size()));
  clone.setTargetToSourceKeyFields(new HashMap(getTargetToSourceKeyFields().size()));
  Map setOfFields = new HashMap(getTargetToSourceKeyFields().size());
  for (Enumeration enumtr = getForeignKeyFields().elements(); enumtr.hasMoreElements();) {
    DatabaseField field = (DatabaseField)enumtr.nextElement();
    clone.getForeignKeyFields().addElement(fieldClone);
  Iterator sourceKeyIterator = getSourceToTargetKeyFields().keySet().iterator();
  while (sourceKeyIterator.hasNext()) {
    DatabaseField sourceField = (DatabaseField)sourceKeyIterator.next();
    DatabaseField targetField = getSourceToTargetKeyFields().get(sourceField);
      setOfFields.put(sourceField, sourceClone);
    clone.getSourceToTargetKeyFields().put(sourceClone, targetClone);
  Iterator targetKeyIterator = getTargetToSourceKeyFields().keySet().iterator();
  while (targetKeyIterator.hasNext()) {
    DatabaseField targetField = (DatabaseField)targetKeyIterator.next();
    DatabaseField sourceField = getTargetToSourceKeyFields().get(targetField);
    clone.getTargetToSourceKeyFields().put(targetClone, sourceClone);
origin: org.eclipse.persistence/com.springsource.org.eclipse.persistence

/**
 * INTERNAL:
 * Selection criteria is created with source foreign keys and target keys.
 */
protected void initializePrivateOwnedCriteria() {
  if (!isForeignKeyRelationship()) {
    setPrivateOwnedCriteria(getSelectionCriteria());
  } else {
    Expression pkCriteria = getDescriptor().getObjectBuilder().getPrimaryKeyExpression();
    ExpressionBuilder builder = new ExpressionBuilder();
    Expression backRef = builder.getManualQueryKey(getAttributeName() + "-back-ref", getDescriptor());
    Expression newPKCriteria = pkCriteria.rebuildOn(backRef);
    Expression twistedSelection = backRef.twist(getSelectionCriteria(), builder);
    if (getDescriptor().getQueryManager().getAdditionalJoinExpression() != null) {
      // We don't have to twist the additional join because it's all against the same node, which is our base
      // but we do have to rebuild it onto the manual query key
      Expression rebuiltAdditional = getDescriptor().getQueryManager().getAdditionalJoinExpression().rebuildOn(backRef);
      if (twistedSelection == null) {
        twistedSelection = rebuiltAdditional;
      } else {
        twistedSelection = twistedSelection.and(rebuiltAdditional);
      }
    }
    setPrivateOwnedCriteria(newPKCriteria.and(twistedSelection));
  }
}
origin: com.haulmont.thirdparty/eclipselink

        wasCacheUsed[0] = Boolean.TRUE;
      return this.getAttributeValueFromObject(cached);
  for (Enumeration enumeration = getFields().elements(); enumeration.hasMoreElements();) {
    DatabaseField field = (DatabaseField)enumeration.nextElement();
    if (row.get(field) == null) {
      return getIndirectionPolicy().nullValueFromRow();
ReadQuery targetQuery = getSelectionQuery();
if (targetQuery.isObjectLevelReadQuery() && (query.shouldCascadeAllParts() || (query.shouldCascadePrivateParts() && isPrivateOwned()) || (query.shouldCascadeByMapping() && this.cascadeRefresh))) {
  targetQuery = (ObjectLevelReadQuery)targetQuery.clone();
  ((ObjectLevelReadQuery)targetQuery).setShouldRefreshIdentityMapResult(query.shouldRefreshIdentityMapResult());
return getIndirectionPolicy().valueFromQuery(targetQuery, row, query.getSession());
origin: org.eclipse.persistence/org.eclipse.persistence.core

/**
 * PUBLIC:
 * Define the source foreign key relationship in the one-to-one mapping.
 * This method is used to add foreign key relationships to the mapping.
 * Both the source foreign key field name and the corresponding
 * target primary key field name must be specified.
 */
@Override
public void addForeignKeyField(DatabaseField sourceForeignKeyField, DatabaseField targetKeyField) {
  getSourceToTargetKeyFields().put(sourceForeignKeyField, targetKeyField);
  getTargetToSourceKeyFields().put(targetKeyField, sourceForeignKeyField);
  getForeignKeyFields().add(sourceForeignKeyField);
  setIsForeignKeyRelationship(true);
}
origin: org.eclipse.persistence/org.eclipse.persistence.core

/**
 * INTERNAL:
 * Reads the private owned object.
 */
@Override
protected Object readPrivateOwnedForObject(ObjectLevelModifyQuery modifyQuery) throws DatabaseException {
  if (modifyQuery.getSession().isUnitOfWork()) {
    return getRealAttributeValueFromObject(modifyQuery.getBackupClone(), modifyQuery.getSession());
  } else {
    if (!shouldVerifyDelete()) {
      return null;
    }
    ReadObjectQuery readQuery = (ReadObjectQuery)getSelectionQuery().clone();
    readQuery.setSelectionCriteria(getPrivateOwnedCriteria());
    return modifyQuery.getSession().executeQuery(readQuery, modifyQuery.getTranslationRow());
  }
}
origin: org.eclipse.persistence/com.springsource.org.eclipse.persistence

/**
 * PUBLIC:
 * Define the source foreign key relationship in the one-to-one mapping.
 * This method is used to add foreign key relationships to the mapping.
 * Both the source foreign key field name and the corresponding
 * target primary key field name must be specified.
 */
public void addForeignKeyFieldName(String sourceForeignKeyFieldName, String targetKeyFieldName) {
  this.addForeignKeyField(new DatabaseField(sourceForeignKeyFieldName), new DatabaseField(targetKeyFieldName));
}
origin: org.eclipse.persistence/com.springsource.org.eclipse.persistence

/**
 * INTERNAL:
 * Initialize the mapping.
 */
public void initialize(AbstractSession session) throws DescriptorException {
  super.initialize(session);
  // Must build foreign keys fields.
  List foreignKeyFields = getForeignKeyFields();
  int size = foreignKeyFields.size();
  for (int index = 0; index < size; index++) {
    DatabaseField foreignKeyField = (DatabaseField)foreignKeyFields.get(index);
    foreignKeyField = getDescriptor().buildField(foreignKeyField);
    foreignKeyFields.set(index, foreignKeyField);
  }
  initializeForeignKeys(session);
  if (shouldInitializeSelectionCriteria()) {
    initializeSelectionCriteria(session);
  } else {
    setShouldVerifyDelete(false);
  }
  setFields(collectFields());
}
origin: com.haulmont.thirdparty/eclipselink

/**
 * INTERNAL:
 * Get a value from the object and set that in the respective field of the row.
 */
@Override
public void writeFromObjectIntoRow(Object object, AbstractRecord Record, AbstractSession session, WriteType writeType) {
  if (isReadOnly() || (!isForeignKeyRelationship())) {
    return;
  }
  AbstractRecord referenceRow = getIndirectionPolicy().extractReferenceRow(getAttributeValueFromObject(object));
  if (referenceRow == null) {
    // Extract from object.
    Object referenceObject = getRealAttributeValueFromObject(object, session);
    for (int i = 0; i < getForeignKeyFields().size(); i++) {
      DatabaseField sourceKey = getForeignKeyFields().get(i);
      DatabaseField targetKey = getSourceToTargetKeyFields().get(sourceKey);
      Object referenceValue = null;
      // If privately owned part is null then method cannot be invoked.
      if (referenceObject != null) {
        referenceValue = getReferenceDescriptor().getObjectBuilder().extractValueFromObjectForField(referenceObject, targetKey, session);
      }
      Record.add(sourceKey, referenceValue);
    }
  } else {
    for (int i = 0; i < getForeignKeyFields().size(); i++) {
      DatabaseField sourceKey = getForeignKeyFields().get(i);
      Record.add(sourceKey, referenceRow.get(sourceKey));
    }
  }
}
origin: com.haulmont.thirdparty/eclipselink

/**
 * INTERNAL:
 * The foreign keys primary keys are stored as database fields in the hashtable.
 */
protected void initializeForeignKeys(AbstractSession session) {
  HashMap newSourceToTargetKeyFields = new HashMap(getSourceToTargetKeyFields().size());
  HashMap newTargetToSourceKeyFields = new HashMap(getTargetToSourceKeyFields().size());
  Iterator iterator = getSourceToTargetKeyFields().entrySet().iterator();
  while (iterator.hasNext()) {
    Map.Entry entry = (Map.Entry)iterator.next();
    DatabaseField sourceField = (DatabaseField)entry.getKey();
    DatabaseField targetField = (DatabaseField)entry.getValue();
    sourceField = getDescriptor().buildField(sourceField);
    targetField = getReferenceDescriptor().buildField(targetField);
    newSourceToTargetKeyFields.put(sourceField, targetField);
    newTargetToSourceKeyFields.put(targetField, sourceField);
  }
  setSourceToTargetKeyFields(newSourceToTargetKeyFields);
  setTargetToSourceKeyFields(newTargetToSourceKeyFields);
}
org.eclipse.persistence.eis.mappingsEISOneToOneMapping

Javadoc

An EIS one-to-one mapping is a reference mapping that represents the relationship between a single source object and a single mapped persistent Java object. The source object usually contains a foreign key (pointer) to the target object (key on source); alternatively, the target object may contiain a foreign key to the source object (key on target). Because both the source and target objects use interactions, they must both be configured as root object types.

Record Type Description
Indexed Ordered collection of record elements. The indexed record EIS format enables Java class attribute values to be retrieved by position or index.
Mapped Key-value map based representation of record elements. The mapped record EIS format enables Java class attribute values to be retrieved by an object key.
XML Record/Map representation of an XML DOM element.

Most used methods

  • addForeignKeyField
    PUBLIC: Define the source foreign key relationship in the one-to-one mapping. This method is used to
  • collectFields
  • getAttributeName
  • getAttributeValueFromObject
  • getDescriptor
  • getFields
  • getForeignKeyFields
  • getIndirectionPolicy
  • getPrivateOwnedCriteria
    INTERNAL: The private owned criteria is only used outside of the unit of work to compare the previou
  • getRealAttributeValueFromObject
  • getReferenceDescriptor
  • getSelectionCriteria
  • getReferenceDescriptor,
  • getSelectionCriteria,
  • getSelectionQuery,
  • getSourceToTargetKeyFields,
  • getTargetToSourceKeyFields,
  • initializeForeignKeys,
  • initializePrivateOwnedCriteria,
  • initializeSelectionCriteria,
  • isForeignKeyRelationship,
  • isPrivateOwned

Popular in Java

  • Updating database using SQL prepared statement
  • runOnUiThread (Activity)
  • getResourceAsStream (ClassLoader)
  • getSharedPreferences (Context)
  • InputStream (java.io)
    A readable source of bytes.Most clients will use input streams that read data from the file system (
  • URLEncoder (java.net)
    This class is used to encode a string using the format required by application/x-www-form-urlencoded
  • Date (java.util)
    A specific moment in time, with millisecond precision. Values typically come from System#currentTime
  • HashMap (java.util)
    HashMap is an implementation of Map. All optional operations are supported.All elements are permitte
  • Filter (javax.servlet)
    A filter is an object that performs filtering tasks on either the request to a resource (a servlet o
  • IOUtils (org.apache.commons.io)
    General IO stream manipulation utilities. This class provides static utility methods for input/outpu
  • Top 12 Jupyter Notebook Extensions
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

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