Search This Blog

Tuesday, 29 January 2013

ServletContext and ServletConfig

With Spring MVC we have the Front Controller pattern at work. So there is the one Servlet - Spring's own DispatcherServlet which receives the requests and forwards them to the controllers in the code.
But what if you wanted to access the ServletContext ? Or (in some rare case) the Servlet Config ?
Could you get them in your controller?

Friday, 25 January 2013

Restrictions AND OR

I need to execute a query to fetch all entities with id is greater than 5 and the names start with "ent". That means there are two distinct conditions. Doing that using HQL would be pretty straightforward:

Monday, 21 January 2013

Applying Restrictions

In the previous post we saw how a Criterion was actually translated into an SQL query. In this post we shall use the different restrictions available. I started with the simple ones involving the equality operator.

Thursday, 17 January 2013

Creating a new Criterion

We have seen Hibernate's set of Restrictions and they cover a very large range of queries. However Hibernate also allows the creation of a custom Criterion that can be used in the criteria.

Sunday, 13 January 2013

Applying Restrictions - continued

In the last post we saw restrictions associated with equality and comparison.We can even use a single criterion instance to apply multiple equality conditions.

Wednesday, 9 January 2013

FactoryBean Interface in Spring

In our post on Velocity integration in Spring we saw an example of a FactoryBean. If we look at the configuration for velocity:

Sunday, 6 January 2013

Processing Template Text in Spring

In our previous post we saw Spring's ability to allow us to send mails. With mails comes up the requirement for mail templates. We want to dynamically generate our content using some template generation framework.
I decided to integrate Velocity via Spring for this purpose.

Wednesday, 2 January 2013

Emailing - the Spring way

I am yet to work in a project that did not involve any mail related functionality. Send notification mails to admin, send alerts to users, send password mails... the use cases for mails go on.
Spring has provided a utility class that wraps around the the javax.Mail library.
So we do not need to acquire any mail Sessions, create javax.mail.Transport objects or attempt to connect with the mail server.We simply get the wrapper class and call send.