简体   繁体   中英

Hibernate 1.0 + JPA + Netbeans 7.01 + Sql server 2005 = Problems to insert into table with GenerationType.IDENTITY

My environment:

Hibernate 1.0 JPA Netbeans 7.01 Sql server 2005

Part of code:

public class EdiAgendamentoCliente implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue (strategy = GenerationType.IDENTITY)
@Basic(optional = false)
@Column(name = "id_edi", unique = true, nullable = true)
private Integer idEdi;

Error:

"java.lang.IllegalArgumentException: id to load is required for loading"


Im trying to insert values into a table with auto increment, but its not working, can you guys give me some direction here?

将其更改为可为空的false,并检查数据库中的列名称是否与name属性匹配

@Column(name = "id_edi", unique = true, nullable = false)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM