Please excuse me if you think the question shouldn't be on this forum
 
I have a situation where i am passing an java object from presentation layer
( JSF/Facelets) to business layer(Spring/Hibernate)
 
Here is the model
 
public Class A{
 public B b; //refers to other class B
}
 
I am implementing a business rule which states "an object A   reference
object B  value cannot be changed."

 

To enforce this rule, coding is done in the Business Layer method as
follows:

 

public void assertRule(A a)

        {            

 

// get the value of object B from object A from presentation Layer. Please
note it may  contain modified value of object B

            B b = a.getB(); 

            if(a.getId() != 0)

            {

                //load the persistent object A from database and then
retrieve the value for object B for comparision with the value passed from
presentation layer to check if its really changed

 

                A persistentA = xxxManager.getA(a.getId());

                B persistentB = persistentA.getB();

                if(!persistentB.getName().equals(b.getName()))

                {

                    throw new ServiceException("The object A   reference
object B value cannot be changed ");

                }

            }

            

        }

 

The problem with the  the above code snippet is 

 

    A persistentA = xxxManager.getA(a.getId());

 

 Loads the object from database , but it refers to the object passed from
presentation layer and hence i am unable to check if the value of object B
has really changed or not

 

Any pointers/suggestions will be greatly appreciated


-- 
View this message in context: 
http://www.nabble.com/Object-reference-%21%21%21-tp20310599p20310599.html
Sent from the MyFaces - Users mailing list archive at Nabble.com.

Reply via email to