org.hibernate.annotations.Fetch类的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(7.5k)|赞(0)|评价(0)|浏览(283)

本文整理了Java中org.hibernate.annotations.Fetch类的一些代码示例,展示了Fetch类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Fetch类的具体详情如下:
包路径:org.hibernate.annotations.Fetch
类名称:Fetch

Fetch介绍

暂无

代码示例

代码示例来源:origin: hibernate/hibernate-orm

@OneToMany(cascade=CascadeType.ALL, mappedBy = "veryOldPerson")
@Fetch(FetchMode.SELECT)
public Collection<Stay> getVeryOldStays() {
  return veryOldStays;
}

代码示例来源:origin: hibernate/hibernate-orm

if ( fetch.value() == org.hibernate.annotations.FetchMode.JOIN ) {
  toOne.setFetchMode( FetchMode.JOIN );
  toOne.setLazy( false );
  toOne.setUnwrapProxy( false );
else if ( fetch.value() == org.hibernate.annotations.FetchMode.SELECT ) {
  toOne.setFetchMode( FetchMode.SELECT );
else if ( fetch.value() == org.hibernate.annotations.FetchMode.SUBSELECT ) {
  throw new AnnotationException( "Use of FetchMode.SUBSELECT not allowed on ToOne associations" );
  throw new AssertionFailure( "Unknown FetchMode: " + fetch.value() );

代码示例来源:origin: hibernate/hibernate-orm

if ( fetch.value() == org.hibernate.annotations.FetchMode.JOIN ) {
  collection.setFetchMode( FetchMode.JOIN );
  collection.setLazy( false );
else if ( fetch.value() == org.hibernate.annotations.FetchMode.SELECT ) {
  collection.setFetchMode( FetchMode.SELECT );
else if ( fetch.value() == org.hibernate.annotations.FetchMode.SUBSELECT ) {
  collection.setFetchMode( FetchMode.SELECT );
  collection.setSubselectLoadable( true );
  throw new AssertionFailure( "Unknown FetchMode: " + fetch.value() );

代码示例来源:origin: hibernate/hibernate-orm

@JoinTable(name = "REVCHANGES", joinColumns = @JoinColumn(name = "REV"))
@Column(name = "ENTITYNAME")
@Fetch(FetchMode.JOIN)
@ModifiedEntityNames
private Set<String> modifiedEntityNames = new HashSet<>();

代码示例来源:origin: stackoverflow.com

private void applyFetchMode(Root<T> root) {
  for (Field field : getDomainClass().getDeclaredFields()) {

    Fetch fetch = field.getAnnotation(Fetch.class);

    if (fetch != null && fetch.value() == FetchMode.JOIN) {
      root.fetch(field.getName(), JoinType.LEFT);
    }
  }
}

代码示例来源:origin: hibernate/hibernate-orm

@ManyToOne(targetEntity = Team.class)
@Fetch(FetchMode.SELECT)
@JoinColumn(name = "team_id")
public Team getTeam() {
  return team;
}

代码示例来源:origin: org.hibernate/hibernate-annotations

if ( fetch.value() == org.hibernate.annotations.FetchMode.JOIN ) {
  toOne.setFetchMode( FetchMode.JOIN );
  toOne.setLazy( false );
  toOne.setUnwrapProxy( false );
else if ( fetch.value() == org.hibernate.annotations.FetchMode.SELECT ) {
  toOne.setFetchMode( FetchMode.SELECT );
else if ( fetch.value() == org.hibernate.annotations.FetchMode.SUBSELECT ) {
  throw new AnnotationException( "Use of FetchMode.SUBSELECT not allowed on ToOne associations" );
  throw new AssertionFailure( "Unknown FetchMode: " + fetch.value() );

代码示例来源:origin: hibernate/hibernate-orm

@JoinTable(name = "REVCHANGES", joinColumns = @JoinColumn(name = "REV"))
@Column(name = "ENTITYNAME")
@Fetch(FetchMode.JOIN)
@ModifiedEntityNames
private Set<String> modifiedEntityNames = new HashSet<>();

代码示例来源:origin: org.hibernate/hibernate-annotations

if ( fetch.value() == org.hibernate.annotations.FetchMode.JOIN ) {
  collection.setFetchMode( FetchMode.JOIN );
  collection.setLazy( false );
else if ( fetch.value() == org.hibernate.annotations.FetchMode.SELECT ) {
  collection.setFetchMode( FetchMode.SELECT );
else if ( fetch.value() == org.hibernate.annotations.FetchMode.SUBSELECT ) {
  collection.setFetchMode( FetchMode.SELECT );
  collection.setSubselectLoadable( true );
  throw new AssertionFailure( "Unknown FetchMode: " + fetch.value() );

代码示例来源:origin: hibernate/hibernate-orm

@javax.persistence.Entity
@Table(name="entity")
public static class AnEntity {
  @Id
  @GeneratedValue
  private Long id;
  @ManyToOne
  private OtherEntity otherEntityDefault;
  @ManyToOne
  @Fetch(FetchMode.JOIN)
  private OtherEntity otherEntityJoin;
  @ManyToOne
  @Fetch(FetchMode.SELECT)
  private OtherEntity otherEntitySelect;
  // @Fetch(FetchMode.SUBSELECT) is not allowed for ToOne associations
}

代码示例来源:origin: hibernate/hibernate-orm

@ManyToOne(cascade = CascadeType.ALL)
@LazyToOne(LazyToOneOption.PROXY)
@Fetch(FetchMode.SELECT)
@JoinColumn(name = "oldperson")
public Person getOldPerson() {
  return oldPerson;
}

代码示例来源:origin: hibernate/hibernate-orm

@OneToMany(cascade=CascadeType.ALL, mappedBy = "oldPerson")
@LazyCollection(LazyCollectionOption.EXTRA)
@Fetch(FetchMode.SUBSELECT)
public Collection<Stay> getOldStays() {
  return oldStays;
}

代码示例来源:origin: hibernate/hibernate-orm

@OneToMany(targetEntity = Player.class, mappedBy = "team", fetch = FetchType.EAGER)
@Fetch(FetchMode.SELECT)
@Loader(namedQuery = "loadByTeam")
public Set<Player> getPlayers() {
  return players;
}

代码示例来源:origin: hibernate/hibernate-orm

@OneToMany(targetEntity = ChildEntity.class, mappedBy = "parent")
@LazyCollection(LazyCollectionOption.EXTRA)
@Fetch(FetchMode.SELECT)
public Set<ChildEntity> getChildren() {
  return children;
}

代码示例来源:origin: hibernate/hibernate-orm

@ManyToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
@LazyToOne(LazyToOneOption.PROXY)
@Fetch(FetchMode.JOIN)
@JoinColumn(name = "veryoldperson")
public Person getVeryOldPerson() {
  return veryOldPerson;
}

代码示例来源:origin: hibernate/hibernate-orm

@Entity(name = "Department")
public static class Department {
  @Id
  private Long id;
  @OneToMany(mappedBy = "department", fetch = FetchType.LAZY)
  @Fetch(FetchMode.SELECT)
  private List<Employee> employees = new ArrayList<>();
  //Getters and setters omitted for brevity
//end::fetching-strategies-fetch-mode-select-mapping-example[]
  public Long getId() {
    return id;
  }
  public void setId(Long id) {
    this.id = id;
  }
  public List<Employee> getEmployees() {
    return employees;
  }
  public void setEmployees(List<Employee> employees) {
    this.employees = employees;
  }
//tag::fetching-strategies-fetch-mode-select-mapping-example[]
}

代码示例来源:origin: hibernate/hibernate-orm

@Entity(name = "Department")
public static class Department {
  @Id
  private Long id;
  //tag::fetching-strategies-fetch-mode-join-mapping-example[]
  @OneToMany(mappedBy = "department")
  @Fetch(FetchMode.JOIN)
  private List<Employee> employees = new ArrayList<>();
  //end::fetching-strategies-fetch-mode-join-mapping-example[]
  //Getters and setters omitted for brevity
  public Long getId() {
    return id;
  }
  public void setId(Long id) {
    this.id = id;
  }
  public List<Employee> getEmployees() {
    return employees;
  }
  public void setEmployees(List<Employee> employees) {
    this.employees = employees;
  }
}

代码示例来源:origin: hibernate/hibernate-orm

@Entity(name = "MainEntity")
public static class MainEntity {
  @Id
  @GeneratedValue
  private Long id;
  @ManyToOne(fetch = FetchType.LAZY)
  @Fetch(org.hibernate.annotations.FetchMode.JOIN)
  private SubEntity sub;
  public Long getId() {
    return id;
  }
  public void setId(Long id) {
    this.id = id;
  }
  public SubEntity getSub() {
    return sub;
  }
  public void setSub(SubEntity sub) {
    this.sub = sub;
  }
}

代码示例来源:origin: hibernate/hibernate-orm

@Entity(name = "Product")
public static class Product {
  @Id
  @GeneratedValue
  private int id;
  @ManyToOne(fetch = FetchType.EAGER, cascade = CascadeType.ALL)
  @NotFound(action = NotFoundAction.IGNORE)
  @JoinColumn(name = "categoryId")
  @Fetch(FetchMode.SELECT)
  private Category category;
  private ContainedCategory containedCategory;
  @ElementCollection(fetch = FetchType.EAGER)
  private Set<ContainedCategory> containedCategories = new HashSet<>();
}

代码示例来源:origin: hibernate/hibernate-orm

@Entity(name = "Product")
public static class Product {
  @Id
  @GeneratedValue
  private int id;
  @ManyToOne(fetch = FetchType.EAGER, cascade = CascadeType.ALL)
  @NotFound(action = NotFoundAction.IGNORE)
  @JoinColumn(name = "categoryId")
  @Fetch(FetchMode.JOIN)
  private Category category;
  private ContainedCategory containedCategory;
  @ElementCollection(fetch = FetchType.EAGER)
  private Set<ContainedCategory> containedCategories = new HashSet<>();
}

相关文章