Glassfish and Derby and PostgreSQL
In my last post I gave a link to instructions for setting up a PostgreSQL database connection pool in Glassfish. Those instructions had a note attached about a mismatch between sequence names generated by PostgreSQL and Glassfish for serial
You can completely ignore that note. If you simply use ...
@Id @GeneratedValue(strategy= GenerationType.AUTO)
… for your primary keys then everything works fine without having to do any database specific tricks.
The Java Persistence API is really nice in this respect. It hides database specifics from you so that you can simply model your application in Java objects. The last few weeks I have not seen ANY sql to generate tables or to do queries; TopLink Essentials, the JPA provider in Glassfish, nicely generates a schema for you when you deploy. You can always tune it when you go in production.
It is also really nice that you can leave all the database specific configuration in your Glassfish domain; my persistence.xml has a fixed JTA data source. On the iMac and PowerBook for development that data source is configured to use the built-in Derby database. But on the Linux test server the data source points to PostgreSQL.
Created
