Friday, June 26, 2009

Remove from Hibernate Set

Suppose you have one-to-many bi-directional mapping between Category and Item.

public class Category {
Set items;
}

public class Item {
Category category;
}

To remove an item from Category, you need to do this

category.getItems.remove(item1);
delete(item1); // delete() is from Hibernate API

The first line takes out the relationship while the second one deletes it.

Wednesday, June 24, 2009

Use log4j in JSP

http://www.mobilefish.com/developer/log4j/log4j_quickguide_jsp.html

Use the following section in pom.xml to declare the dependency in maven
<dependency>
<groupId>taglibs</groupId>
<artifactId>log</artifactId>
<version>1.0</version>
</dependency>

Monday, June 22, 2009

Format date in Hibernate Mapping

<property name="birthday" type="date" formula="trunc(BIRTHDAY)">
<column length="20" name="BIRTHDAY"/>
</property>

Tuesday, June 9, 2009

Update jquery tablesorter cache

jquery table sorter caches the data. You need to update the cache after removing table rows. Otherwise, the removed rows will show up again. Here is how to update the cache.

$('#myTable').trigger("update");