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

javax.persistence.OneToMany的实例源码

项目: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_340_404[email protected]   
@Override
public Optional<SerializeType> getSerializeType(BeanAttribute@R_340_4045@ion attributeDesc) {
    Optional<OnetoMany> onetoMany = attributeDesc.getAnnotation(OnetoMany.class);
    if (onetoMany.isPresent()) {
        return toSerializeType(onetoMany.get().fetch());
    }
    Optional<ManyToOne> manyToOne = attributeDesc.getAnnotation(ManyToOne.class);
    if (manyToOne.isPresent()) {
        return toSerializeType(manyToOne.get().fetch());
    }
    Optional<ManyToMany> manyToMany = attributeDesc.getAnnotation(ManyToMany.class);
    if (manyToMany.isPresent()) {
        return toSerializeType(manyToMany.get().fetch());
    }
    Optional<ElementCollection> elementCollection = attributeDesc.getAnnotation(ElementCollection.class);
    if (elementCollection.isPresent()) {
        return toSerializeType(elementCollection.get().fetch());
    }
    return Optional.empty();
}
项目:Equella    文件LanguageBundle.java   
@OnetoMany(cascade = CascadeType.ALL,mappedBy = "bundle")
@Fetch(value = FetchMode.SELECT)
@MapKey(name = "locale")
public Map<String,LanguageString> getStrings()
{
    return strings;
}
项目:lams    文件EnhancementTask.java   
@Override
public boolean isMappedCollection(CtField field) {
    try {
        return (field.getAnnotation(OnetoMany.class) != null ||
                field.getAnnotation(ManyToMany.class) != null ||
                field.getAnnotation(ElementCollection.class) != null);
    }
    catch (ClassNotFoundException e) {
        return false;
    }
}
项目: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;
}
项目:crnk-framework    文件JpaResourceField@R_340_404[email protected]   
@Override
public Optional<String> getoppositeName(BeanAttribute@R_340_4045@ion attributeDesc) {
    Optional<OnetoMany> onetoMany = attributeDesc.getAnnotation(OnetoMany.class);
    if (onetoMany.isPresent()) {
        return Optional.ofNullable(StringUtils.emptyToNull(onetoMany.get().mappedBy()));
    }
    Optional<ManyToMany> manyToMany = attributeDesc.getAnnotation(ManyToMany.class);
    if (manyToMany.isPresent()) {
        return Optional.ofNullable(StringUtils.emptyToNull(manyToMany.get().mappedBy()));
    }
    return Optional.empty();
}
项目: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;
}
项目:java-course    文件BlogEntry.java   
/**
 * Get all comments for current blog entry.
 * 
 * @return List of all comments for current blog entry.
 */
@OnetoMany(mappedBy = "blogEntry",fetch = FetchType.LAZY,cascade = CascadeType.PERSIST,orphanRemoval = true)
@OrderBy("postedOn")
public List<BlogComment> getComments() {
    return comments;
}
项目:jkes    文件EventSupport.java   
private CascadeType[] getCascadeTypes(AccessibleObject accessibleObject) {
    CascadeType[] cascadeTypes = null;
    if(accessibleObject.isAnnotationPresent(OnetoMany.class)) {
        cascadeTypes = accessibleObject.getAnnotation(OnetoMany.class).cascade();
    }else if(accessibleObject.isAnnotationPresent(ManyToOne.class)) {
        cascadeTypes = accessibleObject.getAnnotation(ManyToOne.class).cascade();
    }else if(accessibleObject.isAnnotationPresent(ManyToMany.class)) {
        cascadeTypes = accessibleObject.getAnnotation(ManyToMany.class).cascade();
    }
    return cascadeTypes;
}
项目:sbc-qsystem    文件QUser.java   
@OnetoMany(cascade = CascadeType.ALL,fetch = FetchType.EAGER,orphanRemoval = true)
@JoinColumn(name = "user_id",insertable = false,nullable = false,updatable = false)
// MOSCOW
@Fetch(FetchMode.SELECT)
// Это отсечение дублирования при джойне таблици,т.к. в QPlanService есть @OnetoOne к QService,и в нем есть @OnetoMany к QServiceLang - дублится по
// количеству переводов
// This is the truncation of the duplication when the table joins,since In QPlanService there is @OnetoOne to QService,and there is @OnetoMany to
// QServiceLang - it is duplicated by the number of translations.
public List<QPlanService> getPlanServices() {
    return planServices;
}
项目:tinyshop8    文件GoodsBrand8JPA.java   
@OnetoMany(targetEntity = Goods8JPA.class,cascade = REMOVE,fetch = EAGER)
@JoinColumn(name = "join_goods_brand_m2o",foreignKey =
@ForeignKey(name = "fk_goods_brand_m2o"))
@JoinTable(name = "jpa_goods_brand_set",foreignKey =
@ForeignKey(name = "fk_jpa_goods_brand_set"))
public Set<Goods8JPA> getGoods8JPASet()
{
    return goods8JPASet;
}
项目:lemon    文件diskShare.java   
/** @return . */
@OnetoMany(fetch = FetchType.LAZY,mappedBy = "diskShare")
public Set<diskAcl> getdiskAcls() {
    return this.diskAcls;
}
项目:GitHub    文件Product.java   
@OnetoMany(cascade=CascadeType.ALL,fetch=FetchType.LAZY,mappedBy="product")
public Set<OrderDetail> getorderDetails() {
    return this.orderDetails;
}
项目:GitHub    文件Office.java   
@OnetoMany(cascade=CascadeType.ALL,mappedBy="office")
public Set<Employee> getEmployees() {
    return this.employees;
}
项目:DocIT    文件Company.java   
@OnetoMany(cascade=CascadeType.ALL,fetch=FetchType.EAGER,mappedBy="company")
public Set<Employee> getEmployees() {
    return this.employees;
}
项目:DocIT    文件Department.java   
@OnetoMany(cascade=CascadeType.ALL,mappedBy="department")
public Set<Employee> getEmployees() {
    return this.employees;
}
项目:DocIT    文件Department.java   
@OnetoMany(cascade=CascadeType.ALL,mappedBy="department")
public Set<Department> getDepartments() {
    return this.departments;
}
项目:lemon    文件WhitelistPackage.java   
/** @return . */
@OnetoMany(fetch = FetchType.LAZY,mappedBy = "whitelistPackage")
public Set<WhitelistService> getWhitelistServices() {
    return this.whitelistServices;
}
项目:plumdo-work    文件SystemMenu.java   
@OnetoMany(cascade = CascadeType.ALL,mappedBy = "systemMenu")
public Set<SystemMenu> getSystemMenus() {
    return this.systemMenus;
}
项目:lemon    文件TicketCatalog.java   
/** @return . */
@OnetoMany(fetch = FetchType.LAZY,mappedBy = "ticketCatalog")
public Set<TicketInfo> getTicketInfos() {
    return this.ticketInfos;
}
项目:aws-photosharing-example    文件User.java   
@XmlTransient
@LazyCollection(LazyCollectionoption.EXTRA)
@OnetoMany(mappedBy = "user",orphanRemoval=true,cascade=CascadeType.ALL)
public List<Share> getShares() {return shares;}
项目:lemon    文件TicketGroup.java   
/** @return . */
@OnetoMany(fetch = FetchType.LAZY,mappedBy = "ticketGroup")
public Set<TicketMember> getTicketMembers() {
    return this.ticketMembers;
}
项目:lemon    文件BookInfo.java   
/** @return . */
@OnetoMany(fetch = FetchType.LAZY,mappedBy = "bookInfo")
public Set<BookBorrow> getBookBorrows() {
    return this.bookBorrows;
}
项目:lemon    文件FeedbackCatalog.java   
/** @return . */
@OnetoMany(fetch = FetchType.LAZY,mappedBy = "FeedbackCatalog")
public Set<FeedbackInfo> getFeedbackInfos() {
    return this.FeedbackInfos;
}
项目:aws-photosharing-example    文件Album.java   
@OnetoMany(mappedBy = "album",orphanRemoval=true)    
@LazyCollection(LazyCollectionoption.EXTRA)
public List<Share> getShares() {return shares;}
项目:lemon    文件BpmCategory.java   
/** @return . */
@OnetoMany(fetch = FetchType.LAZY,mappedBy = "bpmCategory")
@OrderBy("priority")
public Set<BpmProcess> getBpmProcesses() {
    return this.bpmProcesses;
}
项目:lemon    文件WhitelistService.java   
/** @return . */
@OnetoMany(fetch = FetchType.LAZY,mappedBy = "whitelistService")
public Set<WhitelistInfo> getWhitelistInfos() {
    return this.whitelistInfos;
}
项目:lemon    文件BpmProcess.java   
/** @return . */
@OnetoMany(fetch = FetchType.LAZY,mappedBy = "bpmProcess")
public Set<BpmtaskdefNotice> getBpmtaskdefNotices() {
    return this.bpmtaskdefNotices;
}
项目:lemon    文件BpmProcess.java   
/** @return . */
@OnetoMany(fetch = FetchType.LAZY,mappedBy = "bpmProcess")
public Set<BpmInstance> getBpmInstances() {
    return this.bpmInstances;
}
项目:lemon    文件JavamailConfig.java   
/** @return . */
@OnetoMany(fetch = FetchType.LAZY,mappedBy = "javamailConfig")
public Set<JavamailMessage> getJavamailMessages() {
    return this.javamailMessages;
}
项目:lemon    文件BpmConfNode.java   
/** @return . */
@OnetoMany(fetch = FetchType.LAZY,mappedBy = "bpmConfNode")
public Set<BpmConfNotice> getBpmConfNotices() {
    return this.bpmConfNotices;
}
项目:lemon    文件BpmConfNode.java   
/** @return . */
@OnetoMany(fetch = FetchType.LAZY,mappedBy = "bpmConfNode")
public Set<BpmConfUser> getBpmConfUsers() {
    return this.bpmConfUsers;
}
项目:tap17-muggl-javaee    文件vendor.java   
@OnetoMany(cascade=ALL,mappedBy="vendor")
public Collection<vendorPart> getvendorParts() {
    return vendorParts;
}
项目:lemon    文件OfficesupplyInfo.java   
/** @return . */
@OnetoMany(fetch = FetchType.LAZY,mappedBy = "officesupplyInfo")
public Set<OfficesupplyReceive> getofficesupplyReceives() {
    return this.officesupplyReceives;
}
项目:lemon    文件Pimschedule.java   
/** @return . */
@OnetoMany(fetch = FetchType.LAZY,mappedBy = "pimschedule")
public Set<PimscheduleParticipant> getPimscheduleParticipants() {
    return this.pimscheduleParticipants;
}
项目:lemon    文件CmsArticle.java   
/** @return . */
@OnetoMany(fetch = FetchType.LAZY,mappedBy = "cmsArticle")
public Set<CmsClick> getCmsClicks() {
    return this.cmsClicks;
}
项目:lemon    文件BpmConfNode.java   
/** @return . */
@OnetoMany(fetch = FetchType.LAZY,mappedBy = "bpmConfNode")
public Set<BpmConfOperation> getBpmConfOperations() {
    return this.bpmConfOperations;
}
项目:lams    文件CollectionBinder.java   
protected void bindOnetoManySecondPass(
        Collection collection,Map persistentClasses,Ejb3JoinColumn[] fkJoinColumns,XClass collectionType,boolean cascadeDeleteEnabled,boolean ignoreNotFound,Mappings mappings,Map<XClass,InheritanceState> inheritanceStatePerClass) {

    final boolean debugEnabled = LOG.isDebugEnabled();
    if ( debugEnabled ) {
        LOG.debugf( "Binding a OnetoMany: %s.%s through a foreign key",propertyHolder.getEntityName(),propertyName );
    }
    org.hibernate.mapping.OnetoMany onetoMany = new org.hibernate.mapping.OnetoMany( mappings,collection.getowner() );
    collection.setElement( onetoMany );
    onetoMany.setReferencedEntityName( collectionType.getName() );
    onetoMany.setIgnoreNotFound( ignoreNotFound );

    String assocclass = onetoMany.getReferencedEntityName();
    PersistentClass associatedClass = (PersistentClass) persistentClasses.get( assocclass );
    if ( jpaOrderBy != null ) {
        final String orderByFragment = buildOrderByClauseFromHql(
                jpaOrderBy.value(),associatedClass,collection.getRole()
        );
        if ( StringHelper.isNotEmpty( orderByFragment ) ) {
            collection.setorderBy( orderByFragment );
        }
    }

    if ( mappings == null ) {
        throw new AssertionFailure(
                "CollectionSecondPass for onetoMany should not be called with null mappings"
        );
    }
    Map<String,Join> joins = mappings.getJoins( assocclass );
    if ( associatedClass == null ) {
        throw new MappingException(
                "Association references unmapped class: " + assocclass
        );
    }
    onetoMany.setAssociatedClass( associatedClass );
    for (Ejb3JoinColumn column : fkJoinColumns) {
        column.setPersistentClass( associatedClass,joins,inheritanceStatePerClass );
        column.setJoins( joins );
        collection.setCollectionTable( column.getTable() );
    }
    if ( debugEnabled ) {
        LOG.debugf( "Mapping collection: %s -> %s",collection.getRole(),collection.getCollectionTable().getName() );
    }
    bindFilters( false );
    bindCollectionSecondPass( collection,null,fkJoinColumns,cascadeDeleteEnabled,property,mappings );
    if ( !collection.isInverse()
            && !collection.getKey().isNullable() ) {
        // for non-inverse one-to-many,with a not-null fk,add a backref!
        String entityName = onetoMany.getReferencedEntityName();
        PersistentClass referenced = mappings.getClass( entityName );
        Backref prop = new Backref();
        prop.setName( '_' + fkJoinColumns[0].getPropertyName() + '_' + fkJoinColumns[0].getLogicalColumnName() + "Backref" );
        prop.setUpdateable( false );
        prop.setSelectable( false );
        prop.setCollectionRole( collection.getRole() );
        prop.setEntityName( collection.getowner().getEntityName() );
        prop.setValue( collection.getKey() );
        referenced.addProperty( prop );
    }
}
项目:lemon    文件BpmMailTemplate.java   
/** @return . */
@OnetoMany(fetch = FetchType.LAZY,mappedBy = "bpmMailTemplate")
public Set<BpmConfNotice> getBpmConfNotices() {
    return this.bpmConfNotices;
}
项目:lemon    文件BpmConfBase.java   
/** @return . */
@OnetoMany(fetch = FetchType.LAZY,mappedBy = "bpmConfBase")
public Set<BpmConfNode> getBpmConfNodes() {
    return this.bpmConfNodes;
}

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