The Answer to Life, the Universe, and Everything

Thursday, November 30, 2006

Debian apt management

This is the latest package update tool. Unlike netselect-apt, it doesn't use ICMP! which is often blocked now by firewall..

# s...location
# d...release type
# f...file to examin
# e...the number of host try
apt-spy -s nl -d unstable -f ls-lR.gz -e 10

Debian Keymap

Simple solution to change the keymap on Debian GNU/Linux.
loadkeys /usr/share/keymaps/i386/qwerty/jp106.kmap.gz
cp /usr/share/keymaps/i386/qwerty/jp106.kmap.gz /etc/console/boottime.kmap.gz

Monday, November 13, 2006

HibernateException


package org.hibernate;

import org.hibernate.exception.NestableRuntimeException;

/**
* Any exception that occurs inside the persistence layer
* or JDBC driver. SQLExceptions are always wrapped
* by instances of JDBCException.
*
* @see JDBCException
* @author Gavin King
*/

public class HibernateException extends NestableRuntimeException {

public HibernateException(Throwable root) {
super(root);
}

public HibernateException(String string, Throwable root) {
super(string, root);
}

public HibernateException(String s) {
super(s);
}
}

Sunday, November 12, 2006

Hibernate - Composite key

For a table with a composite key, you may map multiple properties of the class as identifier properties. The <composite-id>element accepts <key-property> property mappings and <key-many-to-one> mappings as child elements.

<composite-id>
<key-property name="medicareNumber"/>
<key-property name="dependent"/>
</composite-id>

Monday, November 06, 2006

Regex

Small sample to replace the regular expression..
Using Core API
String body = "\n";
String out;
Pattern pattern = Pattern.compile("class=\".*?\"");
Matcher matcher = pattern.matcher(body);
out = matcher.replaceAll("");
System.out.println(out);


Using Jakarta ORO
String body = "\n";
String out;
Perl5Util util = new Perl5Util();
out = util.substitute("s/ class=\".*?\"//g", body);
System.out.println(out);