Hi
in my pojo i have one object
@Column(name = "GRUPO", unique = true, nullable = false, length = 45)
public String getGrupo() {
return this.grupo;
}
then i have a DAO Class to save object in database like this
public void save(Gruposdeusuarios entity) {
EntityManagerHelper.log("saving Gruposdeusuarios instance", Level.INFO,
null);
EntityManagerHelper.beginTransaction();
try {
getEntityManager().persist(entity);
EntityManagerHelper.commit();
EntityManagerHelper.log("save successful", Level.INFO, null);
} catch (RuntimeException re) {
EntityManagerHelper.log("save failed", Level.SEVERE, re);
EntityManagerHelper.rollback();
throw re;
}
}
then i have AbstractAssembler to make a call from flex to dao
public void createItem(Object entity){
GruposdeusuariosDAO dao = new GruposdeusuariosDAO();
dao.save((Gruposdeusuarios) entity);
}
if i duplicate de object i get this exception
GRAVE: save failed
javax.persistence.RollbackException: Exception [TOPLINK-4002] (Oracle TopLink Essentials - 2.0.1 (Build b09d-fcs (12/06/2007))): oracle.toplink.essentials.exceptions.DatabaseException
Internal Exception: com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Duplicate entry 'ENELDO' for key 'GRUPO'
Error Code: 1062
Call: INSERT INTO mydaniel.gruposdeusuarios (GRUPO) VALUES (?)
bind => [ENELDO]
the question is
how i can catch the Error Code:1062 and Duplicate Key Name "GRUPO" to flex dataservice on fault to tell flex user it trying to duplicate value
i using Tomcat 6 , Livecycle Data Service 2.5, mysql-connector-java-5.1.8-bin, JPA Toplink and Flex Builder 3.3
Thank