我正在使用@Entity
和CrudRepository
在我的MySQL数据库中创建一个条目,我想知道@GeneratedValue(strategy = GenerationType.AUTO)在什么时候执行并生成自动增量值?@GenerateValue在休眠时执行什么时候执行
@Entity
@Table(name = "all_contacts")
public class Contact {
//Ideally this would be set as foreign key to application's user schema
private long userId;
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name="contactid")
private long contactId;
@NotNull
private String name;
//getters and setters
}
//
public interface ContactRepository extends CrudRepository<Contact, Long> { }
我问,因为我想访问contactId
通过其吸气剂的价值,但我必须要等到ContactRepository.save()
叫?