-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Return value of PreInsert event
PostPosted: Tue Aug 21, 2007 4:12 am 
Newbie

Joined: Mon Jun 18, 2007 2:29 am
Posts: 16
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


Top
 Profile  
 
 Post subject: preInsert event
PostPosted: Tue Aug 21, 2007 5:28 am 
Newbie

Joined: Mon Jun 18, 2007 2:29 am
Posts: 16
It is working fine, if I am returning false, but shows some error if returning true. I need to return true as well as show an error message. What can I do ?

The error is..
org.hibernate.AssertionFailure : null identifier


Please help.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.