Search My Blog

Sunday, August 30, 2015

Not able to get a simple Spring web application working :(

I am not able to run the sample web application provided on the spring website. Feeling so depressed.

Monday, April 13, 2015

Sunday, April 12, 2015

Notes - Spring in Action 3ed.:Chapter 1

Aspects

What about logging run-time values in the knight class?
The example explains how aspects can be used for logging, without the knight class needing to know the existence of a minstrel. However, in more practical use, we would want to log run-time values, specific to the knight class. Can this be done using aspects, without the log statement being present in the knight class code?

Friday, April 10, 2015

interesting read on Stephen Colbourne and his work

An interview
http://java.dzone.com/articles/heroes-java-stephen-colebourne

About JSR-310 and why joda time wasnt imported directly into the JDK
http://blog.joda.org/2009/11/why-jsr-310-isn-joda-time_4941.html

Lazy Loading in Hibernate

Very detailed article about Hibernate lazy loading, with a brilliant fun fact at the end (esp. the quantum physics analogy :D)

https://howtoprogramwithjava.com/hibernate-eager-vs-lazy-fetch-type/

@Where and @SQLDelete in Hibernate

Soft Delete
Many times, you want to delete an entity from your database, but you still want to keep a record of it. In such cases, we use soft deletes, ie, we mark the object as deleted using a flag in the record, but we do not remove it form the DB. This is called a soft delete.

Problem
Now, for each query you write, you need to append 'where isDeleted=false', to work with any active records.

Hibernate solution
In order to get rid of this boilerplate, Hibernate provides an annotation at the class level.

@Where(clause = "isDeleted != true")
class EntityName

Using this annotation, any select query on that entity gets appended with the where clause - 'where isDeleted != true'

(A more detailed explanation can be found here - http://java.dzone.com/articles/hibernate-where-clause)

And, in order to implement the soft delete, we can annotate the class with @SQLDelete.

@SQLDelete(sql = "update entityname SET isDeleted = true where objectkey = ?")