Search This Blog

Tuesday, 28 February 2012

I don't want to share my bean

In the previous example we saw how to set bean properties via the configuration. We can inject any value (or reference) into any property of the bean using the configuration files. However this leads to the side effect that the same bean reference may end up as a property among multiple beans.

Loading the Configuration

In our previous posts we created an XML based configuration file that provided the Bean Factory information on the beans to be created. The XmlBeanFactory class takes a resource instance as a part of its constructor parameter.

Saturday, 25 February 2012

Making A Detached Object Persistent Again

Hibernate allows detached objects to be associated with a persistence context again.One way to achieve this is to use the update method of the session.

Thursday, 23 February 2012

Controlling the size of the Persistence cache

As we saw earlier the Persistence Cache holds a collection of loaded persistent objects. For every object that we load in Hibernate a separate copy (called a snapshot) is maintained within the persistence cache. This copy is used by Hibernate to mange dirty checks.(It is also used as a first level cache.) A downside to this phenomenon is that if we load a very huge object graph into the session there is a possibility that we might run into an OutOfMemoryException.

Tuesday, 21 February 2012

Write-Behind Technique In Hibernate

Calling session.save(entity) in the code does not cause an immediate SQL insert to be fired. Similarly  session.delete(entity) or session.update(entity) will not result immediately in the execution of the sql delete or update queries being fired.
When objects associated with the persistence context are modified, the changes are not immediately propagated to the database.