Wednesday, November 10, 2010

Hibernate revisited

JDBC is old school and Object Relation Mapping is mainstream (and has been around for years). ORM tries to abstract tried-and-true SQL and provides objects. Theoretically you can just change from Oracle to SQLserver just by tweaking the config file and no more dealing with different SQL syntax. ORM usually means Hibernate. Anything other than Hibernate such as Toplink gets you nowhere. Java programmers today need to list Spring/Hibernate on their resume unless you run your own shop. I previously read about it and now I have some time to look into more detail... to get something simple running.

So people is not happy with the simple JDBC approach because there are some boilerplate code to open and close connections and don't like hardcoding query strings. They don't want to transfer columns into their own value objects and demands more object wrappers.

So how do your objects know about columns of your table? You provide the mapping! (1. in xml or 2. annotation)
You have to include many jars in your classpath to make it compile happily.

It comes with 2 flavors of querying: the Criteria, and HQL. To prevent a few lines of boilerplate code, you'll need to learn a new query language.

If logging is on, you will see what query, insert, update statements that it is doing. For insert, update statments it gives you lots of question marks! That's PreparedStatements in action. But there is no obvious way to see exactly what it is inserting or updating.

You know internally that it is a wrapper to JDBC and your goal is to make Hibernate crank out statements that you would use

directly in JDBC.

I fail to share the enthusiasm.... long learning curve to get something straight forward. There should be tools that generate all that mapping, POJOs for me, perhaps it would becomes useful. No one should be hacking XML or error-prone annotation by hand.

Thursday, November 4, 2010

Eco-friendly suggestions for Whole Foods

Whole Foods is definitely THE most successful grocery store around even items there are more expensive. Many people concern the evil aspects of genetically engineered food... even though they have consumed A LOT already.

Organic food is just one thing. If your local grocery store also sell organic food, is it going to be as big business as Whole Food? Probably not. It takes excellent decorations to attract customers... that really is an important factor of a successful business.

I like the eco-friendly theme in almost everything they have. The tables are made of bamboo, paper bags over plastic bags, and recycle bins everywhere.

But I saw also these enemies of environment: single-use chopsticks and individually wrapped utensils. Sure, individually wrapped utensils are cleaner, but I don't mind using those that are not individually wrapped... that amount of plastic wasted is huge.

Wooden single-use chopsticks used up a lot of woods... yes, there are some eco-friendlier options but they are not popular enough. Perhaps someone should made them in aluminum and you can toss them in same bin as cans? The world needs even more innovations to reduce garbage!

Here is one idea for Whole Food: reward-driven recycling.

Deposit recyclable items (cans, glass, etc) into vending machine... and rewards will be added to a smartcard for points... collect enough points to earn a discount.

Tuesday, November 2, 2010

Gaming New Era?

The Kinect is almost here. See News. I am sure it would be somewhat fun.

But it is also scary to me:
Using a 3-D camera, depth sensors and voice-recognition software, it recognizes your face, voice and gestures as you move around and talk, without requiring you to hold a controller or wear a headset.... It will even take a photo of you doing these things so you can post it on Facebook for everyone’s amusement.


A bit too powerful and intrusive.... SOMEBODY IS WATCHING ME. An evil programmer can spy on you if that game console connects to the internet.

Is it taking gaming to new era? or has it gone too far?

Emperor and Christianity

While browsing classics, I noted the great emperor Kangxi is a Christian and wrote a classic poem!

《基督死》

功成十字血成溪,百丈恩流分自西。
身列四衙半夜路,徒方三背兩番雞。
五千鞭撻寸膚裂,六尺懸垂二盜齊。
慘慟八垓驚九品,七言一畢萬靈啼。

For an excellent analysis, see here

Monday, November 1, 2010

Halloween... BOO!

The world needs reasons to party (and need to make some money to sell candies and partying items). It started as some All Saint Days and becomes a day of costume and trick-or-treating with a theme of horror. Great info here at wiki. Ah, the reason for wacky costumes is to camouflage yourself from actual evil spirits. In one old job, some co-workers full of mustache and beard give themselves a reason to wear a DRESS on Halloween.

Halloween also inspired many TWISTED minds filming twisted horror movies. Some colleagues sent some links of twisted videos to me. Though I am not too scared (no one actually got hack sawed apart) but I am sicked by twisted stuff conceived by some twisted minds.

About trick-or-treat... this is blackmail and parents encourage kids to do that? Ok ok it is... tradition. Let them dress up as something cute.

But I am not telling kids to actually eat candies from strangers.

Why isn't anyone thinking the "OtherWorld" on any day other than Halloween?

Look folks, there is positive and negative charge, ying and yang, matter and anti-matter, kickass programmers and dumbass programmers... good and evil.

World and Otherworld?