我正在尝试使用由 Hibernate 实现的 JPA 在数据库中持久化 Team 对象(实体)。Team 的一个属性是 Contact 对象。当我创建一个团队对象并设置联系人属性时,是否有一个注释可以用来说明当我坚持一个团队时,如果我提供给团队的联系人不存在,请继续创建/坚持它?
//New Contact, that is NOT in the database yet
Contact c = new Contact();
c.setName("John Doe");
Team team = new Team();
team.setName("Ravens");
team.setContact(c);
//now make call to persist Team. Can the call to persist the team also persist the Contact?