Saturday, February 10, 2007

Hyderabad Day 27 (Feb 10, 2007)

食啊食~





一路睇波一路食~



連蚊都一齊開餐... 好多蚊~~ 血啊~~


Hibernate + Derby

Stumbled across Derby today. A few years ago I used Cloudscape (now owned by IBM) for a toy project. Now with the open-source code maintained by Apache, I decided to try it out.

Downloaded and unpacked the Derby jar files. Then dug up a Hibernate "hello world" project that is on my hard disk. This project was created by following the Hibernate reference document. It is a simple program with HSQL as the database.

I made a copy of the project. Edited the Hibernate configuration file as follow:

<property name="connection.driver_class">
org.hsqldb.jdbcDriver
</property>
<property name="connection.url">
jdbc:hsqldb:hsql://localhost
</property>
<property name="connection.username">
sa
</property>
<property name="connection.password">
</property>
<property name="connection.driver_class">
org.apache.derby.jdbc.EmbeddedDriver
</property>
<property name="connection.url">
jdbc:derby:dbname;create=true
</property>

......

<property name="dialect">
org.hibernate.dialect.HSQLDialect
</property>
<property name="dialect">
org.hibernate.dialect.DerbyDialect
</property>

......

<property name="hbm2ddl.auto">
create
</property>

......



The text colored in red is to instruct Derby to create the database and for Hibernate to create the DDL. Only required for the first run. They can be commented thereafter.


Then went on to modify the class path to include the Derby jar file. And the Hibernate version that I have already has the Dialet for Derby. So no need to search around for the class.

Fired the program up. And without modifying any Java code, the whole program was now "ported" to another database. All it took was just about 15 minutes.

Sunday, February 4, 2007

Hyderabad Day 22 (Feb 5, 2007)

呢個禮拜冇咩特別。

星期四晚係 resident manager 果道食飯時,遇上兩個係 Dell 到做 trainer 既印度人,大家一路食一路吹水。 佢地其中一個係第二次黎 Hyderabad。 佢極力推介我 weekend 去 museum 到行下。個 museum 係 show 某有錢佬生前 collection,好似話係全世界最大既私人收藏。

不過今週末冇咩心情出去,或者下個禮拜喇。

星期五晚搵 resident manager 幫我叫左個 Domino's pizza。諗住叫個冇咁辣既,但係 d 好似洋蔥圈咁大條既紅椒絲一樣係鋪滿 pizza 面... orz。 十寸 mid-size,雞+番茄+etc,盛惠二百四十五盧比 (大概五十蚊港幣)。

係某 website 見到有個新書作者訪問。 本書叫 Dreaming in Code。個作者係訪問入面解釋 "why software is hard", "why even small-scale programming projects can take years to complete", "one programmer is often better than two" etc. 睇完個 interview 之後,除左覺得有 d 共鳴同想買本書黎睇之外,仲令我諗起另一本書。

另一本書都係同 software development 有關的 ,叫 The Mythical Man-month 。 本書係八十年代寫既,但係入面講既野到依家都冇 outdate。本書入面其中一句,係唔少地方見到有人 quote 過: "The bearing of a child takes nine months, no matter how many women are assigned" (無論你搵幾多個女人番黎,你點都要等九個月先會生到個仔出黎)。意思係話,有 d 野 (e.g. software development) 唔係話不停加人去做就以為可以快 d 完工的。呢本書我幾年前係 CU library 睇過幾個 chapters。依家突然好想搵番黎睇…… orz