List of usage examples for javax.persistence CascadeType ALL
CascadeType ALL
To view the source code for javax.persistence CascadeType ALL.
Click Source Link
From source file:com.doculibre.constellio.entities.RecordCollection.java
@OneToMany(mappedBy = "recordCollection", cascade = { CascadeType.ALL }, fetch = FetchType.LAZY, orphanRemoval = true) public List<AdvancedSearchEnabledRule> getAdvancedSearchEnabledRules() { return advancedSearchEnabledRules; }
From source file:com.doculibre.constellio.entities.RecordCollection.java
@OneToMany(mappedBy = "ownerCollection", cascade = { CascadeType.ALL }, fetch = FetchType.LAZY, orphanRemoval = true) public Set<FederationRecordIndexingRequired> getFederationIndexingRequired() { return federationIndexingRequired; }
From source file:com.medigy.persist.model.person.Person.java
@OneToMany(mappedBy = "party", cascade = CascadeType.ALL) public List<PersonIdentifier> getPersonIdentifiers() { return personIdentifiers; }
From source file:com.doculibre.constellio.entities.RecordCollection.java
@OneToMany(mappedBy = "ownerCollection", cascade = { CascadeType.ALL }, fetch = FetchType.LAZY, orphanRemoval = true) public Set<FederationRecordDeletionRequired> getFederationDeletionRequired() { return federationDeletionRequired; }
From source file:com.medigy.persist.model.person.Person.java
@OneToMany(mappedBy = "patient", cascade = CascadeType.ALL) public List<ResponsiblePartySelection> getResponsiblePartySelections() { return responsiblePartySelections; }
From source file:com.doculibre.constellio.entities.RecordCollection.java
@OneToMany(cascade = { CascadeType.ALL }, fetch = FetchType.LAZY, orphanRemoval = true) @OrderColumn(name = "searchResultFieldIndex") @JoinColumn(name = "recordCollection_id", nullable = false) public List<SearchResultField> getSearchResultFields() { return searchResultFields; }
From source file:org.projectforge.business.address.AddressDO.java
@OneToMany(cascade = CascadeType.ALL, mappedBy = "parent", targetEntity = AddressAttrDO.class, orphanRemoval = true, fetch = FetchType.EAGER) @MapKey(name = "propertyName") @Override//w w w. j a v a 2 s . c om @HistoryProperty(converter = TabAttrHistoryPropertyConverter.class) public Map<String, JpaTabAttrBaseDO<AddressDO, Integer>> getAttrs() { return super.getAttrs(); }
From source file:org.opennms.netmgt.model.OnmsAlarm.java
@OneToOne(cascade = CascadeType.ALL) @JoinColumn(name = "stickymemo") @XmlElement(name = "stickyMemo") public OnmsMemo getStickyMemo() { return m_stickyMemo; }
From source file:edu.ku.brc.specify.tools.datamodelgenerator.DatamodelGenerator.java
/** * @param className/*w w w . j a v a 2 s . c o m*/ * @param tableList */ @SuppressWarnings("cast") protected void processClass(final String className, final List<Table> tableList) { try { Class<?> classObj = Class.forName(packageName + "." + className); Table table = null; String tableName = null; if (classObj.isAnnotationPresent(javax.persistence.Table.class)) { Vector<TableIndex> indexes = new Vector<TableIndex>(); javax.persistence.Table tableAnno = (javax.persistence.Table) classObj .getAnnotation(javax.persistence.Table.class); tableName = tableAnno.name(); org.hibernate.annotations.Table hiberTableAnno = (org.hibernate.annotations.Table) classObj .getAnnotation(org.hibernate.annotations.Table.class); if (hiberTableAnno != null) { //System.out.println("Table Indexes: "); for (Index index : hiberTableAnno.indexes()) { //System.out.println(" "+index.name() + " "+ index.columnNames()); indexes.add(new TableIndex(index.name(), index.columnNames())); } } table = createTable(packageName + "." + className, tableName); if (includeDesc) { table.setDesc(getTableDesc(tableName)); table.setNameDesc(getTableNameDesc(tableName)); } table.setIndexes(indexes); tableList.add(table); } if (table != null) { boolean isLob = false; for (Method method : classObj.getMethods()) { String methodName = method.getName(); if (!methodName.startsWith("get")) { continue; } if (DEBUG) { System.out.println(className + " " + method.getName()); } Type type = method.getGenericReturnType(); Class<?> typeClass; if (type instanceof Class<?>) { typeClass = (Class<?>) type; } else if (type instanceof ParameterizedType) { typeClass = null; for (Type t : ((ParameterizedType) type).getActualTypeArguments()) { if (t instanceof Class<?>) { typeClass = (Class<?>) t; } } } else { if (!method.getName().equals("getDataObj") && !method.getName().equals("getTreeRootNode")) { log.warn("Not handled: " + type); } typeClass = null; } // rods 07/10/08 - Used to skip all relationships that point to themselves // that works now and is needed. if (typeClass == null || typeClass == AttributeIFace.class || typeClass == PickListItemIFace.class || typeClass == RecordSetItemIFace.class) { continue; } String thisSideName = getFieldNameFromMethod(method); if (method.isAnnotationPresent(javax.persistence.Lob.class)) { isLob = true; } if (method.isAnnotationPresent(javax.persistence.Column.class)) { if (method.isAnnotationPresent(javax.persistence.Id.class)) { table.addId(createId(method, (javax.persistence.Column) method .getAnnotation(javax.persistence.Column.class))); } else { Field field = createField(method, (javax.persistence.Column) method.getAnnotation(javax.persistence.Column.class), isLob); if (includeDesc) { field.setDesc(getFieldDesc(tableName, field.getName())); field.setNameDesc(getFieldNameDesc(tableName, field.getName())); } if (typeClass == java.util.Calendar.class) { String mName = method.getName() + "Precision"; for (Method mthd : classObj.getMethods()) { if (mthd.getName().equals(mName)) { field.setPartialDate(true); field.setDatePrecisionName(field.getName() + "Precision"); break; } } } table.addField(field); } } else if (method.isAnnotationPresent(javax.persistence.ManyToOne.class)) { javax.persistence.ManyToOne oneToMany = (javax.persistence.ManyToOne) method .getAnnotation(javax.persistence.ManyToOne.class); boolean isSave = false; for (CascadeType ct : oneToMany.cascade()) { if (ct == CascadeType.ALL || ct == CascadeType.PERSIST) { isSave = true; } } isSave = !isSave ? isOKToSave(method) : isSave; String otherSideName = getRightSideForManyToOne(classObj, typeClass, thisSideName); javax.persistence.JoinColumn join = method .isAnnotationPresent(javax.persistence.JoinColumn.class) ? (javax.persistence.JoinColumn) method .getAnnotation(javax.persistence.JoinColumn.class) : null; if (join != null) { //String othersideName = typeClass == null ? "" : getOthersideName(classObj, typeClass, thisSideName, RelType.OneToMany); Relationship rel = createRelationship(method, "many-to-one", join, otherSideName, join != null ? !join.nullable() : false); table.addRelationship(rel); rel.setSave(isSave); if (includeDesc) { rel.setDesc(getFieldDesc(tableName, rel.getRelationshipName())); rel.setNameDesc(getFieldNameDesc(tableName, rel.getRelationshipName())); } } else { log.error("No Join!"); } } else if (method.isAnnotationPresent(javax.persistence.ManyToMany.class)) { javax.persistence.ManyToMany manyToMany = method .getAnnotation(javax.persistence.ManyToMany.class); String othersideName = manyToMany.mappedBy(); if (StringUtils.isEmpty(othersideName)) { othersideName = getRightSideForManyToMany(classObj, typeClass, getFieldNameFromMethod(method)); } boolean isSave = false; for (CascadeType ct : manyToMany.cascade()) { if (ct == CascadeType.ALL || ct == CascadeType.PERSIST) { isSave = true; } } isSave = !isSave ? isOKToSave(method) : isSave; javax.persistence.JoinColumn join = method .isAnnotationPresent(javax.persistence.JoinColumn.class) ? (javax.persistence.JoinColumn) method .getAnnotation(javax.persistence.JoinColumn.class) : null; Relationship rel = createRelationship(method, "many-to-many", join, othersideName, join != null ? !join.nullable() : false); rel.setLikeManyToOne(table.getIsLikeManyToOne(rel.getRelationshipName())); rel.setSave(isSave); table.addRelationship(rel); if (includeDesc) { rel.setDesc(getFieldDesc(tableName, rel.getRelationshipName())); rel.setNameDesc(getFieldNameDesc(tableName, rel.getRelationshipName())); } javax.persistence.JoinTable joinTable = method .getAnnotation(javax.persistence.JoinTable.class); if (joinTable != null) { rel.setJoinTableName(joinTable.name()); } } else if (method.isAnnotationPresent(javax.persistence.OneToMany.class)) { javax.persistence.OneToMany oneToMany = (javax.persistence.OneToMany) method .getAnnotation(javax.persistence.OneToMany.class); String othersideName = oneToMany.mappedBy(); if (StringUtils.isEmpty(othersideName)) { // This Should never happen othersideName = getRightSideForOneToMany(classObj, typeClass, oneToMany.mappedBy()); } boolean isSave = false; for (CascadeType ct : oneToMany.cascade()) { if (ct == CascadeType.ALL || ct == CascadeType.PERSIST) { isSave = true; } } isSave = !isSave ? isOKToSave(method) : isSave; javax.persistence.JoinColumn join = method .isAnnotationPresent(javax.persistence.JoinColumn.class) ? (javax.persistence.JoinColumn) method .getAnnotation(javax.persistence.JoinColumn.class) : null; Relationship rel = createRelationship(method, "one-to-many", join, othersideName, join != null ? !join.nullable() : false); rel.setLikeManyToOne(table.getIsLikeManyToOne(rel.getRelationshipName())); rel.setSave(isSave); table.addRelationship(rel); if (includeDesc) { rel.setDesc(getFieldDesc(tableName, rel.getRelationshipName())); rel.setNameDesc(getFieldNameDesc(tableName, rel.getRelationshipName())); } } else if (method.isAnnotationPresent(javax.persistence.OneToOne.class)) { javax.persistence.OneToOne oneToOne = (javax.persistence.OneToOne) method .getAnnotation(javax.persistence.OneToOne.class); String leftSideVarName = getFieldNameFromMethod(method); boolean isMappedBy = true; String othersideName = oneToOne.mappedBy(); if (StringUtils.isEmpty(othersideName)) { isMappedBy = false; othersideName = getRightSideForOneToOne(classObj, typeClass, leftSideVarName, othersideName, isMappedBy); } boolean isSave = false; for (CascadeType ct : oneToOne.cascade()) { if (ct == CascadeType.ALL || ct == CascadeType.PERSIST) { isSave = true; } } isSave = !isSave ? isOKToSave(method) : isSave; javax.persistence.JoinColumn join = method .isAnnotationPresent(javax.persistence.JoinColumn.class) ? (javax.persistence.JoinColumn) method .getAnnotation(javax.persistence.JoinColumn.class) : null; Relationship rel = createRelationship(method, "one-to-one", join, othersideName, join != null ? !join.nullable() : false); rel.setSave(isSave); table.addRelationship(rel); if (includeDesc) { rel.setDesc(getFieldDesc(tableName, rel.getRelationshipName())); rel.setNameDesc(getFieldNameDesc(tableName, rel.getRelationshipName())); } } isLob = false; } // This updates each field as to whether it is an index table.updateIndexFields(); } } catch (Exception ex) { ex.printStackTrace(); } }
From source file:com.denimgroup.threadfix.data.entities.Application.java
@ManyToMany(cascade = CascadeType.ALL) @JoinTable(name = "Application_Tag", joinColumns = { @JoinColumn(name = "Application_Id") }, inverseJoinColumns = { @JoinColumn(name = "Tag_Id") }) @JsonView({ AllViews.RestViewTag.class, AllViews.FormInfo.class }) public List<Tag> getTags() { return tags;/*from w ww . j av a 2 s . c om*/ }