密钥

时间:2015-04-22 14:38:01

标签: java jpa

我有一个简单的实体类MappingBean

@Entity
@Table(uniqueConstraints =@UniqueConstraint(columnNames = { "number" }))
public class MappingBean {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private int    mappingid;
private String number;
private String name;

...}

当我打电话

entityManager.merge(this.mapping);

在MappingBean实例上我有时会得到

2015-04-22 16:32:08,552 ERROR [org.hibernate.engine.jdbc.spi.SqlExceptionHelper] (default task-15) Duplicate entry '03054445441' for key 'number'
2015-04-22 16:32:08,568 ERROR [org.jboss.as.ejb3] (default task-15) javax.ejb.EJBTransactionRolledbackException: org.hibernate.exception.ConstraintViolationException: could not execute statement

导致此例外的原因是什么?

最好的问候。

爱德蒙

0 个答案:

没有答案