javax.persistence.FetchType Java Examples

The following examples show how to use javax.persistence.FetchType. 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: AbstractEntityMetaFactory.java    From crnk-framework with Apache License 2.0 6 votes vote down vote up
protected boolean isJpaLazy(Collection<Annotation> annotations, boolean isAssociation) {
	for (Annotation annotation : annotations) {
		if (annotation instanceof OneToMany) {
			OneToMany oneToMany = (OneToMany) annotation;
			return oneToMany.fetch() == FetchType.LAZY;
		}
		if (annotation instanceof ManyToOne) {
			ManyToOne manyToOne = (ManyToOne) annotation;
			return manyToOne.fetch() == FetchType.LAZY;
		}
		if (annotation instanceof ManyToMany) {
			ManyToMany manyToMany = (ManyToMany) annotation;
			return manyToMany.fetch() == FetchType.LAZY;
		}
		if (annotation instanceof ElementCollection) {
			ElementCollection elementCollection = (ElementCollection) annotation;
			return elementCollection.fetch() == FetchType.LAZY;
		}
	}
	return isAssociation;
}
 
Example #2
Source File: User.java    From aws-photosharing-example with Apache License 2.0 5 votes vote down vote up
@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;}
 
Example #3
Source File: ImageOverview.java    From uyuni with GNU General Public License v2.0 5 votes vote down vote up
/**
 * @return the channels
 */
@ManyToMany(fetch = FetchType.LAZY)
@JoinTable(name = "suseImageInfoChannel",
    joinColumns = {
        @JoinColumn(name = "image_info_id", nullable = false, updatable = false)},
    inverseJoinColumns = {
        @JoinColumn(name = "channel_id", nullable = false, updatable = false)}
)
public Set<Channel> getChannels() {
    return channels;
}
 
Example #4
Source File: ImageOverview.java    From uyuni with GNU General Public License v2.0 5 votes vote down vote up
/**
 * @return the installed products
 */
@ManyToMany(fetch = FetchType.LAZY)
@JoinTable(name = "suseImageInfoInstalledProduct",
    joinColumns = {
        @JoinColumn(name = "image_info_id", nullable = false, updatable = false)},
    inverseJoinColumns = {
        @JoinColumn(name = "installed_product_id", nullable = false, updatable = false)
})
public Set<InstalledProduct> getInstalledProducts() {
    return installedProducts;
}
 
Example #5
Source File: Role.java    From tianti with Apache License 2.0 5 votes vote down vote up
@ManyToMany(fetch = FetchType.LAZY)
@JoinTable(name = "org_role_resource_rel", 
	joinColumns = {@JoinColumn(name = "role_id")},
	inverseJoinColumns = {@JoinColumn(name = "resources_id")})
public Set<Resource> getResources() {
	return resources;
}
 
Example #6
Source File: JPAOverriddenAnnotationReader.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
private void getFetchType(AnnotationDescriptor descriptor, Element element) {
	String fetchString = element != null ? element.attributeValue( "fetch" ) : null;
	if ( fetchString != null ) {
		if ( "eager".equalsIgnoreCase( fetchString ) ) {
			descriptor.setValue( "fetch", FetchType.EAGER );
		}
		else if ( "lazy".equalsIgnoreCase( fetchString ) ) {
			descriptor.setValue( "fetch", FetchType.LAZY );
		}
	}
}
 
Example #7
Source File: AnnotationBinder.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
public static FetchMode getFetchMode(FetchType fetch) {
	if ( fetch == FetchType.EAGER ) {
		return FetchMode.JOIN;
	}
	else {
		return FetchMode.SELECT;
	}
}
 
Example #8
Source File: MetadataTable.java    From youkefu with Apache License 2.0 5 votes vote down vote up
/**
 * @return the tableproperty
 */
@Where(clause="impfield=0")	//不载入 设置为 禁用 导入导出的字段
@OneToMany(cascade = CascadeType.ALL,fetch = FetchType.EAGER)
@JoinColumn(name = "dbtableid")
@OrderBy("sortindex")
public List<TableProperties> getTableproperty() {
	return tableproperty;
}
 
Example #9
Source File: User.java    From tianti with Apache License 2.0 5 votes vote down vote up
@ManyToMany(fetch = FetchType.LAZY)
@JoinTable(name = "org_user_role_rel", 
		joinColumns = {@JoinColumn(name = "user_id")}, 
		inverseJoinColumns = {@JoinColumn(name = "role_id")})
@Where(clause="delete_flag=0")
@OrderBy("no")
public Set<Role> getRoles() {
	return roles;
}
 
Example #10
Source File: ImageOverview.java    From uyuni with GNU General Public License v2.0 5 votes vote down vote up
/**
 * @return the patches
 */
@ManyToMany(fetch = FetchType.LAZY)
@JoinTable(name = "rhnImageNeededErrataCache",
        joinColumns = {@JoinColumn(name = "image_id")},
        inverseJoinColumns = {@JoinColumn(name = "errata_id")}
)
public Set<PublishedErrata> getPatches() {
    return patches;
}
 
Example #11
Source File: ProjectSource.java    From uyuni with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Gets the contentProject.
 *
 * @return contentProject
 */
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "project_id")
public ContentProject getContentProject() {
    return contentProject;
}
 
Example #12
Source File: SUSEProductSCCRepository.java    From uyuni with GNU General Public License v2.0 4 votes vote down vote up
/**
 * @return Returns the repoId.
 */
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "repo_id", nullable = false)
public SCCRepository getRepository() {
    return repository;
}
 
Example #13
Source File: SUSEProductSCCRepository.java    From uyuni with GNU General Public License v2.0 4 votes vote down vote up
/**
 * @return Returns the root product.
 */
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "root_product_id", nullable = false)
public SUSEProduct getRootProduct() {
    return rootProduct;
}
 
Example #14
Source File: SUSEProductSCCRepository.java    From uyuni with GNU General Public License v2.0 4 votes vote down vote up
/**
 * @return Returns the product.
 */
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "product_id", nullable = false)
public SUSEProduct getProduct() {
    return product;
}
 
Example #15
Source File: EnvironmentTarget.java    From uyuni with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Gets the contentEnvironment.
 *
 * @return contentEnvironment
 */
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "env_id")
public ContentEnvironment getContentEnvironment() {
    return contentEnvironment;
}
 
Example #16
Source File: ResourceComment.java    From Exam-Online with Apache License 2.0 4 votes vote down vote up
@ManyToOne(fetch=FetchType.LAZY)
public Resource getResource() {
	return resource;
}
 
Example #17
Source File: ReportFilter.java    From youkefu with Apache License 2.0 4 votes vote down vote up
@ManyToOne(fetch = FetchType.EAGER)
   @JoinColumn(name="tableproperty")
@NotFound(action=NotFoundAction.IGNORE)
public TableProperties getTableproperty() {
	return tableproperty;
}
 
Example #18
Source File: SysUser.java    From Exam-Online with Apache License 2.0 4 votes vote down vote up
@Override
@ManyToMany(fetch=FetchType.LAZY)
@JoinTable(name = "sys_user_authority")
public Set<SysAuthority> getAuthorities() {
	return authorities;
}
 
Example #19
Source File: BuyLog.java    From Exam-Online with Apache License 2.0 4 votes vote down vote up
@ManyToOne(fetch=FetchType.LAZY)
public SysUser getUser() {
	return user;
}
 
Example #20
Source File: Person.java    From quarkus with Apache License 2.0 4 votes vote down vote up
@ManyToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
public SequencedAddress getAddress() {
    return address;
}
 
Example #21
Source File: BuyLog.java    From Exam-Online with Apache License 2.0 4 votes vote down vote up
@ManyToOne(fetch=FetchType.LAZY)
public Resource getResource() {
	return resource;
}
 
Example #22
Source File: Choice.java    From Exam-Online with Apache License 2.0 4 votes vote down vote up
@ManyToOne(fetch = FetchType.LAZY)
public Question getQuestion() {
	return question;
}
 
Example #23
Source File: Client.java    From KITE with Apache License 2.0 4 votes vote down vote up
@OneToOne(cascade = CascadeType.ALL, fetch = FetchType.EAGER)
public BrowserSpecs getBrowserSpecs() {
  return this.browserSpecs;
}
 
Example #24
Source File: User.java    From aws-photosharing-example with Apache License 2.0 4 votes vote down vote up
@XmlTransient
@LazyCollection(LazyCollectionOption.EXTRA)
@OneToMany(mappedBy = "user", orphanRemoval=true, fetch=FetchType.LAZY, cascade=CascadeType.ALL)
public List<Media> getMedia() {return media;}
 
Example #25
Source File: Funcionario.java    From ponto-inteligente-api with MIT License 4 votes vote down vote up
@ManyToOne(fetch = FetchType.EAGER)
public Empresa getEmpresa() {
	return empresa;
}
 
Example #26
Source File: Cluster.java    From uyuni with GNU General Public License v2.0 4 votes vote down vote up
/**
 * @return org to get
 */
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "org_id")
public Org getOrg() {
    return org;
}
 
Example #27
Source File: QuestionComment.java    From Exam-Online with Apache License 2.0 4 votes vote down vote up
@ManyToOne(fetch=FetchType.LAZY)
public Question getQuestion() {
	return question;
}
 
Example #28
Source File: Person.java    From quarkus with Apache License 2.0 4 votes vote down vote up
@ManyToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
public SequencedAddress getAddress() {
    return address;
}
 
Example #29
Source File: ImageInfo.java    From uyuni with GNU General Public License v2.0 4 votes vote down vote up
/**
 * @return the custom data values
 */
@OneToMany(fetch = FetchType.LAZY, mappedBy = "imageInfo", cascade = CascadeType.ALL)
public Set<ImageInfoCustomDataValue> getCustomDataValues() {
    return customDataValues;
}
 
Example #30
Source File: ContentEnvironment.java    From uyuni with GNU General Public License v2.0 4 votes vote down vote up
/**
 * @return the nextEnvironment
 */
@OneToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
@JoinColumn(name = "next_env_id")
protected ContentEnvironment getNextEnvironment() {
    return nextEnvironment;
}