Spring Data JPA Quick Guide
  • Spring Data JPA 快速指南
  • 配置依赖
  • 配置数据源
  • 数据库编码与词语定序
  • Core Concepts
  • 基本用法
  • Transactions
    • 什么是事务
    • 配置事务(@EnableTransactionManagement)
    • 配置事务(XML)
    • 配置事务(@Transactional)
    • @Transactional 实现细节
    • Transaction and Spring Data JPA
    • 事务隔离
    • 事务传播
  • Query Creation from Method Names
  • Using @Query
  • Sorting and Pagination
  • Projection
  • Specification
  • Query by Example
  • javax.persistence Annotations
    • @OneToOne (bidirectional)
      • Usage
      • PO Serialization
      • Save and Update
      • Nested Projection
      • @MapsId
    • @OneToMany (bidirectional)
    • @OneToMany (unidirectional)
    • @ManyToMany (bidirectional)
      • Many-to-Many Using a Composite Key
由 GitBook 提供支持
在本页
  1. javax.persistence Annotations
  2. @OneToOne (bidirectional)

Nested Projection

TuitionView

public interface TuitionView {
    Double getFee();
    StudentView getStudent();
}

StudentView

public interface StudentView {
    String getName();
}

可以发现,上面的投影是通过 owning side 访问 non-owning side。这样是合法的。

TuitionView

public interface TuitionView {
    Double getFee();
}

StudentView

public interface StudentView {
    String getName();
    TuitionView getTuition();
}

如果是这样反过来,从 non-owning side 访问 owning side,那么 StudentView.tuition 会被设置成 null。

Projection 中,从 non-owning side 访问 owning side 是不被允许的!

上一页Save and Update下一页@MapsId

最后更新于3年前