javax.persistence.OneToMany Java Examples

The following examples show how to use javax.persistence.OneToMany. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AuftragDO.java    From projectforge-webapp with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Get the position entries for this object.
 */
@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER, orphanRemoval = true, mappedBy = "auftrag")
@IndexColumn(name = "number", base = 1)
public List<AuftragsPositionDO> getPositionen()
{
  return this.positionen;
}
 
Example #2
Source File: Node.java    From ankush with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * @return the configuration
 */
@OneToMany(fetch = FetchType.LAZY, cascade = CascadeType.REMOVE)
@JoinColumns({
		@JoinColumn(name = "clusterId", referencedColumnName = "clusterId"),
		@JoinColumn(name = "host", referencedColumnName = "publicIp") })
public List<Configuration> getConfiguration() {
	return configuration;
}
 
Example #3
Source File: EventSupport.java    From jkes with Apache License 2.0 5 votes vote down vote up
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;
}
 
Example #4
Source File: A.java    From hyperjaxb3 with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@OneToMany(cascade = CascadeType.ALL)
public List<EItem> getEItems() {
	if (eItems == null) {
		eItems = new ArrayList<EItem>();
	}
	if (ItemUtils.shouldBeWrapped(e))
		e = ItemUtils.wrap(e, eItems, EItem.class);
	return this.eItems;
}
 
Example #5
Source File: Node.java    From ankush with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * @return the configuration
 */
@OneToMany(fetch = FetchType.LAZY, cascade = CascadeType.REMOVE)
@JoinColumns({
		@JoinColumn(name = "clusterId", referencedColumnName = "clusterId"),
		@JoinColumn(name = "host", referencedColumnName = "publicIp") })
public List<Event> getEvents() {
	return events;
}
 
Example #6
Source File: TaskData.java    From scheduling with GNU Affero General Public License v3.0 5 votes vote down vote up
@Cascade(CascadeType.ALL)
@OneToMany(fetch = FetchType.LAZY, mappedBy = "taskData")
@OnDelete(action = OnDeleteAction.CASCADE)
@OrderColumn(name = "SCRIPT_ORDER")
public List<SelectionScriptData> getSelectionScripts() {
    return selectionScripts;
}
 
Example #7
Source File: DocumentAttachmentContainer.java    From cia with Apache License 2.0 5 votes vote down vote up
/**
* Gets the document attachment list.
*
* @return the document attachment list
*/
  @OneToMany(targetEntity = DocumentAttachment.class, cascade = {
      CascadeType.ALL
  })
  @JoinColumn(name = "DOCUMENT_ATTACHMENT_LIST_DOC_0")
  public List<DocumentAttachment> getDocumentAttachmentList() {
      return this.documentAttachmentList;
  }
 
Example #8
Source File: PersonDetailData.java    From cia with Apache License 2.0 5 votes vote down vote up
/**
* Gets the detail list.
*
* @return the detail list
*/
  @OneToMany(targetEntity = DetailData.class, cascade = {
      CascadeType.ALL
  })
  @JoinColumn(name = "DETAIL_LIST_PERSON_DETAIL_DA_0")
  public List<DetailData> getDetailList() {
      return this.detailList;
  }
 
Example #9
Source File: ReplicationConfiguration.java    From juddi with Apache License 2.0 5 votes vote down vote up
@OneToMany(targetEntity = ControlMessage.class, fetch = FetchType.LAZY, cascade = CascadeType.ALL)
public List<ControlMessage> getControlMessage() {
        if (controlledMessage == null) {
                controlledMessage = new ArrayList<ControlMessage>();
        }
        return this.controlledMessage;
}
 
Example #10
Source File: Resource.java    From base-framework with Apache License 2.0 4 votes vote down vote up
/**
 * 获取子类资源
 * 
 * @return List
 */
@OrderBy("sort ASC")
@OneToMany(mappedBy = "parent",fetch = FetchType.LAZY,cascade={CascadeType.ALL})
public List<Resource> getChildren() {
	return children;
}
 
Example #11
Source File: Role.java    From OA with GNU General Public License v3.0 4 votes vote down vote up
@OneToMany(cascade={CascadeType.ALL},mappedBy="roleId")
public Set<UsersRoles> getUsersRoles() {
	return usersRoles;
}
 
Example #12
Source File: TicketCatalog.java    From lemon with Apache License 2.0 4 votes vote down vote up
/** @return . */
@OneToMany(fetch = FetchType.LAZY, mappedBy = "ticketCatalog")
public Set<TicketInfo> getTicketInfos() {
    return this.ticketInfos;
}
 
Example #13
Source File: Module.java    From hrms with Apache License 2.0 4 votes vote down vote up
@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER, mappedBy = "module")
public Set<Syslog> getSyslogs() {
	return this.syslogs;
}
 
Example #14
Source File: User.java    From TinyMooc with Apache License 2.0 4 votes vote down vote up
@OneToMany(fetch = FetchType.LAZY, mappedBy = "user")
public Set<Comment> getComments() {
    return this.comments;
}
 
Example #15
Source File: TicketInfo.java    From lemon with Apache License 2.0 4 votes vote down vote up
/** @return . */
@OneToMany(fetch = FetchType.LAZY, mappedBy = "ticketInfo")
public Set<TicketComment> getTicketComments() {
    return this.ticketComments;
}
 
Example #16
Source File: UserRepo.java    From lemon with Apache License 2.0 4 votes vote down vote up
/** @return . */
@OneToMany(fetch = FetchType.LAZY, mappedBy = "userRepo")
public Set<UserBase> getUserBases() {
    return this.userBases;
}
 
Example #17
Source File: Address.java    From juddi with Apache License 2.0 4 votes vote down vote up
@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "address")
@OrderBy
public List<AddressLine> getAddressLines() {
	return this.addressLines;
}
 
Example #18
Source File: PlmProject.java    From lemon with Apache License 2.0 4 votes vote down vote up
/** @return . */
@OneToMany(fetch = FetchType.LAZY, mappedBy = "plmProject")
public Set<PlmIssue> getPlmIssues() {
    return this.plmIssues;
}
 
Example #19
Source File: CollectionBinder.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
protected void bindOneToManySecondPass(
		Collection collection,
		Map persistentClasses,
		Ejb3JoinColumn[] fkJoinColumns,
		XClass collectionType,
		boolean cascadeDeleteEnabled,
		boolean ignoreNotFound,
		MetadataBuildingContext buildingContext,
		Map<XClass, InheritanceState> inheritanceStatePerClass) {

	final boolean debugEnabled = LOG.isDebugEnabled();
	if ( debugEnabled ) {
		LOG.debugf( "Binding a OneToMany: %s.%s through a foreign key", propertyHolder.getEntityName(), propertyName );
	}
	if ( buildingContext == null ) {
		throw new AssertionFailure(
				"CollectionSecondPass for oneToMany should not be called with null mappings"
		);
	}
	org.hibernate.mapping.OneToMany oneToMany = new org.hibernate.mapping.OneToMany( buildingContext, collection.getOwner() );
	collection.setElement( oneToMany );
	oneToMany.setReferencedEntityName( collectionType.getName() );
	oneToMany.setIgnoreNotFound( ignoreNotFound );

	String assocClass = oneToMany.getReferencedEntityName();
	PersistentClass associatedClass = (PersistentClass) persistentClasses.get( assocClass );
	if ( jpaOrderBy != null ) {
		final String orderByFragment = buildOrderByClauseFromHql(
				jpaOrderBy.value(),
				associatedClass,
				collection.getRole()
		);
		if ( StringHelper.isNotEmpty( orderByFragment ) ) {
			collection.setOrderBy( orderByFragment );
		}
	}
	Map<String, Join> joins = buildingContext.getMetadataCollector().getJoins( assocClass );
	if ( associatedClass == null ) {
		throw new MappingException(
				String.format("Association [%s] for entity [%s] references unmapped class [%s]",
						propertyName, propertyHolder.getClassName(), assocClass)
		);
	}
	oneToMany.setAssociatedClass( associatedClass );
	for (Ejb3JoinColumn column : fkJoinColumns) {
		column.setPersistentClass( associatedClass, joins, inheritanceStatePerClass );
		column.setJoins( joins );
		collection.setCollectionTable( column.getTable() );
	}
	if ( debugEnabled ) {
		LOG.debugf( "Mapping collection: %s -> %s", collection.getRole(), collection.getCollectionTable().getName() );
	}
	bindFilters( false );
	bindCollectionSecondPass( collection, null, fkJoinColumns, cascadeDeleteEnabled, property, propertyHolder, buildingContext );
	if ( !collection.isInverse()
			&& !collection.getKey().isNullable() ) {
		// for non-inverse one-to-many, with a not-null fk, add a backref!
		String entityName = oneToMany.getReferencedEntityName();
		PersistentClass referenced = buildingContext.getMetadataCollector().getEntityBinding( entityName );
		Backref prop = new Backref();
		prop.setName( '_' + fkJoinColumns[0].getPropertyName() + '_' + fkJoinColumns[0].getLogicalColumnName() + "Backref" );
		prop.setUpdateable( false );
		prop.setSelectable( false );
		prop.setCollectionRole( collection.getRole() );
		prop.setEntityName( collection.getOwner().getEntityName() );
		prop.setValue( collection.getKey() );
		referenced.addProperty( prop );
	}
}
 
Example #20
Source File: Module.java    From hrms with Apache License 2.0 4 votes vote down vote up
@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "module")
public Set<RolePermission> getRolePermissions() {
	return this.rolePermissions;
}
 
Example #21
Source File: PurchaseOrderRegisiter.java    From OA with GNU General Public License v3.0 4 votes vote down vote up
@OneToMany(mappedBy="order",cascade={CascadeType.ALL})
public Set<OrderProductRecord> getProductRecords() {
	return productRecords;
}
 
Example #22
Source File: Role.java    From hrms with Apache License 2.0 4 votes vote down vote up
@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "role")
public Set<RoleModule> getRoleModules() {
	return this.roleModules;
}
 
Example #23
Source File: Account.java    From authlib-agent with MIT License 4 votes vote down vote up
@OneToMany(mappedBy = "owner", cascade = CascadeType.ALL)
public Set<GameProfile> getProfiles() {
	return profiles;
}
 
Example #24
Source File: ImageBuildHistory.java    From uyuni with GNU General Public License v2.0 4 votes vote down vote up
/**
 * @return the repo digests
 */
@OneToMany(fetch = FetchType.LAZY, mappedBy = "buildHistory", cascade = CascadeType.ALL)
public Set<ImageRepoDigest> getRepoDigests() {
    return repoDigests;
}
 
Example #25
Source File: ImageInfo.java    From uyuni with GNU General Public License v2.0 4 votes vote down vote up
/**
 * @return the build history
 */
@OneToMany(fetch = FetchType.LAZY, mappedBy = "imageInfo", cascade = CascadeType.ALL)
public Set<ImageBuildHistory> getBuildHistory() {
    return buildHistory;
}
 
Example #26
Source File: ImageInfo.java    From uyuni with GNU General Public License v2.0 4 votes vote down vote up
/**
 * @return the packages
 */
@OneToMany(fetch = FetchType.LAZY, mappedBy = "imageInfo")
public Set<ImagePackage> getPackages() {
    return packages;
}
 
Example #27
Source File: UserRepo.java    From lemon with Apache License 2.0 4 votes vote down vote up
/** @return . */
@OneToMany(fetch = FetchType.LAZY, mappedBy = "userRepo")
public Set<UserSchema> getUserSchemas() {
    return this.userSchemas;
}
 
Example #28
Source File: Classes.java    From sample-java-spring-genericdao with Apache License 2.0 4 votes vote down vote up
@OneToMany(fetch = FetchType.LAZY, mappedBy = "classes")
public Set<InstructorClasses> getClasseses() {
	return this.instructorClasses;
}
 
Example #29
Source File: Module.java    From hrms with Apache License 2.0 4 votes vote down vote up
@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "module")
public Set<UserPermission> getUserPermissions() {
	return this.userPermissions;
}
 
Example #30
Source File: SalesAgreement.java    From OA with GNU General Public License v3.0 4 votes vote down vote up
@OneToMany(mappedBy="order",cascade={CascadeType.ALL})
public Set<PaymentPlan> getPaymentPlans() {
	return paymentPlans;
}