微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

javax.persistence.OneToOne的实例源码

项目:Equella    文件Property.java   
private boolean isCascadeAll()
{
    OnetoMany onetomany = getAnnotation(OnetoMany.class);
    if( onetomany != null )
    {
        return hasCascadeAll(onetomany.cascade());
    }
    OnetoOne onetoone = getAnnotation(OnetoOne.class);
    if( onetoone != null )
    {
        return hasCascadeAll(onetoone.cascade());
    }
    ManyToOne manyToOne = getAnnotation(ManyToOne.class);
    if( manyToOne != null )
    {
        return hasCascadeAll(manyToOne.cascade());
    }
    // CollectionOfElements is a 'default' cascade all
    if( getAnnotation(CollectionOfElements.class) != null )
    {
        return true;
    }

    return false;
}
项目:crnk-framework    文件JpaMetaFilter.java   
private String getMappedBy(MetaAttribute attr) {
    ManyToMany manyManyAnnotation = attr.getAnnotation(ManyToMany.class);
    OnetoMany oneManyAnnotation = attr.getAnnotation(OnetoMany.class);
    OnetoOne oneOneAnnotation = attr.getAnnotation(OnetoOne.class);
    String mappedBy = null;
    if (manyManyAnnotation != null) {
        mappedBy = manyManyAnnotation.mappedBy();
    }
    if (oneManyAnnotation != null) {
        mappedBy = oneManyAnnotation.mappedBy();
    }
    if (oneOneAnnotation != null) {
        mappedBy = oneOneAnnotation.mappedBy();
    }

    if (mappedBy != null && mappedBy.length() == 0) {
        mappedBy = null;
    }
    return mappedBy;
}
项目:crnk-framework    文件JpaResourceField@R_421_404[email protected]   
@Override
public Optional<ResourceFieldType> getFieldType(BeanAttribute@R_421_4045@ion attributeDesc) {
    Optional<OnetoOne> onetoOne = attributeDesc.getAnnotation(OnetoOne.class);
    Optional<OnetoMany> onetoMany = attributeDesc.getAnnotation(OnetoMany.class);
    Optional<ManyToOne> manyToOne = attributeDesc.getAnnotation(ManyToOne.class);
    Optional<ManyToMany> manyToMany = attributeDesc.getAnnotation(ManyToMany.class);
    if (onetoOne.isPresent() || onetoMany.isPresent() || manyToOne.isPresent() || manyToMany.isPresent()) {
        return Optional.of(ResourceFieldType.RELATIONSHIP);
    }

    Optional<Id> id = attributeDesc.getAnnotation(Id.class);
    Optional<EmbeddedId> embeddedId = attributeDesc.getAnnotation(EmbeddedId.class);
    if (id.isPresent() || embeddedId.isPresent()) {
        return Optional.of(ResourceFieldType.ID);
    }
    return Optional.empty();
}
项目:lams    文件AnnotationBinder.java   
private static boolean hasAnnotationsOnIdClass(XClass idClass) {
//      if(idClass.getAnnotation(Embeddable.class) != null)
//          return true;

        List<XProperty> properties = idClass.getDeclaredProperties( XClass.ACCESS_FIELD );
        for ( XProperty property : properties ) {
            if ( property.isAnnotationPresent( Column.class ) || property.isAnnotationPresent( OnetoMany.class ) ||
                    property.isAnnotationPresent( ManyToOne.class ) || property.isAnnotationPresent( Id.class ) ||
                    property.isAnnotationPresent( GeneratedValue.class ) || property.isAnnotationPresent( OnetoOne.class ) ||
                    property.isAnnotationPresent( ManyToMany.class )
                    ) {
                return true;
            }
        }
        List<XMethod> methods = idClass.getDeclaredMethods();
        for ( XMethod method : methods ) {
            if ( method.isAnnotationPresent( Column.class ) || method.isAnnotationPresent( OnetoMany.class ) ||
                    method.isAnnotationPresent( ManyToOne.class ) || method.isAnnotationPresent( Id.class ) ||
                    method.isAnnotationPresent( GeneratedValue.class ) || method.isAnnotationPresent( OnetoOne.class ) ||
                    method.isAnnotationPresent( ManyToMany.class )
                    ) {
                return true;
            }
        }
        return false;
    }
项目:oma-riista-web    文件JpaModelTest.java   
/**
 * In JPA,@ManyToOne and @OnetoOne associations are fetched eagerly by
 * default. That will,in most situations,cause performance problems.
 * Because of that,the default behavior shall be changed to lazy fetching
 * which this test enforces. On some rare occasions,the developer may want
 * to apply eager fetching and for these cases @EagerFetch annotation is
 * available for indicating that the intention is purposeful and should be
 * passed by this test.
 */
@Test
public void nonInversetoOneAssociationsMustBeLazilyFetched() {
    final Stream<Field> FailedFields = filterFieldsOfManagedJpaTypes(field -> {
        final OnetoOne onetoOne = field.getAnnotation(OnetoOne.class);
        final ManyToOne manyToOne = field.getAnnotation(ManyToOne.class);

        return !isIdField(field) && !field.isAnnotationPresent(EagerFetch.class) &&
                (manyToOne != null && manyToOne.fetch() == FetchType.EAGER ||
                        onetoOne != null && "".equals(onetoOne.mappedBy()) && onetoOne.fetch() == FetchType.EAGER);
    });

    assertNoFields(FailedFields,"These entity fields should either have \"fetch = FetchType.LAZY\" parameter set on @ManyToOne/" +
                    "@OnetoOne annotation or alternatively be annotated with @EagerFetch: ");
}
项目:infiniquery-core    文件DefaultQueryModelService.java   
/**
 * 
 * Append the entity attribute name to the JPQL query statement.
 * 
 * @param jpqlStatement
 * @param jpaEntity
 * @param attribute
 * @throws java.lang.SecurityException 
 * @throws NoSuchFieldException 
 * @throws ClassNotFoundException 
 */
private void appendEntityAttributeName(StringBuilder jpqlStatement,JpaEntity jpaEntity,EntityAttribute attribute,AtomicInteger aliasUnicityKey,AtomicInteger joinAdditionsOffset) throws NoSuchFieldException,java.lang.SecurityException,ClassNotFoundException {
    Class<?> entityClass = Class.forName(jpaEntity.getClassName());
    Field field = entityClass.getDeclaredField(attribute.getAttributeName());
    boolean isJointRelationship = 
            field.getAnnotation(OnetoOne.class) != null
            || field.getAnnotation(OnetoMany.class) != null
            || field.getAnnotation(ManyToOne.class) != null
            || field.getAnnotation(ManyToMany.class) != null;
    if(isJointRelationship) {
        StringBuilder joinFragment = new StringBuilder();
        Queue<String> objectTreePath = extractDotSeparatedpathFragments(attribute.getPossibleValueLabelAttributePath());
        completeJoinFragment(joinFragment,entityClass,objectTreePath,aliasUnicityKey);
        jpqlStatement.insert(joinAdditionsOffset.get(),joinFragment);
        joinAdditionsOffset.set(joinAdditionsOffset.get() + joinFragment.length());
        jpqlStatement.append(" x").append(aliasUnicityKey.get()).append('.').append(attribute.getPossibleValueLabelAttribute());
    } else {
        jpqlStatement.append(" x.").append(attribute.getAttributeName());
    }
}
项目:katharsis-framework    文件AbstractEntityMetaProvider.java   
private String getMappedBy(MetaAttribute attr) {
    ManyToMany manyManyAnnotation = attr.getAnnotation(ManyToMany.class);
    OnetoMany oneManyAnnotation = attr.getAnnotation(OnetoMany.class);
    OnetoOne oneOneAnnotation = attr.getAnnotation(OnetoOne.class);
    String mappedBy = null;
    if (manyManyAnnotation != null) {
        mappedBy = manyManyAnnotation.mappedBy();
    }
    if (oneManyAnnotation != null) {
        mappedBy = oneManyAnnotation.mappedBy();
    }
    if (oneOneAnnotation != null) {
        mappedBy = oneOneAnnotation.mappedBy();
    }

    if (mappedBy != null && mappedBy.length() == 0) {
        mappedBy = null;
    }
    return mappedBy;
}
项目:blcdemo    文件MapFieldPersistenceProvider.java   
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;
}
项目:hql-builder    文件EntityRelationHelper.java   
private Annotation anyAnnotation(Field field) {
    Annotation annotation = null;

    annotation = field.getAnnotation(ManyToMany.class);
    if (annotation != null) {
        return annotation;
    }

    annotation = field.getAnnotation(OnetoOne.class);
    if (annotation != null) {
        return annotation;
    }

    annotation = field.getAnnotation(OnetoMany.class);
    if (annotation != null) {
        return annotation;
    }

    annotation = field.getAnnotation(ManyToOne.class);
    if (annotation != null) {
        return annotation;
    }

    return null;
}
项目:hql-builder    文件EntityRelationHelper.java   
private Annotation mappedByAnything(String property) {
    Field field = findField(property);
    Annotation relationAnnotation = null;

    relationAnnotation = field.getAnnotation(ManyToMany.class);
    if (relationAnnotation != null) {
        return relationAnnotation;
    }

    relationAnnotation = field.getAnnotation(OnetoOne.class);
    if (relationAnnotation != null) {
        return relationAnnotation;
    }

    relationAnnotation = field.getAnnotation(OnetoMany.class);
    if (relationAnnotation != null) {
        return relationAnnotation;
    }

    relationAnnotation = field.getAnnotation(ManyToOne.class);
    if (relationAnnotation != null) {
        return relationAnnotation;
    }

    return null;
}
项目:hql-builder    文件EntityRelationHelper.java   
private Class<?> targetEntity(Annotation relationAnnotation) {
    if (relationAnnotation instanceof ManyToMany) {
        return ManyToMany.class.cast(relationAnnotation).targetEntity();
    }

    if (relationAnnotation instanceof OnetoOne) {
        return OnetoOne.class.cast(relationAnnotation).targetEntity();
    }

    if (relationAnnotation instanceof OnetoMany) {
        return OnetoMany.class.cast(relationAnnotation).targetEntity();
    }

    if (relationAnnotation instanceof ManyToOne) {
        return ManyToOne.class.cast(relationAnnotation).targetEntity();
    }

    return null;
}
项目:karaku    文件BaseDAOImpl.java   
/**
 * Metodo que agrega relaciones
 * 
 * @param criteria
 * @param example
 * @return
 */
@Nonnull
private Criteria configureExample(@Nonnull final Criteria criteria,final T example) {

    if (example == null) {
        return criteria;
    }
    try {
        for (final Field f : example.getClass().getDeclaredFields()) {
            f.setAccessible(true);
            if (f.getAnnotation(OnetoOne.class) == null
                    && f.getAnnotation(ManyToOne.class) == null
                    || f.get(example) == null) {
                continue;
            }
            criteria.add(Restrictions.eq(f.getName(),f.get(example)));
        }
    } catch (final Exception e) {
        this.log.error("Error al agregar la relación",e);
    }
    return criteria;
}
项目:org.fastnate    文件EntityClass.java   
private void buildUniqueProperty(final SingularProperty<E,?> property) {
    if (this.context.getMaxUniqueProperties() > 0) {
        final boolean unique;
        final Column column = property.getAttribute().getAnnotation(Column.class);
        if (column != null && column.unique()) {
            unique = true;
        } else {
            final OnetoOne onetoOne = property.getAttribute().getAnnotation(OnetoOne.class);
            if (onetoOne != null) {
                unique = StringUtils.isEmpty(onetoOne.mappedBy());
            } else {
                final JoinColumn joinColumn = property.getAttribute().getAnnotation(JoinColumn.class);
                unique = joinColumn != null && joinColumn.unique();
            }
        }
        if (unique) {
            final UniquePropertyQuality propertyQuality = UniquePropertyQuality.getMatchingQuality(property);
            if (propertyQuality != null && isBetterUniquePropertyQuality(propertyQuality)) {
                this.uniquePropertiesQuality = propertyQuality;
                this.uniqueProperties = Collections
                        .<SingularProperty<E,?>> singletonList((SingularProperty<E,?>) property);
            }
        }
    }
}
项目:jbromo    文件EntityUtil.java   
/**
 * Find if a OnetoOne or OnetoMany annotation exits and if it's the case,verify if the fetch is LAZY.
 * @param field the field
 * @return true if eager,false otherwise
 */
public static boolean isLazy(final Field field) {
    final OnetoOne oneOne = field.getAnnotation(OnetoOne.class);
    if (oneOne != null) {
        // By Default Eager
        return oneOne.fetch().equals(FetchType.LAZY);
    }
    final ManyToOne manyOne = field.getAnnotation(ManyToOne.class);
    if (manyOne != null) {
        // By Default Eager
        return manyOne.fetch().equals(FetchType.LAZY);
    }
    final OnetoMany oneMany = field.getAnnotation(OnetoMany.class);
    if (oneMany != null) {
        // By Default Lazy
        return oneMany.fetch().equals(FetchType.LAZY);
    }
    final ManyToMany manyMany = field.getAnnotation(ManyToMany.class);
    if (manyMany != null) {
        // By Default Lazy
        return manyMany.fetch().equals(FetchType.LAZY);
    }
    // Other case,no problem
    return true;
}
项目:further-open-core    文件JpaAnnotationUtil.java   
/**
 * @param field
 * @return
 */
private static Class<?> getTargetEntityFromAnnotation(final Field field)
{
    for (final Annotation annotation : field.getAnnotations())
    {
        if (instanceOf(annotation,OnetoMany.class))
        {
            return ((OnetoMany) annotation).targetEntity();
        }
        else if (instanceOf(annotation,OnetoOne.class))
        {
            return ((OnetoOne) annotation).targetEntity();
        }
    }
    return null;
}
项目:bjug-querydsl    文件JpaEntityResourceMetadataExtractor.java   
/**
 * Get the property Metadata
 * for the supplied property
 * @param property
 * @param builder
 */
@SuppressWarnings("unchecked")
private void extractPropertyMetadata(PropertyDescriptor property,ResourceMetadataBuilder builder) {
    // Get the field for the property
    Method accessor = property.getReadMethod();

    // Get the property name
    String name = property.getName();

    // Is it an identity field?
    if (AnnotationHelper.fieldOrPropertyAnnotated(property,Id.class)) {
        builder.identityProperty(name,accessor);
    }

    // Is it a relation field (and therefore embedded)?
    else if (AnnotationHelper.fieldOrPropertyAnnotated(property,ManyToOne.class,OnetoOne.class,OnetoMany.class,ManyToMany.class)) {
        builder.embeddedResource(name,accessor);
    }

    // None of the above,must be @Basic or unadorned.
    else {
        builder.simpleProperty(name,accessor);
    }
}
项目:sneo    文件Vlan.java   
@OnetoOne(
  fetch = FetchType.LAZY,orphanRemoval = true,cascade = {
    CascadeType.REMOVE
  },optional = false
)
@JoinColumn(
  name = "IP_ADDRESS_RELATION_ID",nullable = false,unique = true
)
public VlanIpAddressRelation getIpAddressRelation() {
  return ipAddressRelation;
}
项目:sneo    文件RealNetworkInterfaceConfiguration.java   
@OnetoOne(
  fetch = FetchType.LAZY,unique = true
)
public RealNetworkInterfaceConfigurationIpAddressRelation
getIpAddressRelation() {
  return ipAddressRelation;
}
项目:oscm    文件ReflectiveClone.java   
private static boolean needsToCascade(Field field) {
    Class<?> fieldtype = field.getType();
    if (!DomainObject.class.isAssignableFrom(fieldtype))
        return false;
    Annotation ann;
    CascadeType[] cascades = null;
    ann = field.getAnnotation(OnetoOne.class);
    if (ann != null) {
        cascades = ((OnetoOne) ann).cascade();
    } else {
        ann = field.getAnnotation(OnetoMany.class);
        if (ann != null) {
            cascades = ((OnetoMany) ann).cascade();
        } else {
            ann = field.getAnnotation(ManyToOne.class);
            if (ann != null) {
                cascades = ((ManyToOne) ann).cascade();
            } else {
                ann = field.getAnnotation(ManyToMany.class);
                if (ann != null) {
                    cascades = ((ManyToMany) ann).cascade();
                }
            }
        }
    }
    if (cascades == null)
        return false;
    for (CascadeType cas : cascades) {
        if ((cas == CascadeType.ALL) || (cas == CascadeType.MERGE)
                || (cas == CascadeType.PERSIST)
                || (cas == CascadeType.REMOVE)) {
            return true;
        }
    }
    return false;
}
项目:lams    文件PropertyContainer.java   
private static boolean discoverTypeWithoutReflection(XProperty p) {
    if ( p.isAnnotationPresent( OnetoOne.class ) && !p.getAnnotation( OnetoOne.class )
            .targetEntity()
            .equals( void.class ) ) {
        return true;
    }
    else if ( p.isAnnotationPresent( OnetoMany.class ) && !p.getAnnotation( OnetoMany.class )
            .targetEntity()
            .equals( void.class ) ) {
        return true;
    }
    else if ( p.isAnnotationPresent( ManyToOne.class ) && !p.getAnnotation( ManyToOne.class )
            .targetEntity()
            .equals( void.class ) ) {
        return true;
    }
    else if ( p.isAnnotationPresent( ManyToMany.class ) && !p.getAnnotation( ManyToMany.class )
            .targetEntity()
            .equals( void.class ) ) {
        return true;
    }
    else if ( p.isAnnotationPresent( org.hibernate.annotations.Any.class ) ) {
        return true;
    }
    else if ( p.isAnnotationPresent( ManyToAny.class ) ) {
        if ( !p.isCollection() && !p.isArray() ) {
            throw new AnnotationException( "@ManyToAny used on a non collection non array property: " + p.getName() );
        }
        return true;
    }
    else if ( p.isAnnotationPresent( Type.class ) ) {
        return true;
    }
    else if ( p.isAnnotationPresent( Target.class ) ) {
        return true;
    }
    return false;
}
项目:lams    文件ColumnsBuilder.java   
Ejb3JoinColumn[] buildDefaultJoinColumnsForXToOne(XProperty property,PropertyData inferredData) {
    Ejb3JoinColumn[] joinColumns;
    JoinTable joinTableAnn = propertyHolder.getJoinTable( property );
    if ( joinTableAnn != null ) {
        joinColumns = Ejb3JoinColumn.buildJoinColumns(
                joinTableAnn.inverseJoinColumns(),null,entityBinder.getSecondaryTables(),propertyHolder,inferredData.getPropertyName(),mappings
        );
        if ( StringHelper.isEmpty( joinTableAnn.name() ) ) {
            throw new AnnotationException(
                    "JoinTable.name() on a @ToOne association has to be explicit: "
                            + BinderHelper.getPath( propertyHolder,inferredData )
            );
        }
    }
    else {
        OnetoOne onetoOneAnn = property.getAnnotation( OnetoOne.class );
        String mappedBy = onetoOneAnn != null ?
                onetoOneAnn.mappedBy() :
                null;
        joinColumns = Ejb3JoinColumn.buildJoinColumns(
                null,mappedBy,mappings
        );
    }
    return joinColumns;
}
项目:lams    文件ToOneBinder.java   
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() );
}
项目:lams    文件AnnotationBinder.java   
private static boolean isIdClasspkOfTheAssociatedEntity(
        InheritanceState.ElementsToProcess elementsToProcess,XClass compositeClass,PropertyData inferredData,PropertyData baseInferredData,Accesstype propertyAccessor,Map<XClass,InheritanceState> inheritanceStatePerClass,Mappings mappings) {
    if ( elementsToProcess.getIdPropertyCount() == 1 ) {
        final PropertyData idPropertyOnBaseClass = getUniqueIdPropertyFromBaseClass(
                inferredData,baseInferredData,propertyAccessor,mappings
        );
        final InheritanceState state = inheritanceStatePerClass.get( idPropertyOnBaseClass.getClassOrElement() );
        if ( state == null ) {
            return false; //while it is likely a user error,let's consider it is something that might happen
        }
        final XClass associatedClassWithIdClass = state.getClassWithIdClass( true );
        if ( associatedClassWithIdClass == null ) {
            //we cannot kNow for sure here unless we try and find the @EmbeddedId
            //Let's not do this thorough checking but do some extra validation
            final XProperty property = idPropertyOnBaseClass.getproperty();
            return property.isAnnotationPresent( ManyToOne.class )
                    || property.isAnnotationPresent( OnetoOne.class );

        }
        else {
            final XClass idClass = mappings.getReflectionManager().toXClass(
                    associatedClassWithIdClass.getAnnotation( IdClass.class ).value()
            );
            return idClass.equals( compositeClass );
        }
    }
    else {
        return false;
    }
}
项目:uckefu    文件TopicComment.java   
@OnetoOne(cascade  =  CascadeType.PERSIST)
   @JoinColumns ({
       @JoinColumn(name  =   "view",referencedColumnName  =   "dataid" ),@JoinColumn(name  =   "creater",referencedColumnName  =   "creater" )
   })
public TopicView getView() {
    return view;
}
项目:oasp-tutorial-sources    文件VisitorEntity.java   
/**
 * @return code
 */
@OnetoOne(fetch = FetchType.EAGER,cascade = CascadeType.ALL)
@JoinColumn(name = "idCode")
public AccessCodeEntity getCode() {

  return this.code;
}
项目:oasp-tutorial-sources    文件AccessCodeEntity.java   
/**
 * @return visitor
 */
@OnetoOne
@JoinColumn(name = "idVisitor")
public VisitorEntity getVisitor() {

  return this.visitor;
}
项目:oma-riista-web    文件JpaModelTest.java   
/**
 * To differentiate @OnetoOne associations from @ManyToOne ones.
 */
@Test
public void nonInverSEOnetoOneAssociationsMustHaveUniqueJoinColumn() {
    final Stream<Field> FailedFields = filterFieldsOfManagedJpaTypes(field -> {
        final OnetoOne onetoOne = field.getAnnotation(OnetoOne.class);
        final JoinColumn joinCol = field.getAnnotation(JoinColumn.class);

        return !isIdField(field) && onetoOne != null && "".equals(onetoOne.mappedBy()) &&
                (joinCol == null || !joinCol.unique());
    });

    assertNoFields(FailedFields,"These entity fields should be annotated with @JoinColumn(unique = true): ");
}
项目:katharsis-framework    文件AbstractEntityMetaProvider.java   
private boolean hasJpaAnnotations(MetaAttribute attribute) {
    List<Class<? extends Annotation>> annotationClasses = Arrays.asList(Id.class,EmbeddedId.class,Column.class,ManyToMany.class,Version.class,ElementCollection.class);
    for (Class<? extends Annotation> annotationClass : annotationClasses) {
        if (attribute.getAnnotation(annotationClass) != null) {
            return true;
        }
    }
    return false;
}
项目:domui    文件HibernateChecker.java   
private void checkOnetoOne(Method g) {
    OnetoOne annotation = g.getAnnotation(OnetoOne.class);
    if(null == annotation)
        return;
    if(annotation.optional() && annotation.fetch() == FetchType.LAZY) {
        problem(Severity.ERROR,"@OneOnOne that is optional with fetch=LAZY does eager fetching,causing big performance trouble");
        m_badOnetoOne++;
    }
}
项目:cuba    文件EntityInspectorEditor.java   
protected boolean isrequired(MetaProperty MetaProperty) {
    if (MetaProperty.isMandatory())
        return true;

    ManyToOne many2One = MetaProperty.getAnnotatedElement().getAnnotation(ManyToOne.class);
    if (many2One != null && !many2One.optional())
        return true;

    OnetoOne one2one = MetaProperty.getAnnotatedElement().getAnnotation(OnetoOne.class);
    return one2one != null && !one2one.optional();
}
项目:development    文件ReflectiveClone.java   
private static boolean needsToCascade(Field field) {
    Class<?> fieldtype = field.getType();
    if (!DomainObject.class.isAssignableFrom(fieldtype))
        return false;
    Annotation ann;
    CascadeType[] cascades = null;
    ann = field.getAnnotation(OnetoOne.class);
    if (ann != null) {
        cascades = ((OnetoOne) ann).cascade();
    } else {
        ann = field.getAnnotation(OnetoMany.class);
        if (ann != null) {
            cascades = ((OnetoMany) ann).cascade();
        } else {
            ann = field.getAnnotation(ManyToOne.class);
            if (ann != null) {
                cascades = ((ManyToOne) ann).cascade();
            } else {
                ann = field.getAnnotation(ManyToMany.class);
                if (ann != null) {
                    cascades = ((ManyToMany) ann).cascade();
                }
            }
        }
    }
    if (cascades == null)
        return false;
    for (CascadeType cas : cascades) {
        if ((cas == CascadeType.ALL) || (cas == CascadeType.MERGE)
                || (cas == CascadeType.PERSIST)
                || (cas == CascadeType.REMOVE)) {
            return true;
        }
    }
    return false;
}
项目:opencucina    文件HistoryRecord.java   
/**
 * JAVADOC Method Level Comments
 *
 * @return JAVADOC.
 */

//@Transient
@OnetoOne(fetch = FetchType.LAZY,cascade = CascadeType.ALL)
@JoinColumn(name = "attachment")
public Attachment getAttachment() {
    return attachment;
}
项目:oval    文件JPAAnnotationsConfigurer.java   
protected void addAssertValidCheckIfrequired(final Annotation constraintAnnotation,final Collection<Check> checks,@SuppressWarnings("unused") /*parameter for potential use by subclasses*/final AccessibleObject fieldOrMethod) {
    if (containsCheckOfType(checks,AssertValidCheck.class))
        return;

    if (constraintAnnotation instanceof OnetoOne || constraintAnnotation instanceof OnetoMany || constraintAnnotation instanceof ManyToOne
            || constraintAnnotation instanceof ManyToMany)
        checks.add(new AssertValidCheck());
}
项目:scheduling    文件TaskData.java   
@Cascade(org.hibernate.annotations.CascadeType.ALL)
@OnetoOne(fetch = FetchType.LAZY)
// disable foreign key,to be able to remove runtime data
@JoinColumn(name = "ENV_SCRIPT_ID",foreignKey = @ForeignKey(name = "none",value = ConstraintMode.NO_CONSTRAINT))
public ScriptData getEnvScript() {
    return envScript;
}
项目:scheduling    文件TaskData.java   
@Cascade(org.hibernate.annotations.CascadeType.ALL)
@OnetoOne(fetch = FetchType.LAZY)
// disable foreign key,to be able to remove runtime data
@JoinColumn(name = "SCRIPT_ID",value = ConstraintMode.NO_CONSTRAINT))
public ScriptData getScript() {
    return script;
}
项目:scheduling    文件TaskData.java   
@Cascade(CascadeType.ALL)
@OnetoOne(fetch = FetchType.LAZY)
// disable foreign key,to be able to remove runtime data
@JoinColumn(name = "PRE_SCRIPT_ID",value = ConstraintMode.NO_CONSTRAINT))
public ScriptData getPreScript() {
    return preScript;
}
项目:scheduling    文件TaskData.java   
@Cascade(CascadeType.ALL)
@OnetoOne(fetch = FetchType.LAZY)
// disable foreign key,to be able to remove runtime data
@JoinColumn(name = "POST_SCRIPT_ID",value = ConstraintMode.NO_CONSTRAINT))
public ScriptData getPostScript() {
    return postScript;
}
项目:scheduling    文件TaskData.java   
@Cascade(CascadeType.ALL)
@OnetoOne(fetch = FetchType.LAZY)
// disable foreign key,to be able to remove runtime data
@JoinColumn(name = "CLEAN_SCRIPT_ID",value = ConstraintMode.NO_CONSTRAINT))
public ScriptData getCleanScript() {
    return cleanScript;
}
项目:scheduling    文件TaskData.java   
@Cascade(CascadeType.ALL)
@OnetoOne(fetch = FetchType.LAZY)
// disable foreign key,to be able to remove runtime data
@JoinColumn(name = "FLOW_SCRIPT_ID",value = ConstraintMode.NO_CONSTRAINT))
public ScriptData getFlowScript() {
    return flowScript;
}

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。