Left Right Binary Tree

0 comments

This is useful for the implementation of storing a huge number of data (lets say it > 1000) which have the behavior of parent and child (like a binary tree). I remembered that in the Data Structure, our professor used to give a lecture about this left right binary tree. But, who care about the efficiency of data storage, when they're mere a student?

So, simply speaking, it goes like this. Imagine that the data is formed like a binary tree. Each node represent an item. Each node has left id and right id. Root has left id = 1. Root's left child has left id = 2. And so on. (consult the left right binary tree manual book for the id rule). The point is that the left right if will be useful for selecting childs or parents. When we'd like to select the child of a node, select node of which left id is > the node's left id and right id is < the node's right id. A node's parent is a node which has left id = itself's left id minus 1.

This will make the data query become efficient.

Peeking Into My Eclipse's Plugins

0 comments

Today I'll write about my Eclipse, the Eclipse I use in my computer, the plugins I have. There are so many, thousands of free plugins, made by a group of kind-hearted programmers :)

Among them, these are the one that I consider worth installing:

Hibernate - The Concurrency Issue

0 comments

Be careful when using session.lock(object, LockMode.UPGRADE);
The best practice is to check the object whether if it's already locked with
UPGRADE mode.
public void selectForUpdate(Object object) {
if (getSession().getCurrentLockMode(object) !=
LockMode.UPGRADE) {
getSession().refresh(object, LockMode.UPGRADE);
}
}
Because if an object is already locked, locking it again will release the
previous locking.