我正在尝试与共享 PK 建立一对一的关系,但是在尝试了很多事情之后我陷入了困境......
我会尽量提供所有可能的信息:
我正在使用的技术:
数据源配置:
spring.datasource.url = jdbc:mysql://localhost:3306/customers?serverTimezone=UTC&useSSL=false&allowPublicKeyRetrieval=true&useSSL=false
spring.datasource.username = admin
spring.datasource.password = root
spring.jpa.database-platform = org.hibernate.dialect.MySQL5InnoDBDialect
spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.MySQL5InnoDBDialect
spring.jpa.show-sql = true
Run Code Online (Sandbox Code Playgroud)
数据库模型:
@Getter
@Setter
@NoArgsConstructor
@Entity
@Table(name = "customer", schema = "customers")
public class Customer {
@Id
@GeneratedValue(generator = "uuid2")
@GenericGenerator(name = "uuid2", strategy = "uuid2")
@Column(name = "customer_id", columnDefinition = "BINARY(16)")
private UUID customerId;
@OneToOne(mappedBy = "customer", cascade = CascadeType.ALL)
private Address address;
}
@Getter
@Setter
@NoArgsConstructor
@Entity
@Table(name = "address", schema …Run Code Online (Sandbox Code Playgroud)