当前位置: 首页>>代码示例>>Java>>正文


Java CascadeType.PERSIST属性代码示例

本文整理汇总了Java中javax.persistence.CascadeType.PERSIST属性的典型用法代码示例。如果您正苦于以下问题:Java CascadeType.PERSIST属性的具体用法?Java CascadeType.PERSIST怎么用?Java CascadeType.PERSIST使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在javax.persistence.CascadeType的用法示例。


在下文中一共展示了CascadeType.PERSIST属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: needsToCascade

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;
}
 
开发者ID:servicecatalog,项目名称:oscm,代码行数:36,代码来源:ReflectiveClone.java

示例2: getAlbums

@ManyToMany(fetch=FetchType.LAZY, cascade=CascadeType.PERSIST)
@JoinTable(name = "album_media", 
		   joinColumns = { 
		@JoinColumn(name = "media_id", nullable = false, updatable = false) }, 
inverseJoinColumns = { 
		@JoinColumn(name = "album_id", nullable = false, updatable = false) })    
public List<Album> getAlbums() {return albums;}
 
开发者ID:awslabs,项目名称:aws-photosharing-example,代码行数:7,代码来源:Media.java

示例3: getView

@OneToOne(cascade  =  CascadeType.PERSIST)
   @JoinColumns ({
       @JoinColumn(name  =   "view" , referencedColumnName  =   "dataid" ),
       @JoinColumn(name  =   "creater" , referencedColumnName  =   "creater" )
   })
public TopicView getView() {
	return view;
}
 
开发者ID:uckefu,项目名称:uckefu,代码行数:8,代码来源:TopicComment.java

示例4: getComments

/**
 * 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;
}
 
开发者ID:fgulan,项目名称:java-course,代码行数:11,代码来源:BlogEntry.java

示例5: getEntries

/**
 * Gets all blog entries for which current user is author.
 * 
 * @return List of current user blog entries.
 */
@OneToMany(mappedBy = "creator", fetch = FetchType.LAZY,
        cascade = CascadeType.PERSIST, orphanRemoval = true)
@OrderBy("createdAt")
public List<BlogEntry> getEntries() {
    return entries;
}
 
开发者ID:fgulan,项目名称:java-course,代码行数:11,代码来源:BlogUser.java

示例6: getMedia

@XmlTransient
@LazyCollection(LazyCollectionOption.EXTRA)  
@ManyToMany(fetch = FetchType.LAZY, mappedBy = "albums", cascade=CascadeType.PERSIST)    
public List<Media> getMedia() {return media;}
 
开发者ID:awslabs,项目名称:aws-photosharing-example,代码行数:4,代码来源:Album.java

示例7: getCidade

@NotNull
@ManyToOne(cascade = CascadeType.PERSIST, optional = false)
@JoinColumn(foreignKey = @ForeignKey(name = "fk_endereco_to_cidade"))
public Cidade getCidade() {
	return cidade;
}
 
开发者ID:marcelothebuilder,项目名称:webpedidos,代码行数:6,代码来源:Endereco.java

示例8: getEstado

@NotNull
@ManyToOne(cascade = CascadeType.PERSIST, optional = false)
@JoinColumn(name = "estado_codigo", nullable = false, foreignKey = @ForeignKey(name = "fk_cidade_to_estado"))
public Estado getEstado() {
	return estado;
}
 
开发者ID:marcelothebuilder,项目名称:webpedidos,代码行数:6,代码来源:Cidade.java

示例9: getCategoria

@NotNull
@ManyToOne(cascade = CascadeType.PERSIST, optional = false)
@JoinColumn(name = "categoria_id", nullable = false, foreignKey = @ForeignKey(name = "fk_produto_to_categoria"))
public Categoria getCategoria() {
	return categoria;
}
 
开发者ID:marcelothebuilder,项目名称:webpedidos,代码行数:6,代码来源:Produto.java

示例10: getAllocator

@ManyToOne(fetch = FetchType.EAGER,cascade={CascadeType.MERGE,CascadeType.PERSIST})
@JoinColumn(name = "allocator")
public Allocator getAllocator() {
	return this.allocator;
}
 
开发者ID:AuScope,项目名称:igsn30,代码行数:5,代码来源:Registrant.java

示例11: getAcctUserInfo

@OneToMany(mappedBy="acctUser",cascade = { CascadeType.PERSIST ,CascadeType.ALL})
public Set<AcctUserInfo> getAcctUserInfo() {
	return acctUserInfo;
}
 
开发者ID:muzili90,项目名称:SpringBBS,代码行数:4,代码来源:AcctUser.java

示例12: getTopicAd

@OneToMany(mappedBy="topic",cascade = { CascadeType.PERSIST ,CascadeType.ALL})
public Set<TopicAd> getTopicAd() {
	return topicAd;
}
 
开发者ID:muzili90,项目名称:SpringBBS,代码行数:4,代码来源:Topic.java

示例13: getChildren

@OneToMany(mappedBy = "parent",
           fetch = FetchType.EAGER,
           cascade = { CascadeType.PERSIST, CascadeType.MERGE, CascadeType.REMOVE, CascadeType.REFRESH })
public List<MethodAccessAnnotationTestBean> getChildren() {
    return childBeans;
}
 
开发者ID:ArneLimburg,项目名称:jpasecurity,代码行数:6,代码来源:MethodAccessAnnotationTestBean.java

示例14: getProcessInstance

@ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST, CascadeType.MERGE })
public ProcessInstance getProcessInstance() {
    return processInstance;
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:4,代码来源:ActivityState.java

示例15: getActivityDefinition

@ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST, CascadeType.MERGE })
public ActivityDefinition getActivityDefinition() {
    return activityDefinition;
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:4,代码来源:ActivityState.java


注:本文中的javax.persistence.CascadeType.PERSIST属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。