Я получаю следующее сообщение об ошибке при попытке сохранить объект с помощью Entitymanger в Derby БД: -Упорно Субъект в дерби БД Использование EntityManager дает java.sql.SQLIntegrityConstraintViolationException
Internal Exception: java.sql.SQLIntegrityConstraintViolationException: The statement was aborted because it would have caused a duplicate key value in a unique or primary key constraint or unique index identified by 'SQL150318192139760' defined on 'TESTSEARCHS '.
Error Code: 20000
Call: INSERT INTO TESTSEARCHS (SEARCHID) VALUES (?)
bind => [1 parameter bound]
Query: InsertObjectQuery([email protected])
Соответствующий код: -
public class TestA extends SuperA{
@OneToOne(cascade = CascadeType.ALL, fetch = FetchType.EAGER, orphanRemoval = true)
protected TestSearchs testSearchs;
........
}
класс Supera обеспечивает идентификатор для Testa
@Entity
@XmlTransient
@MappedSuperclass
@Inheritance(strategy = InheritanceType.JOINED)
public class SuperA{
@Id
private String id;
.........
}
и TestSearchs класс: -
public class TestSearchs {
@Id
@GeneratedValue
@XmlTransient
private long searchId;
@ElementCollection(targetClass = String.class,fetch = FetchType.EAGER)
protected List<String> testsearch=new ArrayList<String>();
.....
}
Я установил Id по телефону сеттер Теста, который уникален, и тогда я persit объект Testa, используя entityManager.Persit(), но следующее сообщение об ошибке occurs.Please Назови мне что делать не так?