Import test and static data using Hibernate’s

Hibernate comes with a nifty feature that makes it unnecessary to use DBUnit or any tool for initializing your test database with data before the unit and integration tests are run. Ofcourse you need to be using Hibernate Core or its JPA module to take advantage of this. Steps to achieve this are very straightforward

1. Configure Hibernate’s property in the persistence.xml to one of the allowed values. e.g. The following configuration tells Hibernate to create the tables as per the given JPA/Hibernate mapping

<property name=”” value=”create”/>

2. Place additional tables/sequences/trigger creation scripts and the test data insert statements in a file with name import.sql and place it in the runtime class path. In case of eclipse, put it directly under build/classes.

3. Make sure the insert statement has no newline character

That’s it!!


Posted in yourmitra | Tagged , , | 1 Comment

Investing in Index funds – So boring but I will still do it

I came across the book “The bogleheads guide to investing” in the public library recently. I took it since the name Bogle sounded familiar and I had only 15 mins to choose a book before the library closes down for the day. I assumed it was written by John Bogle but it was not be so. It had three authors – all leaders of an online forum called bogleheads who are basically diehard fans of John C Bogle’s investment philosophy. I was sceptical but the book was quite ok. The opinions and advice of the authors had lots of common sense and some of them had really caught my attention and I really want to put them in practice even though my ego is still actually reluctant to follow them.

One of the points was to invest a bulk or all of your money in index funds – equity and/or bond. I am also a DIY investor who started a year ago, right at the peak of the Indian Bull Run. And I don’t have to say that I am not doing too well with my portfolio. It’s obvious isn’t it? But I don’t know if that’s attributable to the financial crisis that swamped the global markets since I started or it’s my poor stock selection. Anyhow!! Coming back to the topic of Index funds I know for sure that investing in these funds are the easiest and the most efficient, and perhaps most assured, way to long term wealth. It does not need much of your time – you don’t have to spend hours going through company’s financials, prospects for the sector, profiling the quality of the management etc. Basically you don’t have to do anything except for choosing an index fund with good track record and low expense. That’s it!! It’s as simple as that.

But the problem lies in this simplicity. Is it not too boring? Where is the challenge, where is the uncertainty, where is the thrill? Don’t we want to beat the market and those highly paid and fancied fund managers? Yes, we certainly want to do that and we can do that – that’s what our ego tells us. But if you really let your commonsense rule then you know for sure this is the way to go forward. So, reluctantly, I am going to look for an index fund that gave decent returns over 5 year period and has a low expense ratio and put in 50% or more of my money. Rest I will manage actively to feed my ego. I may do well or may not, I don’t know yet but what I know for sure is that the 50 odd % of my money in the index funds will do its job of compounding my wealth at decent percentage every year.

So, now let me focus on choosing an index fund!!

Posted originally at

Posted in Stock Markets | Tagged , | Leave a comment

An update on the Tata Nano!

This is a follow up to my last post where I was wondering about the status of Nano and the lack of media attention on it esp since there are no problems attached to it anymore.

I just came across this article on rediff where they mention that Nano will now roll out in the first quarter of 2009 and the exact date has not yet been decided. Nano seems to be undergoing road tests. You can read the news report here

Posted in Uncategorized | Tagged , , | Leave a comment

Whats with the Tata Nano project?

Have you heard anything on the Tata Nano project of late?  I did not. This project hogged the limelight till the time it moved to Gujarat, after which everyone seem to have forgotten about it. Of course, much larger happened in the mean time esp the Mumbai bomb blasts which, oddly,  seem to suggest that bad news follows Tata’s every where. But I think the Mumbai blasts and the Mamata’s senseless agitations actually helped Tata a household name within India as well as abroad which might help them in the long run ini saving costs to build up a brand.


Posted in Uncategorized | Tagged , , | 1 Comment

Eclipse hangs with a blank screen on start up

I ran into a problem where the Eclipse just hangs and shows a blank screen on start up. On analysis I found that its due to the perspective that its trying to open with. I could not find the problem thats causing this but I wanted to open the project and do some work on the java code base.

Since I cannot change the perspective from the eclipse workbench I looked around and found the file that can be edited to make eclipse open in the perspective you want.

It is workbench.xml file that will be under %workspace%\.metadata\.plugins\org.eclipse.ui.workbench folder. Search for perspectives element and modify it to open up in the perspective you want. For e.g. to open in java perspective you can use the following

<perspectives activePart=”org.eclipse.jdt.ui.PackageExplorer” activePerspective=”org.eclipse.jdt.ui.JavaPerspective”>

Posted in Technology | Tagged | 6 Comments

SAX based approach to build/create XML documents

If you dont want to build a xml document using StringBuffer or DOM then you can look at doing it with SAX. A  sample code that does this and passes the document to a byte array stream is as follows

SAXTransformerFactory factory = (SAXTransformerFactory) SAXTransformerFactory.newInstance();
TransformerHandler handler=factory.newTransformerHandler();
Transformer transformer = handler.getTransformer();

//set the stream
ByteArrayOutputStream bos = new ByteArrayOutputStream();
StreamResult streamResult = new StreamResult(bos);

String data = null;
AttributesImpl attr = new AttributesImpl();
handler.startElement(“”, “”, “Root”, null);
handler.startElement(“”, “”, “XXX”, null);
handler.startElement(“”, “”, “YYY”, null);
handler.characters(“Test Data”.toCharArray(), 0, 9);
handler.endElement(“”, “”, “YYY”);
handler.endElement(“”, “”, “XXX”);
handler.endElement(“”, “”, “Root”);
byte[] bytes= bos.toByteArray();

Using null in the startDocument and startElement methods for the namespace and localName params caused NullPointerException at org.apache.xalan.transformer.SerializerSwitcher.switchSerializerIfHTML( Thats the reason why empty strings have been used. I have not tested the code with other SAX parsers.

Posted in Technology | Tagged , | 1 Comment

Jboss Seam problem with Pages.xml – Does not recognize Page actions

I had a strange problem where Seam (used 2.1.0) did not recognize the page actions specified in the pages.xml which was placed under WEB-INF. I searched around and found no one had such a problem and of course the problem was finally in the way I was declaring the view id. View id needs to being with a forward slash and it needs .xhtml extension e.g. “/index.xhtml” – I did not use a forward slash while defining the view id that was the cause.

Posted in Technology | Tagged , | 1 Comment