-->
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: Collections invoking method in children before save
PostPosted: Wed Apr 17, 2013 2:47 pm 
Newbie

Joined: Wed Apr 17, 2013 2:31 pm
Posts: 1
Hi.
I'm implementing audit info in my VO object. Before save objects in database i call mathod setLastUpdateDate, and setUpdatedBy. I have a problem with children in collections. For example, my parent class.
Code:
public class Parent {
    private long id;
    private Set children;
    private Date lastUpdateDate;
    private User updatedBy;

    public long getId() { return id; }
    private void setId(long id) { this.id=id; }

    private Set getChildren() { return children; }
    private void setChildren(Set children) { this.children=children;

    private User getUpdatedBy() { return updatedBy; }
    private void setUpdatedBy(User updatedBy) { this.updatedBy=updatedBy; }
}

Children class:
Code:
public class Parent {
    private long id;
    private Date lastUpdateDate;
    private User updatedBy;

    public long getId() { return id; }
    private void setId(long id) { this.id=id; }

    private Date getLastUpdateDate() { return lastUpdateDate; }
    private void setLastUpdateDate(Date date) { this.lastUpdateDate=date; }

    private User getUpdatedBy() { return updatedBy; }
    private void setUpdatedBy(User updatedBy) { this.updatedBy=updatedBy; }
}

Before save Parent i call method setLastUpdateDate and setUpdatedBy. Is this possible to call also this 2 methods in children object VO? I want universal way of do this, because I have many VO objects, many diffrents collections in this objects and only one core class which is responsible for save objects and update audit info. Is there any adnotation to set a call method in collection before save them in database or any different solution?


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.