Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp
Hibernate version:3.1
Dear hibernate developers,
I'm using MyInsertEventListener to handle business logic validations and I need to retun an error message if the condition fails.(Or is there any way to show the error mesage in the client side?I'm using Ajax request to save the record) But onPreInsert method always returs boolean value. Do anyone have a solution for this ?
I've already registered the event in my cfg.xml file like this,
crm.cfg.xml
<event type="pre-insert">
<listener class="com.common.MyInsertEventListener"/>
</event>
MyInsertEventListener.java
public class MyInsertEventListener implements PreInsertEventListener{
public boolean onPreInsert(PreInsertEvent event)throws HibernateException
{
if(event.getEntity() instanceof Vor){
Vor lVor = (Vor)event.getEntity();
System.out.println("Begin date :"+lVor.getVorldatva());
System.out.println("Upto date :"+lVor.getVorldattm());
if(lVor.getVorldattm().before(lVor.getVorldatva())){
System.out.println("Begindatum > einddatum");
return true; //--->I need to return the error message
}
}
return false;
}
}
Thanks and regards,
Prasanth