Codota Logo
OneToOne.targetEntity
Code IndexAdd Codota to your IDE (free)

How to use
targetEntity
method
in
javax.persistence.OneToOne

Best Java code snippets using javax.persistence.OneToOne.targetEntity (Showing top 20 results out of 315)

  • Common ways to obtain OneToOne
private void myMethod () {
OneToOne o =
  • Codota IconField field;field.getAnnotation(OneToOne.class)
  • Codota IconXProperty property;property.getAnnotation(OneToOne.class)
  • Codota IconAccessibleObject accessibleObject;accessibleObject.getAnnotation(OneToOne.class)
  • Smart code suggestions by Codota
}
origin: BroadleafCommerce/BroadleafCommerce

protected Class<?> getValueType(PopulateValueRequest populateValueRequest, Class<?> startingValueType) {
  Class<?> valueType = startingValueType;
  if (!StringUtils.isEmpty(populateValueRequest.getMetadata().getToOneTargetProperty())) {
    Field nestedField = FieldManager.getSingleField(valueType, populateValueRequest.getMetadata()
        .getToOneTargetProperty());
    ManyToOne manyToOne = nestedField.getAnnotation(ManyToOne.class);
    if (manyToOne != null && !manyToOne.targetEntity().getName().equals(void.class.getName())) {
      valueType = manyToOne.targetEntity();
    } else {
      OneToOne oneToOne = nestedField.getAnnotation(OneToOne.class);
      if (oneToOne != null && !oneToOne.targetEntity().getName().equals(void.class.getName())) {
        valueType = oneToOne.targetEntity();
      }
    }
  }
  return valueType;
}
origin: hibernate/hibernate-orm

  private static Class<?> getTargetEntityClass(XProperty property) {
    final ManyToOne mTo = property.getAnnotation( ManyToOne.class );
    if (mTo != null) {
      return mTo.targetEntity();
    }
    final OneToOne oTo = property.getAnnotation( OneToOne.class );
    if (oTo != null) {
      return oTo.targetEntity();
    }
    throw new AssertionFailure("Unexpected discovery of a targetEntity: " + property.getName() );
  }
}
origin: hibernate/hibernate-orm

ad.setValue( "targetEntity", oneToOne.targetEntity() );
ad.setValue( "fetch", oneToOne.fetch() );
ad.setValue( "optional", oneToOne.optional() );
origin: hibernate/hibernate-orm

public static CtClass getTargetEntityClass(CtClass managedCtClass, CtField persistentField) throws NotFoundException {
  // get targetEntity defined in the annotation
  try {
    OneToOne oto = PersistentAttributesHelper.getAnnotation( persistentField, OneToOne.class );
    OneToMany otm = PersistentAttributesHelper.getAnnotation( persistentField, OneToMany.class );
    ManyToOne mto = PersistentAttributesHelper.getAnnotation( persistentField, ManyToOne.class );
    ManyToMany mtm = PersistentAttributesHelper.getAnnotation( persistentField, ManyToMany.class );
    Class<?> targetClass = null;
    if ( oto != null ) {
      targetClass = oto.targetEntity();
    }
    if ( otm != null ) {
      targetClass = otm.targetEntity();
    }
    if ( mto != null ) {
      targetClass = mto.targetEntity();
    }
    if ( mtm != null ) {
      targetClass = mtm.targetEntity();
    }
    if ( targetClass != null && targetClass != void.class ) {
      return managedCtClass.getClassPool().get( targetClass.getName() );
    }
  }
  catch (NotFoundException ignore) {
  }
  // infer targetEntity from generic type signature
  String inferredTypeName = inferTypeName( managedCtClass, persistentField.getName() );
  return inferredTypeName == null ? null : managedCtClass.getClassPool().get( inferredTypeName );
}
origin: hibernate/hibernate-orm

private static boolean discoverTypeWithoutReflection(XProperty p) {
  if ( p.isAnnotationPresent( OneToOne.class ) && !p.getAnnotation( OneToOne.class )
      .targetEntity()
      .equals( void.class ) ) {
    return true;
origin: BroadleafCommerce/BroadleafCommerce

} else {
  OneToOne oneToOne = nestedField.getAnnotation(OneToOne.class);
  if (oneToOne != null && !oneToOne.targetEntity().getName().equals(void.class.getName())) {
    valueClassName = oneToOne.targetEntity().getName();
origin: org.hibernate/hibernate-annotations

  private static Class<?> getTargetEntityClass(XProperty property) {
    final ManyToOne mTo = property.getAnnotation( ManyToOne.class );
    if (mTo != null) {
      return mTo.targetEntity();
    }
    final OneToOne oTo = property.getAnnotation( OneToOne.class );
    if (oTo != null) {
      return oTo.targetEntity();
    }
    throw new AssertionFailure("Unexpected discovery of a targetEntity: " + property.getName() );
  }
}
origin: toplink.essentials/toplink-essentials

/**
 * INTERNAL: (Overridden in XMLOneToOneAccessor)
 */
public Class getTargetEntity() {
  return (m_oneToOne == null) ? void.class : m_oneToOne.targetEntity();
}

origin: org.hibernate/hibernate-annotations

private static boolean discoverTypeWithoutReflection(XProperty p) {
  if ( p.isAnnotationPresent( OneToOne.class ) && !p.getAnnotation( OneToOne.class )
      .targetEntity()
      .equals( void.class ) ) {
    return true;
origin: com.haulmont.cuba/cuba-global

protected Class getFieldTypeAccordingAnnotations(Field field) {
  OneToOne oneToOneAnnotation = field.getAnnotation(OneToOne.class);
  OneToMany oneToManyAnnotation = field.getAnnotation(OneToMany.class);
  ManyToOne manyToOneAnnotation = field.getAnnotation(ManyToOne.class);
  ManyToMany manyToManyAnnotation = field.getAnnotation(ManyToMany.class);
  Class result = null;
  if (oneToOneAnnotation != null) {
    result = oneToOneAnnotation.targetEntity();
  } else if (oneToManyAnnotation != null) {
    result = oneToManyAnnotation.targetEntity();
  } else if (manyToOneAnnotation != null) {
    result = manyToOneAnnotation.targetEntity();
  } else if (manyToManyAnnotation != null) {
    result = manyToManyAnnotation.targetEntity();
  }
  return result;
}
origin: io.github.itfinally/mybatis-jpa

  private Class<?> getTargetEntity() {
    if ( oneToOne != null ) {
      return oneToOne.targetEntity();
    }
    if ( oneToMany != null ) {
      return oneToMany.targetEntity();
    }
    if ( manyToOne != null ) {
      return manyToOne.targetEntity();
    }
    return null;
  }
}
origin: org.hibernate/com.springsource.org.hibernate

  private static Class<?> getTargetEntityClass(XProperty property) {
    final ManyToOne mTo = property.getAnnotation( ManyToOne.class );
    if (mTo != null) {
      return mTo.targetEntity();
    }
    final OneToOne oTo = property.getAnnotation( OneToOne.class );
    if (oTo != null) {
      return oTo.targetEntity();
    }
    throw new AssertionFailure("Unexpected discovery of a targetEntity: " + property.getName() );
  }
}
origin: org.hibernate/com.springsource.org.hibernate.core

  private static Class<?> getTargetEntityClass(XProperty property) {
    final ManyToOne mTo = property.getAnnotation( ManyToOne.class );
    if (mTo != null) {
      return mTo.targetEntity();
    }
    final OneToOne oTo = property.getAnnotation( OneToOne.class );
    if (oTo != null) {
      return oTo.targetEntity();
    }
    throw new AssertionFailure("Unexpected discovery of a targetEntity: " + property.getName() );
  }
}
origin: com.caucho/resin

private void introspectOneToOne(OneToOne oneToOne)
{
 Class targetClass = oneToOne.targetEntity();
 if (void.class.equals(targetClass))
  targetClass = _fieldType;
 
 setTargetEntity(targetClass);
 
 setCascadeTypes(oneToOne.cascade());
 setFetch(oneToOne.fetch());
 
 _isOptional = oneToOne.optional();
 _mappedBy = oneToOne.mappedBy();
}

origin: org.hibernate.orm/hibernate-core

  private static Class<?> getTargetEntityClass(XProperty property) {
    final ManyToOne mTo = property.getAnnotation( ManyToOne.class );
    if (mTo != null) {
      return mTo.targetEntity();
    }
    final OneToOne oTo = property.getAnnotation( OneToOne.class );
    if (oTo != null) {
      return oTo.targetEntity();
    }
    throw new AssertionFailure("Unexpected discovery of a targetEntity: " + property.getName() );
  }
}
origin: org.apache.openjpa/com.springsource.org.apache.openjpa

/**
 * Parse @OneToOne.
 */
private void parseOneToOne(FieldMetaData fmd, OneToOne anno) {
  if (!JavaTypes.maybePC(fmd.getValue()))
    throw new MetaDataException(_loc.get("bad-meta-anno", fmd,
      "OneToOne"));
  // don't specifically exclude relation from DFG b/c that will prevent
  // us from even reading the fk when reading from the primary table,
  // which is not what most users will want
  if (anno.fetch() == FetchType.EAGER)
    fmd.setInDefaultFetchGroup(true);
  if (!anno.optional())
    fmd.setNullValue(FieldMetaData.NULL_EXCEPTION);
  if (isMappingOverrideMode() && !StringUtils.isEmpty(anno.mappedBy()))
    fmd.setMappedBy(anno.mappedBy());
  if (anno.targetEntity() != void.class)
    fmd.setTypeOverride(anno.targetEntity());
  setCascades(fmd, anno.cascade());
}
origin: org.apache.openejb.patch/openjpa-persistence

/**
 * Parse @OneToOne.
 */
private void parseOneToOne(FieldMetaData fmd, OneToOne anno) {
  if (!JavaTypes.maybePC(fmd.getValue()))
    throw new MetaDataException(_loc.get("bad-meta-anno", fmd,
      "OneToOne"));
  // don't specifically exclude relation from DFG b/c that will prevent
  // us from even reading the fk when reading from the primary table,
  // which is not what most users will want
  if (anno.fetch() == FetchType.EAGER)
    fmd.setInDefaultFetchGroup(true);
  if (!anno.optional())
    fmd.setNullValue(FieldMetaData.NULL_EXCEPTION);
  if (isMappingOverrideMode() && !StringUtils.isEmpty(anno.mappedBy()))
    fmd.setMappedBy(anno.mappedBy());
  if (anno.targetEntity() != void.class)
    fmd.setTypeOverride(anno.targetEntity());
  setCascades(fmd, anno.cascade());
  setOrphanRemoval(fmd, anno.orphanRemoval());
  fmd.setAssociationType(FieldMetaData.ONE_TO_ONE);
}
origin: org.apache.openjpa/openjpa-persistence

/**
 * Parse @OneToOne.
 */
private void parseOneToOne(FieldMetaData fmd, OneToOne anno) {
  if (!JavaTypes.maybePC(fmd.getValue()))
    throw new MetaDataException(_loc.get("bad-meta-anno", fmd,
      "OneToOne"));
  // don't specifically exclude relation from DFG b/c that will prevent
  // us from even reading the fk when reading from the primary table,
  // which is not what most users will want
  if (anno.fetch() == FetchType.EAGER)
    fmd.setInDefaultFetchGroup(true);
  if (!anno.optional())
    fmd.setNullValue(FieldMetaData.NULL_EXCEPTION);
  if (isMappingOverrideMode() && !StringUtil.isEmpty(anno.mappedBy()))
    fmd.setMappedBy(anno.mappedBy());
  if (anno.targetEntity() != void.class)
    fmd.setTypeOverride(anno.targetEntity());
  setCascades(fmd, anno.cascade());
  setOrphanRemoval(fmd, anno.orphanRemoval());
  fmd.setAssociationType(FieldMetaData.ONE_TO_ONE);
}
origin: org.apache.openjpa/openjpa-all

/**
 * Parse @OneToOne.
 */
private void parseOneToOne(FieldMetaData fmd, OneToOne anno) {
  if (!JavaTypes.maybePC(fmd.getValue()))
    throw new MetaDataException(_loc.get("bad-meta-anno", fmd,
      "OneToOne"));
  // don't specifically exclude relation from DFG b/c that will prevent
  // us from even reading the fk when reading from the primary table,
  // which is not what most users will want
  if (anno.fetch() == FetchType.EAGER)
    fmd.setInDefaultFetchGroup(true);
  if (!anno.optional())
    fmd.setNullValue(FieldMetaData.NULL_EXCEPTION);
  if (isMappingOverrideMode() && !StringUtil.isEmpty(anno.mappedBy()))
    fmd.setMappedBy(anno.mappedBy());
  if (anno.targetEntity() != void.class)
    fmd.setTypeOverride(anno.targetEntity());
  setCascades(fmd, anno.cascade());
  setOrphanRemoval(fmd, anno.orphanRemoval());
  fmd.setAssociationType(FieldMetaData.ONE_TO_ONE);
}
origin: org.streampipes/streampipes-empire-core

/**
 * Return the value of the targetEntity for the accessor if it has a {@link OneToOne}, {@link OneToMany},
 * {@link ManyToOne}, {@link OneToOne}, or {@link ManyToMany} annotation.  This will return null if the accessor
 * is not an {@link AccessibleObject} or if it does not have one of the aforementioned annotations, or if the
 * targetEntity is not set for the annotation
 * @param theAccessor the accessor
 * @return the targetEntity for the accessor, or null if not specified.
 */
public static Class<?> getTargetEntity(Object theAccessor) {
  Class<?> aClass = null;
  if (theAccessor instanceof AccessibleObject) {
    AccessibleObject aObject = (AccessibleObject) theAccessor;
    if (aObject.getAnnotation(OneToMany.class) != null) {
      aClass = aObject.getAnnotation(OneToMany.class).targetEntity();
    }
    else if (aObject.getAnnotation(OneToOne.class) != null) {
      aClass = aObject.getAnnotation(OneToOne.class).targetEntity();
    }
    else if (aObject.getAnnotation(ManyToOne.class) != null) {
      aClass = aObject.getAnnotation(ManyToOne.class).targetEntity();
    }
    else if (aObject.getAnnotation(ManyToMany.class) != null) {
      aClass = aObject.getAnnotation(ManyToMany.class).targetEntity();
    }
  }
  return aClass;
}
javax.persistenceOneToOnetargetEntity

Popular methods of OneToOne

  • <init>
  • mappedBy
  • cascade
  • fetch
  • optional
  • orphanRemoval

Popular in Java

  • Start an intent from android
  • orElseThrow (Optional)
    Return the contained value, if present, otherwise throw an exception to be created by the provided s
  • getContentResolver (Context)
  • getSupportFragmentManager (FragmentActivity)
    Return the FragmentManager for interacting with fragments associated with this activity.
  • HttpURLConnection (java.net)
    An URLConnection for HTTP (RFC 2616 [http://tools.ietf.org/html/rfc2616]) used to send and receive d
  • Dictionary (java.util)
    The Dictionary class is the abstract parent of any class, such as Hashtable, which maps keys to valu
  • List (java.util)
    A List is a collection which maintains an ordering for its elements. Every element in the List has a
  • Vector (java.util)
    The Vector class implements a growable array of objects. Like an array, it contains components that
  • JComboBox (javax.swing)
  • JTextField (javax.swing)
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now