Archive for March, 2010

Hibernate: annotations for PostgreSQL sequence id

Tuesday, March 30th, 2010
@Table(name = "mySchema.user")
@javax.persistence.SequenceGenerator(
    name="SEQ_STORE",
    allocationSize=1,
    sequenceName="mySchema.user_id_seq"
)
public class User {
....
    @Id
    @GeneratedValue(strategy=GenerationType.SEQUENCE, generator="SEQ_STORE")
    public Long getId() {
        return id;
    }
}

Flash: Scriptable Charts

Friday, March 26th, 2010

Hibernate: Database column name annotation

Wednesday, March 24th, 2010
@Column(name = "first_name")
public String getFirstName(){...

jQuery: Removing the jQueryUI dialog elements on close

Wednesday, March 24th, 2010

By default, $(..).dialog(“close”) or even $(..).dialog(“destroy”) leaves some html element in the DOM. Could be an issue when you expect to have it removed.

Here is a little trick

$("<div title='my transient dialog'>Some content</div>").dialog({
    close: function(event, ui){
                // Remove the dialog elements
                // Note: this will put the original div element in the dom
		$(this).dialog("destroy");
                // Remove the left over element (the original div element)
		$(this).remove();
	}
    });

Now, clicking on the close button or calling ‘close’ will remove the dialog elements completely

Apache: libpq.so.4 cannot open shared object file (postgres)

Wednesday, March 24th, 2010

After installing postgresql, you might have issues to start apache

Starting httpd: /usr/sbin/httpd:
error while loading shared libraries:
libpq.so.4: cannot open shared object file:
No such file or directory

One way to solve this issue, is to reinstall apache and apr-util.

#remove apache and apr-util
yum remove apr-util
#reinstall apache
yum install httpd

Source

Postgresql: Installing Postgresql on CentOS

Tuesday, March 23rd, 2010

Get the YUM repository

UPDATE for 9.x, Look this link: Installing Postgres 9.x with Yum

First check your latest version of the noarch.rpm at yum postgres repos

for CentOS 5, 64bit, Postgres 9.1

$ wget http://yum.pgrpms.org/9.1/redhat/rhel-5-x86_64/pgdg-centos91-9.1-4.noarch.rpm
$ rpm -ivh pgdg-centos91-9.1-4.noarch.rpm

Filter YUM postgresql

yum list | grep postgresql

If you see postgresql from other repositories besides pgdg84, then you need to exclude postgresql from coming from other repositories by following the below instructions excerpted from PostgreSQL How to Yum

  • As root, cd /etc/yum.repos.d
  • Edit distro’s .repo file:
    • On Fedora, edit fedora.repo and fedora-updates.repo, [fedora] sections
    • On CentOS, edit CentOS-Base.repo, [base] and [updates] sections.
    • On Red Hat, edit edit /etc/yum/pluginconf.d/rhnplugin.conf [main] section.

Add to the bottom of the section:

exclude=postgresql*

Yum Install

yum install postgresql-server

Init database

service postgresql initdb
# or
service postgresql-9.1 initdb

Make it autostart

chkconfig postgresql on

Create the first DBTest

su - postgres
createdb DBTest

SQL to DBTest

su - postgres
psql DBTest

All DB files are at

Root directory: /var/lib/pgsql/

Config file: /var/lib/pgsql/data/postgresql.conf

See also:

Jetty: Files locked on Windows

Sunday, March 14th, 2010

On Windows the Jetty buffers locks file. To fix that, set the following in the application servlet context xml or webdefault.xml.

<init-param>
  <param-name>useFileMappedBuffer</param-name>
  <param-value><strong>false</strong></param-value>
  <!-- default is true (you might want to keep it to true on your linux/production system) -->
</init-param>

Source

Google: Getting started with Java GData, OAuth, contacts, …

Friday, March 12th, 2010

GWT: Widgets, Drag and Drop

Monday, March 8th, 2010
  • Smart GWT (demo): Free/LGPL:  Seems to be mature and well maintained
  • GWT drag and drop: Free/Apache 2.0: Seems to be mature and well maintained
  • GWT EXT: Paid/Dual License: Complete and huge libs. Seems to be wrappers on top of ext

Javascript: Online JSON Formatter & Java JSON Serialization

Sunday, March 7th, 2010

Online Formatter

http://jsonformatter.curiousconcept.com/

Java JSON serialization

FlexJSON (nothing to do with Adobe Flex)