我正在尝试使用由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?