List of usage examples for javax.persistence CascadeType REFRESH
CascadeType REFRESH
To view the source code for javax.persistence CascadeType REFRESH.
Click Source Link
From source file:com.mmnaseri.dragonfly.metadata.impl.AnnotationTableMetadataResolver.java
private static CascadeMetadata getCascadeMetadata(Method method) { final List<CascadeType> cascadeTypes = new ArrayList<CascadeType>(); if (method.isAnnotationPresent(OneToOne.class)) { cascadeTypes.addAll(Arrays.asList(method.getAnnotation(OneToOne.class).cascade())); } else if (method.isAnnotationPresent(OneToMany.class)) { cascadeTypes.addAll(Arrays.asList(method.getAnnotation(OneToMany.class).cascade())); } else if (method.isAnnotationPresent(ManyToOne.class)) { cascadeTypes.addAll(Arrays.asList(method.getAnnotation(ManyToOne.class).cascade())); } else if (method.isAnnotationPresent(ManyToMany.class)) { cascadeTypes.addAll(Arrays.asList(method.getAnnotation(ManyToMany.class).cascade())); }/*w w w . j a va 2s .c om*/ final boolean cascadeAll = cascadeTypes.contains(CascadeType.ALL); return new ImmutableCascadeMetadata(cascadeAll || cascadeTypes.contains(CascadeType.PERSIST), cascadeAll || cascadeTypes.contains(CascadeType.MERGE), cascadeAll || cascadeTypes.contains(CascadeType.REMOVE), cascadeAll || cascadeTypes.contains(CascadeType.REFRESH)); }
From source file:org.apache.openjpa.persistence.AnnotationPersistenceMetaDataParser.java
/** * Set cascades on relation./*from w ww .j a va 2 s . c o m*/ */ private void setCascades(ValueMetaData vmd, CascadeType[] cascades) { for (CascadeType cascade : cascades) { if (cascade == CascadeType.ALL || cascade == CascadeType.REMOVE) vmd.setCascadeDelete(ValueMetaData.CASCADE_IMMEDIATE); if (cascade == CascadeType.ALL || cascade == CascadeType.PERSIST) vmd.setCascadePersist(ValueMetaData.CASCADE_IMMEDIATE); if (cascade == CascadeType.ALL || cascade == CascadeType.MERGE) vmd.setCascadeAttach(ValueMetaData.CASCADE_IMMEDIATE); if (cascade == CascadeType.ALL || cascade == CascadeType.DETACH) vmd.setCascadeDetach(ValueMetaData.CASCADE_IMMEDIATE); if (cascade == CascadeType.ALL || cascade == CascadeType.REFRESH) vmd.setCascadeRefresh(ValueMetaData.CASCADE_IMMEDIATE); } }
From source file:org.apache.openjpa.persistence.AnnotationPersistenceMetaDataSerializer.java
/** * Serialize cascades./*from w w w . j a v a 2s .co m*/ */ private void serializeCascades(ValueMetaData vmd, AnnotationBuilder ab) { EnumSet<CascadeType> cascades = EnumSet.noneOf(CascadeType.class); if (vmd.getCascadePersist() == ValueMetaData.CASCADE_IMMEDIATE) { cascades.add(CascadeType.PERSIST); } if (vmd.getCascadeAttach() == ValueMetaData.CASCADE_IMMEDIATE) { cascades.add(CascadeType.MERGE); } if (vmd.getCascadeDelete() == ValueMetaData.CASCADE_IMMEDIATE) { cascades.add(CascadeType.REMOVE); } if (vmd.getCascadeRefresh() == ValueMetaData.CASCADE_IMMEDIATE) { cascades.add(CascadeType.REFRESH); } if (vmd.getCascadeDetach() == ValueMetaData.CASCADE_IMMEDIATE) { cascades.add(CascadeType.DETACH); } if (cascades.size() == 5) // ALL { cascades.clear(); cascades.add(CascadeType.ALL); } if (!cascades.isEmpty()) { ab.add("cascade", cascades); } }
From source file:org.batoo.jpa.core.impl.model.mapping.AssociationMapping.java
/** * @param parent//from w w w.j a v a 2 s .co m * the parent mapping * @param metadata * the metadata * @param attribute * the attribute * * @since $version * @author hceylan */ public AssociationMapping(ParentMapping<?, Z> parent, AssociationAttributeMetadata metadata, AttributeImpl<? super Z, X> attribute) { super(parent, attribute, attribute.getJavaType(), attribute.getName()); if ((metadata instanceof MappableAssociationAttributeMetadata) && StringUtils.isNotBlank(((MappableAssociationAttributeMetadata) metadata).getMappedBy())) { this.mappedBy = ((MappableAssociationAttributeMetadata) metadata).getMappedBy(); } else { this.mappedBy = null; } this.eager = attribute.isCollection() || (this.mappedBy == null) ? metadata.getFetchType() == FetchType.EAGER : true; if (metadata instanceof OrphanableAssociationAttributeMetadata) { this.removesOrphans = ((OrphanableAssociationAttributeMetadata) metadata).removesOrphans(); } else { this.removesOrphans = false; } this.cascadesDetach = metadata.getCascades().contains(CascadeType.ALL) || metadata.getCascades().contains(CascadeType.DETACH); this.cascadesMerge = metadata.getCascades().contains(CascadeType.ALL) || metadata.getCascades().contains(CascadeType.MERGE); this.cascadesPersist = metadata.getCascades().contains(CascadeType.ALL) || metadata.getCascades().contains(CascadeType.PERSIST); this.cascadesRefresh = metadata.getCascades().contains(CascadeType.ALL) || metadata.getCascades().contains(CascadeType.REFRESH); this.cascadesRemove = metadata.getCascades().contains(CascadeType.ALL) || metadata.getCascades().contains(CascadeType.REMOVE); }
From source file:org.batoo.jpa.core.impl.model.mapping.AssociationMappingImpl.java
/** * @param parent/*from w w w . java 2 s.c om*/ * the parent mapping * @param metadata * the metadata * @param attribute * the attribute * * @since 2.0.0 */ public AssociationMappingImpl(AbstractParentMapping<?, Z> parent, AssociationAttributeMetadata metadata, AttributeImpl<? super Z, X> attribute) { super(parent, attribute, attribute.getJavaType(), attribute.getName()); if ((metadata instanceof MappableAssociationAttributeMetadata) && StringUtils.isNotBlank(((MappableAssociationAttributeMetadata) metadata).getMappedBy())) { this.mappedBy = ((MappableAssociationAttributeMetadata) metadata).getMappedBy(); } else { this.mappedBy = null; } this.eager = attribute.isCollection() || (this.mappedBy == null) ? metadata.getFetchType() == FetchType.EAGER : true; this.maxFetchDepth = metadata.getMaxFetchDepth(); this.fetchStrategy = metadata.getFetchStrategy(); if (metadata instanceof OrphanableAssociationAttributeMetadata) { this.removesOrphans = ((OrphanableAssociationAttributeMetadata) metadata).removesOrphans(); } else { this.removesOrphans = false; } this.cascadesDetach = metadata.getCascades().contains(CascadeType.ALL) || metadata.getCascades().contains(CascadeType.DETACH); this.cascadesMerge = metadata.getCascades().contains(CascadeType.ALL) || metadata.getCascades().contains(CascadeType.MERGE); this.cascadesPersist = metadata.getCascades().contains(CascadeType.ALL) || metadata.getCascades().contains(CascadeType.PERSIST); this.cascadesRefresh = metadata.getCascades().contains(CascadeType.ALL) || metadata.getCascades().contains(CascadeType.REFRESH); this.cascadesRemove = metadata.getCascades().contains(CascadeType.ALL) || metadata.getCascades().contains(CascadeType.REMOVE); }
From source file:org.orcid.persistence.jpa.entities.ProfileEntity.java
@OneToMany(mappedBy = "receiver", cascade = { CascadeType.DETACH, CascadeType.REFRESH, CascadeType.REMOVE, CascadeType.MERGE })// ww w . j av a2 s. co m public Set<GivenPermissionByEntity> getGivenPermissionBy() { return givenPermissionBy; }
From source file:org.tsm.concharto.model.Event.java
@ManyToOne(cascade = { CascadeType.REFRESH, CascadeType.MERGE }) @ForeignKey(name = "FK_EVENT_STYLE") public org.tsm.concharto.model.kml.StyleSelector getStyleSelector() { return styleSelector; }