2009年11月17日 星期二
2009年8月27日 星期四
HKID check digit calculation algorithm
The last digit of HK can be calculated with the first 1 or 2 english letters and following 6 numbers.
HK digit pattern
XX999999C / X999999C
XX/X - 1 or 2 English letters
999999 - 6 numeric characters
C - check digit, 0-9 or A
Use the following algorithm to calculate the check digit
1. Convert English letters to number, using the mapping
A->10, B->11, C->12 .... Z->35
2. Calculate the check sum
*For HKID with 2 English letters
check sum = char[1] * 9 + char[2] * 8 + char[2] * 8 + char[3] * 7 + char[4] * 6 + char[5] * 5 + char[6] * 4 + char[7] * 3 + char[8] * 2
*For HKID with only 1 English letters
check sum = 36 * 9 + char[2] * 8 + char[2] * 8 + char[3] * 7 + char[4] * 6 + char[5] * 5 + char[6] * 4 + char[7] * 3 + char[8] * 2
3. mooderate check sum by 11 and use 11 to minus the value
check digit = 11 - checksum mod 11
Below are samples of valid HKID
B123456(6)
A182361(5)
CA182361(1)
AB123456(9)
ZA182361(3)
AZ182361(6)
XZ182361(8)
ZX182361(6)
XX182361(2)
HK digit pattern
XX999999C / X999999C
XX/X - 1 or 2 English letters
999999 - 6 numeric characters
C - check digit, 0-9 or A
Use the following algorithm to calculate the check digit
1. Convert English letters to number, using the mapping
A->10, B->11, C->12 .... Z->35
2. Calculate the check sum
*For HKID with 2 English letters
check sum = char[1] * 9 + char[2] * 8 + char[2] * 8 + char[3] * 7 + char[4] * 6 + char[5] * 5 + char[6] * 4 + char[7] * 3 + char[8] * 2
*For HKID with only 1 English letters
check sum = 36 * 9 + char[2] * 8 + char[2] * 8 + char[3] * 7 + char[4] * 6 + char[5] * 5 + char[6] * 4 + char[7] * 3 + char[8] * 2
3. mooderate check sum by 11 and use 11 to minus the value
check digit = 11 - checksum mod 11
Below are samples of valid HKID
B123456(6)
A182361(5)
CA182361(1)
AB123456(9)
ZA182361(3)
AZ182361(6)
XZ182361(8)
ZX182361(6)
XX182361(2)
2009年5月15日 星期五
Difference between JPA and hibernate
JPA is really a specification. It does nothing without an implementation.
It's like architectural drawings for a house. I mean, you can't live in a house until someone builds one. Drawings are great, but you can't live in them.
Hibernate provides an implementation of the JPA specification. Vendors providing EJB3.0 containers will also be providing an implementation of the JPA spec, so that means Sun and IBM WebSphere and Oracle and all the other handsome players in the industry will provide an implementation. Those are the houses you can live in.
Hibernate is awesome, and it was awesome before the JPA spec came out, and it is even more awesome since it has been providing an implementaion of the JPA spec.
-Cameron McKenzie
Yes, it's true. The JPA is an API, a standardization effort from the java community. Hibernate authors heavily contributed at the creation of JPA. Hibernate is certified compliant with the Java Persistence API (with some limitations). However I prefer using plain Hibernate even if I don't respect the compliance mainly because Hibernate is in a continuous development and always benefits from the cutting edge technologies. It's better than waiting a few years for a java community meeting that will incorporate that in the specifications
[ July 09, 2008: Message edited by: Cristian Vrabie ]
Source
http://www.coderanch.com/t/218819/Object-Relational-Mapping/java/Hibernate-vs-JPA
It's like architectural drawings for a house. I mean, you can't live in a house until someone builds one. Drawings are great, but you can't live in them.
Hibernate provides an implementation of the JPA specification. Vendors providing EJB3.0 containers will also be providing an implementation of the JPA spec, so that means Sun and IBM WebSphere and Oracle and all the other handsome players in the industry will provide an implementation. Those are the houses you can live in.
Hibernate is awesome, and it was awesome before the JPA spec came out, and it is even more awesome since it has been providing an implementaion of the JPA spec.
-Cameron McKenzie
Yes, it's true. The JPA is an API, a standardization effort from the java community. Hibernate authors heavily contributed at the creation of JPA. Hibernate is certified compliant with the Java Persistence API (with some limitations). However I prefer using plain Hibernate even if I don't respect the compliance mainly because Hibernate is in a continuous development and always benefits from the cutting edge technologies. It's better than waiting a few years for a java community meeting that will incorporate that in the specifications
[ July 09, 2008: Message edited by: Cristian Vrabie ]
Source
http://www.coderanch.com/t/218819/Object-Relational-Mapping/java/Hibernate-vs-JPA
訂閱:
文章 (Atom)