Wednesday, June 15, 2011

Use Sequence to generate Primary key in TopLink/EclipseLink (JPA)


TopLink/EclipseLink have an easy way of using database sequence to generate primary key of a table. Here is a snapshot of the JPA Entity class generated from existing database table by Netbeans

    @Basic(optional = false)
    @Column(name = "ID", nullable = false, precision = 22)
    private int id;

The lines in red indicate the code added manually after the JPA Entity class was created by Netbeans. The SEQUENCENAME_SEQ represents the name of the sequence object in the database. The OTHER_NAME is just an alias and this can be referred to by the GeneratedValue annotation. GeneratedValue tells the code to use database sequence as primary key. You may also add INCREMENT BY using allocationSize attribute to SequenceGenerator annotation.

For more advanced strategies check out :

Total Lunar Eclipse experience!

I always thought lunar eclipse was dark with the shadow of earth cast on moon but this one appears white in color




Thursday, June 02, 2011

Is Groupon down?

I am unable to get to the login page!


Wednesday, June 01, 2011

AT&T Website Error message

Amazing AT&T error message after the recent upgrade!