Hibernate 3 – Inheritance Strategies

Abstract : The objectives for the Hibernate 3 Inheritance Strategies basically are : . Understanding the different strategies . Given a strategy detect if a given DB schema can be used . Understand how to map polymorphic associations

Table per concrete class

  • how to map a polymorphic association
  • the SQL generated if a polymorphic query is issued

Table per concrete class with UNION

  • your ability to detect if a given DB schema can be mapped using this strategy
  • mapping element to use : <union-subclass> and their allowed content
  • id strategy constraints
  • how to map a polymorphic association
  • what is the SQL generated if a polymorphic query is issued

Table per subclass with discriminator strategy

  • your ability to detect if a given DB schema can be mapped using this strategy
  • mapping elements to use : <discriminator/> <subclass/> <join/> <key/> and their allowed content
  • how to map a polymorphic association
  • what is the SQL generated if a polymorphic query is issued

Table per subclass strategy

  • your ability to detect if a given DB schema can be mapped using this strategy
  • mapping elements to use : <joined-subclass/> <key/> and their allowed content
  • how to map a polymorphic association
  • what is the SQL generated if a polymorphic query is issued

Table per class hierarchy strategy

  • your ability to detect if a given DB schema can be mapped using this strategy
  • mapping elements to use : <subclass/> <key/> and their allowed content
  • how to map a polymorphic association
  • what is the SQL generated if a polymorphic query is issued

For more visit : How Inheritance Work in Hibernate

Struts 2 Framework

In software development process no framework is excellent or best. Although a better approach to structuring all the components such as objects, resources and the most importation part is managing them over the time of development of application or even after the product is released. It seems a too much expectation with a virtual world ;) .

Struts 2 framework has almost all the capabilities to handle starting from a small application which can be opted as quick as possible and Also got strong based on which developers like us can created almost enterprise level applications. Stuts framework is based on MVC approach. I must share with .NET people that the ASP.NET MVC 3 not even near about Struts 2. I knew there are many .net lover’s in market as I was. But let me tell you struts 2 framework has much more capabilities than asp.net mvc.

The conclusion: I am not here to list you folks the advantages of struts over asp.net nor pit falls.

Struts 2 framework automate the common tasks and provides a platform for the users to build applications quickly. Struts 2 is based on the OpenSymphony Web Works Framework. Struts 2 framework implements the Model-View-Controller (MVC) design pattern. Struts 1.x was the first world class and very simple implementation of MVC pattern. Although As I said there is no framework which is the best or complete framework. Struts 1.x was too popular and adapted by various developer. And then the inventor of Struts framework come up with a new version of framework i.e. Struts 2.

Now, as I have already created so much virtual comment over Sturts 2. Let’s roll further and get in to basic terms about struts 2 framework based on Model View and Controller design pattern.

Note: For all those who have not worked with MVC design pattern. I would recommend that you should do the google for understanding the pattern.

Struts 2 framework basic component

In nutshell struts is based on mvc design pattern. And we will talk about Struts 2 framework with its basic component to keep in mind.

Basic component are Model, View and Controller so here with struts we call them as action, result and FilterDispatcher respectivly.

When any request is made by client’s browser it is sent to FilterDispatcher(Controller). And Here FilterDispatcher plays its role and deiced which Action to process this request. Now just for instance consider FilterDispatcher has processed and it has forwarded the request to a Valid Action. So, Here the game begins and once the action is executed, a return(response) from a action that is called as result. This generated result then sent back to client’s browser and this way the process completes. It is pretty simple 😉

Now here is some equation:
Model = Model contains the data and the business logic. In Struts 2 the model is implemented by the Action component.
Controller = FilterDispatcher
View = Struts 2 the view is commonly implemented using JSP, Velocity Template, Freemaker or some other presentation-layer technology.

FilterDispatcher process the request and do the following:
Struts 2, The framework creates an instance of this action and associate it with the newly created instance of the ActionInvocation.

  • Invocation of action have to pass through a series of interceptors as defined(Optional) in the application’s XML file
  • Each time the invoke() method is called, ActionInvocation consults its state and executes whichever interceptor comes next.
  • ActionInvocation hands control over to the interceptor in the stack by calling the interceptors intercept() method.
  • The intercept() method of the interceptor inturn calls the invoke() method of the ActionInvocation till all the interceptors are invoked, in the end the action itself will be called and the corresponding result will be returned back to the user.

Some interceptor do work before the action is executed and some do work after the action is executed. It’s not necessary that it should do something each time it is invoked.

  • These interceptors are invoke both before and after the action.
  • First all the interceptors are executed in the order they are defined in the stack.

Then the action is invoked and the result is generated.

Again all the interceptors present in the stack are invoked in the reverse order.

The other important features of Struts 2 are OGNL and ValueStack.

Object-Graph Navigation Language (OGNL) is a powerful expression language that is used to reference and manipulate data on the ValueStack.

OGNL help in data transfer and type conversion