Archive for April, 2010

Hibernate: Single Table inheritance with annotation

Monday, April 26th, 2010
import javax.persistence.DiscriminatorColumn;
import javax.persistence.DiscriminatorValue;
import javax.persistence.Entity;
import javax.persistence.Inheritance;
import javax.persistence.Table;
import javax.persistence.InheritanceType;
import javax.persistence.DiscriminatorType;

import org.hibernate.annotations.ForceDiscriminator;
@Table(name ="principal")
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
@DiscriminatorColumn(name = "ctype", discriminatorType = DiscriminatorType.CHAR)
@ForceDiscriminator   //optional, useful in some occasions
public class Principal{

@ForceDiscriminator //optional, useful in some occasions
public class User extends Principal {

@ForceDiscriminator //optional, useful in some occasions
public class Group extends Principal {

Postgresql: Failed to start on Windows (used to work)

Sunday, April 25th, 2010

Somehow, my Postgresql 8.4.3 failed to start on windows. After some digging around, I found the following in the windows event log:

FATAL:  bogus data in lock file "": ""

Removing the file did the trick (it is located at the root folder of your database store)

jQuery: Test if jQuery is installed with typeof

Wednesday, April 14th, 2010

There is a corner case where you need to know if jQuery is running on your page. Let’s say, you are using the ajaxForm plugin and that one of the input is of type “file.” ajaxForm will embed the call in a iFrame and the jQuery will not be included in it. So, for the page (or page fragment) that will be the target of such a call, you need to test if jQuery is running before running the script.

if (typeof($) != "undefined"){

Unfortunately, ajaxForm does not support AJAX call in “text” only which would solve this problem.

CSS: Cross-Browser Gradient

Wednesday, April 14th, 2010
background: #999; /* for non-css3 browsers */

filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#cccccc', endColorstr='#000000'); /* for IE */
background: -webkit-gradient(linear, left top, left bottom, from(#ccc), to(#000)); /* for webkit browsers */
background: -moz-linear-gradient(top,  #ccc,  #000); /* for firefox 3.6+ */

Great simple tutorial about cross browser gradient

With RGBA for gradient

background: -webkit-gradient(
   left bottom,
   left top,
   color-stop(0, rgba(0,0,0,.5)),
   color-stop(.49, rgba(0,0,0,.5)),
   color-stop(.5, rgba(29,29,29,.5)),
   color-stop(1, rgba(59,49,49,.5)));

Java: Open CSV Parser

Monday, April 12th, 2010

Parsing CSV is not as simple at it seems. Not hard, but cumbersome.

Here is a simple Lib that does the job: Open CSV (download)

CSVReader reader = new CSVReader(new FileReader(ADDRESS_FILE));
String [] nextLine;
while ((nextLine = reader.readNext()) != null) {
	System.out.println("Name: [" + nextLine[0] + "]nAddress: [" + nextLine[1] + "]nEmail: [" + nextLine[2] + "]");

Photoshop: Top Tutorials (Icon, Effects, Filters, Tools, Tips)

Monday, April 12th, 2010


Learning Photoshop:

  1. [Video] 142 Understanding Adobe Photoshop – Quick Mask Mode
  2. [Video] 156 Understanding Adobe Photoshop – Blending Modes
  3. [Video] Patch and Heal Tools – Photoshop for Video
  4. [Video] Text Effects (Part 1/2) – Photoshop CS4 Advanced Tutorial HD (part 2/2)
  5. [Video] Photoshop – Photo Combination & Manipulation
  6. [Video] Changing Eye and Hair Color
  7. [Video] Beams of sun light from scratch – Photoshop Week 39

Hibernate: Annotation for join column custom column name

Sunday, April 4th, 2010
    @JoinColumn(name = "company_id")
    public Company getCompany() {
        return company;

Note that in this particular example, the @JoinColumn is optional since “company_id” is the hibernate default for getCompany

Java: Validation JSR303, Hibernate, JavaScript

Thursday, April 1st, 2010