Tuesday, September 16, 2008

Wearing out the W-key

IntelliJ IDEA keeps track of some interesting statistics if you go to Help -> Productivity Guide.

Apparently in the last three months I have pressed Ctrl-W (select word) 9,598 times.

That seems like a lot!

Maybe I should re-map that key combination to something a little more ergonomically sound - or start using the right-Ctrl key.

Monday, September 15, 2008

IntelliJ *heart* Spring

Why hasn't there been more blogging about this? I only just realised today you can download JetBrains' IntelliJ 8.0 M1.

Using Spring WebFlow in my current project, I was almost at the point of giving up all the IntelliJ niceties and going back to Eclipse like my mindless drone-like co-workers (hehe sorry guys :)), simply because of IntelliJ 7.0's non-existent WebFlow support and otherwise generally dreadful Spring support.

I really thought JetBrains had given up on Spring, and left it all to Eclipse, since that what the SpringSource guys prefer. I suspect that most people involved in a Spring project have started with Eclipse, simply because of the better IDE support.

But all that has changed with version 8.0. It now has Spring 2.5 support (with both annotation and xml based configuration as well as autowiring), and nice webflow support too.

I just hope it hasn't come too late, and I am forced to adopt Eclipse because everyone else is using it now.

Thursday, September 11, 2008

Australian Credit Card processing fees: Paypal vs The Banks

A client of mine has an online store selling live aquarium fish that processes credit card payments over the Internet.

Currently, all credit card payments are being processed through Paypal. The Paypal system is pretty good - there is no requirement for customers to have a Paypal account, they can just enter their card details and Paypal will process the transaction and deposit the funds into my client's Paypal account.

Sales are starting to get to the volume where credit card fees are a significant amount. So it is time to shop around for a better deal.

The standard alternative to processing credit cards through Paypal is getting a merchant account from a bank, and also a third party gateway. You have to pay both of them fees.

Here are some numbers. This sort of information is very hard to find on the Internet, but I assume is fairly typical for anyone running a reasonably sized online store in Australia. So I hope you find it useful.


Total Other Monthly Fees % fee per transaction Fixed $ fee per transaction
Bank (with Bank gateway) 37.33 1 0.35
Bank with Third Party Gateway 9.33 1 0.36
Paypal
1.5 0.30


As you can see the total costs depend a lot on transaction volume and average transaction amount.

Monday, September 8, 2008

Why won't Hibernate load this collection?

Have you come across this problem? No matter what you do, despite everything looking correct, Hibernate refuses to load a child collection of a parent object when you really really think it should be loading it? Even when debugging, calls to getChildren() return null when you know for sure that there should be something there.

The likely scenario is that the parent/child relationship has not been modelled correctly in the persistence definitions.

Consider the Java Persistence API spec for an idea of how a typical parent-to-children relationship should be defined:

Example 1: One-to-Many association using generics

In Customer class:

@OneToMany(cascade=ALL, mappedBy="customer")
public Set getOrders() { return orders; }

In Order class:

@ManyToOne @JoinColumn(name="CUST_ID", nullable=false)
public Customer getCustomer() { return customer; }



There are two important things to check in your code from the example provided.

  1. "cascade=ALL" is set on the parent. If this is not set, then when you call save on the parent, the children will not be persisted - and usually you do want the children of a parent to be persisted.

  2. "nullable=false" is set on the child (or "optional=false" on the ManyToOne tag). This will ensure that when the child is created, the back-reference to the parent is persisted. If this is not set, then you will be able to create the hierarchy without any problems; but if you forget to explicitly set the parent in your Java code when creating the children you will encounter the problem described before - Hibernate just won't be able to load the children. Setting this element will guarantee that you cannot create the parent/child hierarchy in an invalid state, and will make the cause of any future problems obvious.

It's a good idea to use this snippet as a template when creating a One-to-Many (Parent with Children) relationship, and then you can tinker with the other definition elements as you require them.

Friday, September 5, 2008

Springsource talk was worth attending...

I went to the Spring User group meeting in Brisbane recently, and while the quick overview of Webflow 2.5 was interesting - the best part of the meeting was...

...when I won the lucky door prize!