Note: The original version of this post had a time-bomb in it. It would work as originally presented, but it could cause bizarre behavior if the pattern were used in a larger project. The original had an improper use of a java.util.List on line 11 of TreeNode.java (now it uses a java.util.Set). The issue is fully explained in my simple Hibernate list example.
Notice: This is provided with no warranty whatsoever. Use at your own risk.
This is the node class:
This is an example of how to use the persistent tree:
A wop bop a lu bob a womp bam boom. Tutti frutti ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop