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
Views
Replies
Total Likes
Hi
First me not Clear wether you are using HttpService/Remote Objects.
If you are using Remote Object Just go with the Following Link.
http://sujitreddyg.wordpress.com/2008/02/12/handling-java-exceptions-in-flex-application/
If the Case you are using HttpService then while Returning the Result append the Message in the Headers
for example return an xml like this
<result status="true" message="Exception Here" >
<item name="...........">
<item name="...........">
</result>
And everyTime check wether status is true or false if status=false then display the Message.
Views
Replies
Total Likes
Thanks for your response
i Not using HttpService or Remote Objects.i using DataService Component on flex conecting to java using LiveCycle Data Service with Adstracassamabler
Views
Replies
Total Likes