Scheduling via Spring
Spring provides support for scheduling activities. One way to do it is using java's Timer class. I created a simple program to display random messages.publicclass MessageAgent {publicstaticfinal...
View ArticleWorking with Quartz and Spring
In an earlier post we saw how Spring allows us to get scheduling done using Java's Timer Implementation. The timer schedulers has one shortcoming- There is no way to specify the time of the day when...
View ArticleSQL inside Criteria
We earlier how a custom criterion could be created to handle special scenarios. However this may seem overkill if the condition can be easily expressed using native SQL. For Criteria allows us to add...
View ArticleScheduling with Annotations
In my previous post we saw how to achieve scheduling using Quartz API and Spring. The thing about Quartz is that it adds an additional dependency in your project.If you have a simple project and do not...
View ArticleCriteria and Inner joins
Few posts ago we saw HQL's extensive support for joins. I decided to check out Criteria's claims to the same. I decided to start out with Inner joins.Just to recollect:The SQL INNER JOIN clause tells...
View Articlenew ArrayList(????)
Writing code without using collections framework would be crazy. They are really cool part of java with a lot of nifty stuff. More importantly unlike arrays you do not have to worry about size...
View ArticleROOT.war
Deploying a web application in Tomcat involves placing the war file or the extracted folder in Tomcat's webapps folder. I created a very basic web application named simple and placed it in the webapps...
View ArticleAccessing the Request object outside Controllers
We have seen that when working with controllers, Springautomatically gives us access to the HttpServletRequest object. But what if we are in some utility class and would like to access the request ?...
View ArticleMy First JPA Application
Till date I have always worked with Hibernate's native API. All my projects involved the SessionFactory, Session and other Hibernate APIs. And it works great. So why should I be looking at JPA ?Fact is...
View ArticleMy First JPA Application - 2
In the previous post I created the project structure for my JPA application. Now to look deeper into the code. I decided to build a simple Pet-Owner relation. One owner can have multiple pets. The...
View ArticleMy First JPA Application - 3
In the last two posts we setup the code to run a simple JPA example. In this post I shall now test out the code. The code to execute is as below:publicclass Client {publicstaticvoid main(String[] args)...
View ArticleWorking with the Iterator
Before I start let me state that I am still to come across a valid scenario in actual application code where I could find this functionality useful.To test this I first created a simple Hibernate POJO:...
View Articlepersistence.xml
In previous post we have seen the persistence.xml file - the file provides all the configuration information needed to get JPA up and running. We also saw that the JPA standard is very particular of...
View ArticleFirst Look at JPA Annotations
In the previous posts we saw how to run a JPA application. I decided to have a look at the annotations we used in the previous examples. First the Owner class: @Entity()@Table(name =...
View Articlecriteria.setProjection()
In previous posts we have seen how to use the Criteria interface. We have also been using the setProjection method when needed to select properties or objects from the executed query.Consider the below...
View ArticleLearning web services
In the various programming environments supported by Java, I have found web-services to be the most difficult to penetrate (That and JNDI) . The thing is there are several web-service providers in the...
View ArticleSetting schema information
In all my posts on JPA I have used a PostgreSQL database. The database is composed of multiple schemas (Unlike PostgreSQL, MySQL database supports only a single schema). So we need to specify to our...
View ArticleCriteria and Aggregation
We saw aggregate functions with HQL. Criteria too has methods that provide for using aggregate functions. Consider the below code that simply fetches the count of all rows.Count publicstatic void...
View ArticleThe first CXF Service
In the previous post we saw how JAX-WS 's RI implementation could be used to build and interact with web services. I decided to work with one of the other implementations - Apache CXF. I decided to...
View ArticleThe first CXF Service - 2
In the previous post we created and deployed the Echo webservice. Now to test the same. For this I created a simple client.privatestatic User getUserInstance() { User user = new User(); user.setId(1L);...
View Article