我有一个使用Spring JPA,hibernate,Derby数据库的Spring Boot应用程序,具有以下实体和关系;
@Entity
@Table(name = "users")
public class User implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "id", nullable = false, updatable = false)
private Long id;
@Column(name = "email", nullable = false, unique = true)
private String email;
//bi-directional one-to-one association to Profile
@OneToOne(cascade={CascadeType.ALL}, orphanRemoval=true)
@JoinColumn(name="profile_id")
private Profile profile;
// ... other fields + getters & setters
}
然后我有一个相关的实体,如下所示;
@Entity
@Table(name = "profiles")
public class Profile implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "id", nullable = false, updatable = false)
private Long id;
//bi-directional one-to-one association to User
@OneToOne(mappedBy="profile")
private User user;
@Column(name = "first_name", nullable = false)
private String firstname;
@Column(name = "last_name", nullable = false)
private String lastname;
// ... other fields + getters & setters
}
奇怪的是,我注意到当我运行应用程序并从实体创建数据库表时,也会在配置文件表中创建电子邮件列,即使实体未声明电子邮件字段。
1。有人可以首先解释为什么会这样吗?
2. 如何确保个人资料表没有电子邮件列?