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 = ?")

Wednesday, September 4, 2013

HTTPS and why is it needed?

I never quite paid attention to why we need HTTPS connections. I knew it is a secure connection, but that's about it. I never thought why we need a secure connection, or why the normal HTTP connection was a problem in the first place.

Well, when someone has access to data you send over the network, he can read raw data and re-assemble the data which could be sensitive. Suppose you are on a wifi network, and someone on the same network uses a packet capturing software, he can easily see your data sent over the network. Same is the case with wired connections, but it is far more difficult to capture packets on a wired connection.

Now, suppose you are using a traditional HTTP connection, all your data is raw data. If you encrypt it using HTTPS, the eavesdropper can still capture your data, but it wont be of much use to him, since it is encrypted.

Hence, public wifi networks warn you before logging in to their networks, saying "this network does not use a secure connection, your data may be visible to others". These public networks do no generally have passwords, and hence, the warning.

Most websites today have HTTPS connections, like banking websites, and social networking sites. Check FB and BOA.

Other options include VPN, etc which I am not totally familiar with.