-->
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.  [ 1 post ] 
Author Message
 Post subject: Interceptors and logic
PostPosted: Fri Nov 24, 2006 8:53 am 
Beginner
Beginner

Joined: Mon Mar 06, 2006 2:19 pm
Posts: 42
Location: Belo Horizonte, Brazil
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version:1.2 BETA

Hi. Can I use interceptors to call methods of my entities. Somthing like:

Code:
class fooManager : IMyInterceptor
{

//attributes and properties

private void OnSave()
{
    if(foo.Parent == null)
        throw new Exception("foo must have a parent");

    foo.SomeDate = foo.Parent.OtherDate;
    ...
    ...
}


and use nHibernate interceptor:

Code:
public bool OnSave(object entity, object id, object[] state, string[] propertyNames, NHibernate.Type.IType[] types)
{
    //invoke object.OnSave()
}


So, I can do some logic every time I save an object.

Is this ok, a bad idea....?


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

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.