Help !!! How to save entity log in entity in Hibernate/JPA call back events like @PostPersist @PostRemove @PostUpdate

375 views
Skip to first unread message

Gp P

unread,
Mar 8, 2012, 10:35:56 PM3/8/12
to play-fr...@googlegroups.com
Hi Players ,

I have create and save and new entities when I am saving entity for purpose of aggregation , audit , and refreshing cache . I want to use JPA callback events because I am using curd module for admin part also for cleaner implementation rather than doing manually

  1. Hibernate : I tried but I get all kinds of hibernate exception ,as 
  2. Overriding entity _save method : If dont call save in overridden method entity doesn't , if call it goes into infinite loop
  3. Hibernate  temprory session : Tring to figure out
  4. Override Crud controller : Thinking of doing it .. which function to override ...perhaps save ? any examples
Guys , any help would be much appreciated!! , been up all night :-( , I hope I was able explain my problem 

Thanks 


On Thu, Mar 8, 2012 at 11:22 PM, Gp P <g...@gpism.com> wrote:
Hi List,

n way I save entity @PostPersist (all these hibernate callback event are pretty useless )


or by overriding _save()  method  , how to correctly overide _save() without it being recursive 

Please provide me a working solution ...on deadline :-(


Thanks 

On Thu, Mar 8, 2012 at 9:30 PM, Gp P <g...@gpism.com> wrote:
Hi ,

I am trying to save entity in @PostPersist and update cache when I am saving Entity


But its not working , as per hibernate "A callback method must not invoke EntityManager or Query methods!" "


I tried overiding the _save meathod but without calling this.save it doent work , if call it it goes into recurrive loop :-(

any better solution which works ?


@Entity
public class SiteMeta extends Model {
public String name, tagline , twitterId, facebookId , contactEmail, contactAddress ;
@OneToOne
public Company company;
public String toString() {
   return name  ;
}
@PostPersist
@PostRemove
@PostUpdate
public void refreshCache(){
Logger.info("Repoulating siteMeta  ,something changed"+company.name);
new CacheAccess().repoulateSiteMetaCache(company.name);
}
public void _sav(){ 
 Logger.info(" Repoulating the site navigation , Category changed ->> " + name); save();
 new CacheAccess().repoulateSiteMetaCache(company.name);

 }
}

--
B the Change



--
B the Change



--
B the Change

Gp P

unread,
Mar 9, 2012, 9:02:12 AM3/9/12
to play-fr...@googlegroups.com
anybody ?
--
B the Change

Gp P

unread,
Mar 10, 2012, 9:43:41 PM3/10/12
to play-fr...@googlegroups.com
any suggestions ?
--
B the Change
Reply all
Reply to author
Forward
0 new messages