本文整理汇总了Java中javax.persistence.CascadeType类的典型用法代码示例。如果您正苦于以下问题:Java CascadeType类的具体用法?Java CascadeType怎么用?Java CascadeType使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CascadeType类属于javax.persistence包,在下文中一共展示了CascadeType类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: cascadeTypeToCascadeStyle
import javax.persistence.CascadeType; //导入依赖的package包/类
public static CascadeStyle cascadeTypeToCascadeStyle(CascadeType cascadeType) {
switch ( cascadeType ) {
case ALL: {
return CascadeStyles.ALL;
}
case PERSIST: {
return CascadeStyles.PERSIST;
}
case MERGE: {
return CascadeStyles.MERGE;
}
case REMOVE: {
return CascadeStyles.DELETE;
}
case REFRESH: {
return CascadeStyles.REFRESH;
}
case DETACH: {
return CascadeStyles.EVICT;
}
default: {
throw new AssertionFailure( "Unknown cascade type" );
}
}
}
示例2: testJavaTypes
import javax.persistence.CascadeType; //导入依赖的package包/类
@Test
public void testJavaTypes() {
// create an entity with multiple java types
final SystemDialect dial = new SystemDialect();
dial.setDialBool(true);
dial.setDialChar("char");
dial.setDialDate(new GregorianCalendar(2012, 02, 10).getTime());
dial.setDialDouble(15.0);
dial.setDialEnum(CascadeType.PERSIST);
dial.setDialLong(15L);
dial.setDialShort((short) 1);
// persist and flush
em.persist(dial);
em.flush();
em.clear();
// read entity from database and test values
final SystemDialect dialFromDb = em.find(SystemDialect.class, dial.getId());
Assert.assertEquals(dial.getDialChar(), dialFromDb.getDialChar());
Assert.assertEquals(dial.getDialBool(), dialFromDb.getDialBool());
Assert.assertEquals(dial.getDialDate(), dialFromDb.getDialDate());
Assert.assertEquals(dial.getDialDouble(), dialFromDb.getDialDouble(),0.00001);
Assert.assertEquals(dial.getDialEnum(), dialFromDb.getDialEnum());
Assert.assertEquals(dial.getDialLong(), dialFromDb.getDialLong());
Assert.assertEquals(dial.getDialShort(), dialFromDb.getDialShort());
}
示例3: getPlanServices
import javax.persistence.CascadeType; //导入依赖的package包/类
@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;
}
示例4: needsToCascade
import javax.persistence.CascadeType; //导入依赖的package包/类
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;
}
示例5: getMovieStyleSet
import javax.persistence.CascadeType; //导入依赖的package包/类
@ManyToMany(cascade = CascadeType.MERGE, fetch = FetchType.LAZY)
@JoinTable(name = "R_Movie_MovieStyle",
joinColumns = {@JoinColumn(name = "movie_id", referencedColumnName = "movie_id", [email protected](name="FK_R_MovieStyle_Movie"))},
inverseJoinColumns = {@JoinColumn(name = "movie_style_id", referencedColumnName ="movie_style_id", [email protected](name="FK_R_Movie_MovieStyle"))})
public Set<MovieStyle> getMovieStyleSet() {
return movieStyleSet;
}
示例6: hasCascadeAll
import javax.persistence.CascadeType; //导入依赖的package包/类
private boolean hasCascadeAll(CascadeType[] cascades)
{
for( CascadeType type : cascades )
{
if( CascadeType.ALL == type || CascadeType.REMOVE == type )
{
return true;
}
}
return false;
}
示例7: getStrings
import javax.persistence.CascadeType; //导入依赖的package包/类
@OneToMany(cascade = CascadeType.ALL, mappedBy = "bundle")
@Fetch(value = FetchMode.SELECT)
@MapKey(name = "locale")
public Map<String, LanguageString> getStrings()
{
return strings;
}
示例8: getCascades
import javax.persistence.CascadeType; //导入依赖的package包/类
private void getCascades(AnnotationDescriptor ad, Element element, XMLContext.Default defaults) {
List<Element> elements = element != null ? element.elements( "cascade" ) : new ArrayList<Element>( 0 );
List<CascadeType> cascades = new ArrayList<CascadeType>();
for ( Element subelement : elements ) {
if ( subelement.element( "cascade-all" ) != null ) {
cascades.add( CascadeType.ALL );
}
if ( subelement.element( "cascade-persist" ) != null ) {
cascades.add( CascadeType.PERSIST );
}
if ( subelement.element( "cascade-merge" ) != null ) {
cascades.add( CascadeType.MERGE );
}
if ( subelement.element( "cascade-remove" ) != null ) {
cascades.add( CascadeType.REMOVE );
}
if ( subelement.element( "cascade-refresh" ) != null ) {
cascades.add( CascadeType.REFRESH );
}
if ( subelement.element( "cascade-detach" ) != null ) {
cascades.add( CascadeType.DETACH );
}
}
if ( Boolean.TRUE.equals( defaults.getCascadePersist() )
&& !cascades.contains( CascadeType.ALL ) && !cascades.contains( CascadeType.PERSIST ) ) {
cascades.add( CascadeType.PERSIST );
}
if ( cascades.size() > 0 ) {
ad.setValue( "cascade", cascades.toArray( new CascadeType[cascades.size()] ) );
}
}
示例9: determineCascadeTypes
import javax.persistence.CascadeType; //导入依赖的package包/类
private Set<CascadeType> determineCascadeTypes(AnnotationInstance associationAnnotation) {
Set<CascadeType> cascadeTypes = new HashSet<CascadeType>();
AnnotationValue cascadeValue = associationAnnotation.value( "cascade" );
if ( cascadeValue != null ) {
String[] cascades = cascadeValue.asEnumArray();
for ( String s : cascades ) {
cascadeTypes.add( Enum.valueOf( CascadeType.class, s ) );
}
}
return cascadeTypes;
}
示例10: cascadeTypeToCascadeStyleSet
import javax.persistence.CascadeType; //导入依赖的package包/类
public static Set<CascadeStyle> cascadeTypeToCascadeStyleSet(Set<CascadeType> cascadeTypes) {
if ( CollectionHelper.isEmpty( cascadeTypes ) ) {
return Collections.emptySet();
}
Set<CascadeStyle> cascadeStyleSet = new HashSet<CascadeStyle>();
for ( CascadeType cascadeType : cascadeTypes ) {
cascadeStyleSet.add( cascadeTypeToCascadeStyle( cascadeType ) );
}
return cascadeStyleSet;
}
示例11: getGoods8JPASet
import javax.persistence.CascadeType; //导入依赖的package包/类
@OneToMany(targetEntity = Goods8JPA.class, cascade = CascadeType.ALL,
fetch = FetchType.EAGER)
@JoinColumn(name = "join_user_goodsSet", foreignKey =
@ForeignKey(name = "join_fk_user_goodsSet"))
@JoinTable(name = "jpa_user_goodsSet_table", foreignKey =
@ForeignKey(name = "table_user_goodsSet"))
public Set<Goods8JPA> getGoods8JPASet()
{
return goods8JPASet;
}
示例12: getRoles
import javax.persistence.CascadeType; //导入依赖的package包/类
@XmlTransient
@LazyCollection(LazyCollectionOption.EXTRA)
@ManyToMany(fetch=FetchType.LAZY, cascade=CascadeType.ALL)
@JoinTable(name = "role_mappings", joinColumns = {
@JoinColumn(name = "user_id", nullable = false, updatable = false) },
inverseJoinColumns = { @JoinColumn(name = "role",
nullable = false, updatable = false) })
public List<Role> getRoles() {return _roles;}
示例13: getAlbums
import javax.persistence.CascadeType; //导入依赖的package包/类
@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;}
示例14: getView
import javax.persistence.CascadeType; //导入依赖的package包/类
@OneToOne(cascade = CascadeType.PERSIST)
@JoinColumns ({
@JoinColumn(name = "view" , referencedColumnName = "dataid" ),
@JoinColumn(name = "creater" , referencedColumnName = "creater" )
})
public TopicView getView() {
return view;
}
示例15: getComments
import javax.persistence.CascadeType; //导入依赖的package包/类
/**
* 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;
}