Java 类javax.persistence.CascadeType 实例源码
项目:lams
文件:EnumConversionHelper.java
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" );
}
}
}
项目:bootstrap
文件:DialectDaoTest.java
@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());
}
项目: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;
}
项目:Equella
文件:Property.java
private boolean hasCascadeAll(CascadeType[] cascades)
{
for( CascadeType type : cascades )
{
if( CascadeType.ALL == type || CascadeType.REMOVE == type )
{
return true;
}
}
return false;
}
项目:Equella
文件:LanguageBundle.java
@OneToMany(cascade = CascadeType.ALL, mappedBy = "bundle")
@Fetch(value = FetchMode.SELECT)
@MapKey(name = "locale")
public Map<String, LanguageString> getStrings()
{
return strings;
}
项目:lams
文件:JPAOverriddenAnnotationReader.java
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()] ) );
}
}
项目:lams
文件:AssociationAttribute.java
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;
}
项目:lams
文件:EnumConversionHelper.java
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;
}
项目:tinyshop8
文件:User8JPA.java
@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;
}
项目:aws-photosharing-example
文件:User.java
@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;}
项目:aws-photosharing-example
文件:Media.java
@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;}
项目:uckefu
文件:TopicComment.java
@OneToOne(cascade = CascadeType.PERSIST)
@JoinColumns ({
@JoinColumn(name = "view" , referencedColumnName = "dataid" ),
@JoinColumn(name = "creater" , referencedColumnName = "creater" )
})
public TopicView getView() {
return view;
}
项目: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;
}
项目:java-course
文件:BlogUser.java
/**
* 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;
}
项目: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;
}
项目:oasp-tutorial-sources
文件:VisitorEntity.java
/**
* @return code
*/
@OneToOne(fetch = FetchType.EAGER, cascade = CascadeType.ALL)
@JoinColumn(name = "idCode")
public AccessCodeEntity getCode() {
return this.code;
}
项目: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;
}
项目:webpedidos
文件:Usuario.java
@ManyToMany(cascade = CascadeType.REFRESH, fetch = FetchType.LAZY)
@JoinTable(name = "usuario_grupo", joinColumns = {
@JoinColumn(name = "usuario_id", foreignKey = @ForeignKey(name = "fk_usuario_grupo_to_usuario")
) }, inverseJoinColumns = { @JoinColumn(name = "grupo_id", foreignKey = @ForeignKey(name = "fk_usuario_grupo_to_grupo")) })
public Set<Grupo> getGrupos() {
return grupos;
}
项目:resteasy-examples
文件:Contact.java
@ManyToMany(cascade = { CascadeType.ALL },fetch=FetchType.EAGER)
@JoinTable(name = "ContactToContactJoinTable", joinColumns = @JoinColumn(name = "parentContactId"), inverseJoinColumns = @JoinColumn(name = "childContactId"))
@XmlTransient
public Set<Contact> getContactChildren()
{
return contactChildren;
}
项目:mycore
文件:MCRCategoryImpl.java
@Override
@OneToMany(targetEntity = MCRCategoryImpl.class,
cascade = {
CascadeType.ALL },
mappedBy = "parent")
@OrderColumn(name = "positionInParent")
@Access(AccessType.FIELD)
public List<MCRCategory> getChildren() {
return super.getChildren();
}
项目:my-paper
文件:ParameterGroup.java
/**
* 获取参数
*
* @return 参数
*/
@JsonProperty
@Valid
@NotEmpty
@OneToMany(mappedBy = "parameterGroup", fetch = FetchType.LAZY, cascade = CascadeType.ALL, orphanRemoval = true)
@OrderBy("order asc")
public List<Parameter> getParameters() {
return parameters;
}
项目:my-paper
文件:Order.java
/**
* 获取订单项
*
* @return 订单项
*/
@Valid
@NotEmpty
@OneToMany(mappedBy = "order", fetch = FetchType.LAZY, cascade = CascadeType.ALL, orphanRemoval = true)
@OrderBy("isGift asc")
public List<OrderItem> getOrderItems() {
return orderItems;
}
项目:my-paper
文件:Shipping.java
/**
* 获取发货项
*
* @return 发货项
*/
@Valid
@NotEmpty
@OneToMany(mappedBy = "shipping", fetch = FetchType.LAZY, cascade = CascadeType.ALL)
public List<ShippingItem> getShippingItems() {
return shippingItems;
}
项目:my-paper
文件:Specification.java
/**
* 获取规格值
*
* @return 规格值
*/
@Valid
@NotEmpty
@OneToMany(mappedBy = "specification", fetch = FetchType.LAZY, cascade = CascadeType.ALL, orphanRemoval = true)
@OrderBy("order asc")
public List<SpecificationValue> getSpecificationValues() {
return specificationValues;
}
项目:my-paper
文件:Returns.java
/**
* 获取退货项
*
* @return 退货项
*/
@Valid
@NotEmpty
@OneToMany(mappedBy = "returns", fetch = FetchType.LAZY, cascade = CascadeType.ALL)
public List<ReturnsItem> getReturnsItems() {
return returnsItems;
}
项目:GitHub
文件:Order.java
@OneToMany(cascade=CascadeType.ALL, fetch=FetchType.LAZY, mappedBy="order")
public Set<OrderDetail> getOrderDetails() {
return this.orderDetails;
}
项目: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, fetch=FetchType.LAZY, mappedBy="office")
public Set<Employee> getEmployees() {
return this.employees;
}
项目:DocIT
文件:Company.java
@OneToMany(cascade=CascadeType.ALL, fetch=FetchType.LAZY, mappedBy="company")
public Set<Department> getDepartments() {
return this.departments;
}
项目: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, fetch=FetchType.LAZY, mappedBy="department")
public Set<Employee> getEmployees() {
return this.employees;
}
项目:DocIT
文件:Department.java
@OneToMany(cascade=CascadeType.ALL, fetch=FetchType.LAZY, mappedBy="department")
public Set<Department> getDepartments() {
return this.departments;
}
项目:lams
文件:AssociationAttribute.java
public Set<CascadeType> getCascadeTypes() {
return cascadeTypes;
}
项目:aws-photosharing-example
文件:Album.java
@XmlTransient
@LazyCollection(LazyCollectionOption.EXTRA)
@ManyToMany(fetch = FetchType.LAZY, mappedBy = "albums", cascade=CascadeType.PERSIST)
public List<Media> getMedia() {return media;}
项目:aws-photosharing-example
文件:User.java
@XmlTransient
@LazyCollection(LazyCollectionOption.EXTRA)
@OneToMany(mappedBy = "user", orphanRemoval=true, fetch=FetchType.LAZY, cascade=CascadeType.ALL)
public List<Media> getMedia() {return media;}
项目:aws-photosharing-example
文件:User.java
@XmlTransient
@LazyCollection(LazyCollectionOption.EXTRA)
@OneToMany(mappedBy = "user", orphanRemoval=true, fetch=FetchType.LAZY, cascade=CascadeType.ALL)
public List<Share> getShares() {return shares;}