Friday, June 29, 2007

Yay to Tendulkar

Sachin became the first to score 15000 Cricket ODI runs. What a feast, yay! Now get us a World cup guys and transform yourself from History to History books.

Thursday, June 28, 2007

Stevie Wonder and Toplink

This was a funny dream happened about two weeks ago and I never had a chance to blog about it right away. I was thinking about a Toplink problem and slept when there was this dream of Stevie Wonder singing who in the middle morphed into Little Richard but continued with his song. And believe me I was enjoying it. I woke up early that day and I had the solution of the problem which I implemented before heading for a shower. Thanks Stevie!

Monday, June 25, 2007

The Indian Banking System

A news script from the TimesOfIndia on how a Bank in India sent the Muscle Men to recover money which resulted in a death of the loanee. Shouldn't the Government take tough actions against this bank and its' hired "recovery agents"?

Loanee dies in scuffle with bank agents
24 Jun, 2007 l 0223 hrs ISTlTIMES NEWS NETWORK

Write to Editor
HYDERABAD: Despite the Supreme Court ordering banks not to use strong-arm tactics to recover money from defaulters, a leading bank in the city did just that on Friday and sent its ‘recovery agents’ to a state government employee’s house to reclaim its dues. And within hours of the visit, the 42-year-old loanee breathed his last at a hospital in Ameerpet. The family alleged that he was beaten to death by the bank’s agents.

This comes barely four months after the Supreme Court pulled up commercial banks for employing ‘musclemen’ to recover loans.

On Saturday, the relatives of the victim staged a dharna with the body in front of the bank’s Begumpet branch and demanded compensation. According to family members, A Yadaiah, a resident of Kindi Basthi in Yapral and an electrician with the health department, took Rs 15,000 as personal loan from ICICI Bank a few months ago. He reportedly defaulted on his repayments, ignoring repeated reminders from the bank.

"The bank has outsourced its loan recovery jobs to Elite Financial Services based at Ameerpet," Punjagutta police inspector G Narsaiah told STOI. Yadaiah’s wife Sunanda told police that Elite’s agent Raju came to her house on Friday morning at around 9 am. By then, Yadaiah had left to his office at Koti. Raju even took a photograph of Yadaiah from Sunanda to identify him.

The apex court in its February order had said that banks had a right to recover dues, but they cannot use force. "You can’t send goondas to their (defaulters) house, there are ladies alone at home," the judge remarked, disposing of an appeal filed by ICICI Bank against an order passed by the Allahabad High Court rejecting its plea to quash the criminal cases registered by the UP government against the managing director and top officials for using criminal force against a loan defaulter.

The Supreme Court asked banks to stop the illegal practice forthwith. It asked them to deal with defaulters as per the procedure laid down in the law and the Reserve Bank of India guidelines.

But quite oblivious to this SC order, another executive reportedly went to Yadaiah’s house late in the afternoon and asked Sunanda to speak to her husband over the phone. "My husband asked me to arrange Rs 10,000 immediately to repay the loan. He told me that he was being beaten up by the recovery agents," she said. Even as Sunanda was making efforts to arrange the money, the recovery agent left the place. A little later, Sunanda got a call from a private hospital at Ameerpet stating that her husband had died due to injuries. Sunanda alleged that her husband was beaten to death by the recovery agents trying to make him cough up the loan amount. The agency, however, claimed that Yadaiah suffered convulsions and collapsed before their office.

Punjagutta inspector Narsaiah said they were waiting for the post-mortem report to ascertain the reasons behind the death of Yadaiah. Police, however, had registered a case against the agency for wrongful confinement and culpable homicide not amounting to murder based on a complaint.

Friday, June 22, 2007

What is a Pojo? Again?

Keep hearing this word? With numerous definitions already, here is one more: A Pojo is not just a javabean with getter/setter and isX() methods but can have other behaviors too, provided they only work on the attributes owned, associated or inherited by it. The definition extends to the anemic and rich domain modeling. Event handling in Toplink is an example of a rich domain model. The following is a Pojo even though DescriptorEvent and ClassDescriptor raises eyebrows but its fine as in ORM, the Domain object "is a" descriptor.


public class Domain {
protected String name;
public String getName () { return name; }
public void setName (String name) { this.name = name; }
// -- Richness for postBuild events..
public void addHandler (DescriptorEvent event) {
...
}
// -- More Richness for After Load...
public static void addOrder(ClassDescriptor desc) {
.....
}
}

Tuesday, June 19, 2007

Obscenity of another kind

Someone bought a $300M Super Jumbo Airbus-380 for a personal use. And we raise eyebrows for people driving Hummers?

Monday, June 18, 2007

Taj is not Sanjaya, So please sincerely vote

Taj Mahal is at the verge of not being included in the seven wonders of the world. So how can an icon of love for more than a billion people lose? Taj is not Sanjaya so please sincerely vote here : Vote for Taj

Wednesday, June 13, 2007

Safari on Windows crashes

I don't own a Mac but decided to give a shot with Safari on windows. Installed the beta version of Safari which crashed the first time I opened it. This is a snapshot of the two. Safari (at the back) still loading and Mozilla had it loaded in under two seconds. So, their claims that it is 1.6 times faster than Firefox I guess is doubtful too.

Tuesday, June 12, 2007

Ford rejects to coach Indian Cricket Team

Good work Ford! Good lesson to the knuckle heads sitting in BCCI. And why does this Indian Cricket team need a coach? They don't make use of it anyway? They only need less fatty food and fodder to feed their gigantic egos.

Saturday, June 09, 2007

To make your database work

In one of my blogs I had talked about the perils of matching the domain model with the data model and how to solve it using Toplink. In one of my weekend projects I also talked about Twitterizing your Sunbird. Sunbird uses a small footprint of its' data-model based on the open source, open standard SQLite. And its' database is stored in a sdb file. So lets marry Toplink with the SDB file. Yes you can do that and its fairly simple and straight forward. So if you have a small data model with fewer number of tables and you want to run on a small database like what is used by Sunbird then let Toplink handle it. The Toplink workbench has a feature to recreate the data model on a database based on it's descriptors. So be it any complex data model, it can be recreated on any other database. But hold on.. Is it that simple? SDB does not support any Foreign keys and two tables can not be joined by any such relationships. Except the primary key constraint, no other constraints can be created in SDB. Big problem huh? No. Toplink does not care because the constraints it bothers about should be present in its' Object graph and not necessarily on the database. Remember the small check-boxes in the workbench asking if you want to create it on a database? And here is where the real power of Toplink comes from. The other example would be to create foreign key constraints on a database View? Even though logically it behaves like a table but a view is nothing more than a select statement providing a limited view of a certain data set. In Toplink though a view can be imported as a table descriptor. So, even with a view we can create foreign key constraints which does not have to exist in the database and in this case not even allowed. You would also watch out for default sequencing. Many small size databases like SDB do not support Native Sequencing and this would need to be changed in Toplink if not supported. What a better way to make your application agnostic to your database?

Friday, June 08, 2007

Will Paris case affect Sanjay Datta's?

So the American law has proved that no one is above the law (with all the sympathies to Paris Hilton). We have to wait and see if this case affects the like of one against Sanjay Datt and Salman in the Indian court.

Should be smart, good looking and well educated

No I am not advertising anything for myself. I was going through some matrimonial websites to find the Indian grooms (not for me dammit!) and found this one as a common statement: What are you looking for? "The girl should be smart, good looking and well educated". The rest is usually stated in different ways but mostly obfuscated. The essence will be "To excel both in managing home and outside. And should be working. And should bring a huge dowry. And should be smarter than he is. And better looking than he is. And should listen to his instructions for the rest of his life. And he should be treated like a god etc etc etc...". May be they find this the only way to improve their own gene bank - Male chauvinist jerks. Not all of them though. There are some really good people out there who do not write themselves as being Executives in their matrimonial profiles. God knows how can one become an Executive with 5 years of work experience. May be some other blog on the resume pet peeves.

Wednesday, June 06, 2007

Could someone please find Kelsey's killer?

I don't want to know what the law of the land says but could someone please catch this killer and peel his skin off, hang him upside down and leave hungry hyenas on him? Don't you think the law needs something higher than the death penalty? These beast's head needs to be chopped off and the body thrown for dogs to feed on. It is not possible that someone does not know the guy on Target's camera. Please help the law enforcement, her family and the rest of the society.

Monday, June 04, 2007

So KGMU loses its name

The name of KGMU/KGMC - King George Medical University has been changed to CSMMU - Chhatrapati Shahuji Maharaj Medical University. With every name change comes a phase of adaptation. I meet friends with Mumbai connection who still call the Shivaji Terminus as VT (Victoria Terminus). With all the respect to Shri Chhatrapati Shahuji Maharaj whose contribution to the society should be recognized, it still raises question of how the institutes should be named. Are we losing our liberal mindset to still be offended by name King George? After all, this Prince of Wales had laid the foundation of this premier medical institute in Lucknow. Foreigner/Occupier indeed but the cause was good and shouldn't that be recognized too? It was okay to change Bombay to Mumbai or Madras to Chennai because those were their historic names. Or, naming a brand new University on Mahatma Gandhi or Chhatrapati Shahuji Maharaj. But places with strong historical bonds or someone's constructive contributions should also be recognized and so what if it was a Prince of Wales?

Saturday, June 02, 2007

To find what data has changed in the database?

The problem statement is to find out what data has changed in the database if a transaction is committed. I am helping one of my Customers to build a similar application. Before I jump to the solution let me babble a bit.
We do work on a core application and then new requirements pop up time and again which do not disturb the core process but threatens to affect it. Such requirements are called crosscutting concerns. In one of my old blogs I have cursed such requirements. Things like Logging, Auditing, Profiling etc which does not restrict itself to a single component but affects the entire application. The solution to these problems is the concept of Interceptors. The code need not be changed but new Interceptors are written which can be added/hooked to the "project" which can provide the wanted solution. The concept of Interceptors is not new. Like HTTP plugins (like NSAPI and Apache plugins) Or ServletFilters which are added to intercept the HTTP requests and add/change the default behavior of the web server. Or even more powerful like EJB3 Interceptors or AOP.

So coming back to the original problem: In terms of databases there are two broad categories:
1. To implement it as a database trigger
2. To let the O-R mapper do it for you

Even though they both work, Option(2) is more elegant. It also provides the portability to the application with all the other goodies which O-R mapper gives. In Oracle's Toplink, it can be implemented as a SessionEventListener. The oracle.toplink.sessions.SessionEventListener is an interface which provides all the predefined events which take place in the lifecycle of a Session. If you do not want to implement or have empty methods, your class can extend SessionEventAdapter which does the same thing. The SessionEventListener is then hooked to the Toplink project with its' Toplink session. Here is how you do it:


# Client.java

public class Client {
...

public Session getSession () {
TestProject tP = new TestProject ();
DatabaseSession session = tP.createDatabaseSession ();
MySessionEventListener mL = new MySessionEventListener ();
session.getEventManager ().addListener (mL);
return session;
}
}

# MySessionEventListener.java

public class MySessionEventListener implements SessionEventListener {
...
public void postCommitUnitOfWork (SessionEvent event) {
Session session = event.getSession ();
UnitOfWork uow = (UnitOfWork) session;
UnitOfWorkChangeSet uCS = uow.getCurrentChanges ();
if (uCS != null) {
Enumeration enums = uCS.getAllChangeSets ().elements ();
// -- Traverse through the elements of what has changed.
}
}
}

Thats all you need... Run the application and Toplink will make sure that all the attached listeners keep an eye on all the events and in this case all what has changed.

Happy Toplinking...