Passivation and Activation of View Objects with Transient Attributes

Within passivation/activation cycle of application modules the framework passivates and activates view objects as well. Usually the framework saves information about VO’s state, current row, bind variables values and such. But not the data. The VO’s query is going to be re-executed and the data is going to be re-fetched after activation of the view object. In most cases the query execution is not performed during or right after the activation phase, but is deferred until the view object is really used. This behavior is quite logical. Let’s assume that our application consists of several pages representing data of different view objects. If we send requests to the server from the same page we are going to get VOs executed that are used on that page only. All other view objects, used on other pages, are going to be passivated and activated as well. But they are not going to be re-executed until we ask the framework to do that by navigating to the particular page. And that’s cool! It means that we don’t perform unnecessary query executions and we don’t waste our memory. But there are some cases when the framework performs VO’s query execution during the activation phase not bothering whether we really use the VO.

One of these cases is about using of transient VO’s attributes. The common recommendation is to not passivate such attributes. But sometimes transient attributes are used to store some custom data and passivation/activation mechanism is used as a convenient way to save this data and keep it alive. Be careful with this approach. If any values of transient attributes are passivated, then the framework will execute the query during the activation of the view object.

Let’s consider a sample application with two pages – Employees and Departments.

Screen Shot 2013-07-19 at 2.31.00 PM

We use read-only SQL-based view objects browsing data on both pages:

Screen Shot 2013-07-19 at 2.35.18 PM

Screen Shot 2013-07-19 at 2.36.18 PM

So all VO’s attributes are transient and we’re not going to passivate them. Application module pooling is disabled:

Screen Shot 2013-07-19 at 2.43.59 PM

Exploring the request sent from the Employees page with ODLA we can see the following:

Screen Shot 2013-07-18 at 6.55.10 PM

There is no any query execution within application module activation phase. The VEmployees query has been executed in prepare model phase as it was expected.

And now let us change the passivate parameter of one of the VDepartments attributes:

Screen Shot 2013-07-19 at 2.55.14 PM

I am going to start the application with the Departments page in order to get the VDepartments VO executed and after that navigate to the Employees page. Sending next requests from the Employees page (for example sorting the table) we are going to get the following picture:

Screen Shot 2013-07-18 at 6.32.44 PM

It is obvious that besides execution of VEmployees query the framework executes VDepartments as well. And VDepartments is executed during the activation of the application module. Do we really need that? We are wasting CPU resources for unnecessary query executions and wasting memory to store query collections of unused view objects. The framework demonstrates the same behavior for view objects that have any dynamic attributes and for master view objects with retain view link accessors set on. So, be aware of these features.

That’s it!
 

Related Whitepaper:

Functional Programming in Java: Harnessing the Power of Java 8 Lambda Expressions

Get ready to program in a whole new way!

Functional Programming in Java will help you quickly get on top of the new, essential Java 8 language features and the functional style that will change and improve your code. This short, targeted book will help you make the paradigm shift from the old imperative way to a less error-prone, more elegant, and concise coding style that’s also a breeze to parallelize. You’ll explore the syntax and semantics of lambda expressions, method and constructor references, and functional interfaces. You’ll design and write applications better using the new standards in Java 8 and the JDK.

Get it Now!  

One Response to "Passivation and Activation of View Objects with Transient Attributes"

  1. Renan says:

    Hello Eugene! Nice article.

    I have one question, how do you get de ODLA to looks like that? Like, every action the framework does and its execution time, can you tell me a step-by-step to how to reach that screen?

    Thanks in advance,

    Best regards,
    Renan.

Leave a Reply


two − = 1



Java Code Geeks and all content copyright © 2010-2014, Exelixis Media Ltd | Terms of Use
All trademarks and registered trademarks appearing on Java Code Geeks are the property of their respective owners.
Java is a trademark or registered trademark of Oracle Corporation in the United States and other countries.
Java Code Geeks is not connected to Oracle Corporation and is not sponsored by Oracle Corporation.

Sign up for our Newsletter

15,153 insiders are already enjoying weekly updates and complimentary whitepapers! Join them now to gain exclusive access to the latest news in the Java world, as well as insights about Android, Scala, Groovy and other related technologies.

As an extra bonus, by joining you will get our brand new e-books, published by Java Code Geeks and their JCG partners for your reading pleasure! Enter your info and stay on top of things,

  • Fresh trends
  • Cases and examples
  • Research and insights
  • Two complimentary e-books
Get tutored by the Geeks! JCG Academy is a fact... Join Now
Hello. Add your message here.