Hi,
I'm trying to upgrade from 1.0.2 to 2.0.2. When I save an object(using postgresql), I get:
java.lang.NullPointerException at com.avaje.ebean.server.deploy.id.IdBinderSimple.convertSetId(IdBinderSimple.java:91) at com.avaje.ebean.server.deploy.BeanDescriptor.convertSetId(BeanDescriptor.java:1120) at com.avaje.ebean.server.persist.DefaultPersister.setIdGenValue(DefaultPersister.java:708) at com.avaje.ebean.server.persist.DefaultPersister.insert(DefaultPersister.java:255) at com.avaje.ebean.server.persist.DefaultPersister.saveVanilla(DefaultPersister.java:235) at com.avaje.ebean.server.persist.DefaultPersister.save(DefaultPersister.java:211) at com.avaje.ebean.server.persist.DefaultPersister.saveRecurse(DefaultPersister.java:176) at com.avaje.ebean.server.persist.DefaultPersister.save(DefaultPersister.java:161) at com.avaje.ebean.server.core.DefaultServer.save(DefaultServer.java:1147) at com.avaje.ebean.server.core.DefaultServer.save(DefaultServer.java:1137) at com.avaje.ebean.Ebean.save(Ebean.java:520) at ...
Yes, this is a postgres specific bug.
1. The IdType is GENERATOR and should be SEQUENCE - for Postgres83Platform.getDbIdentity().getIdType()
2. Also note with postgres the ebean.columnAliasPrefix has to be "as c" rather than "c" ... as postgres needs the "as" keyword for column alias'.
In ebean.properties you need to have:ebean.columnAliasPrefix=as c
Workaround:
If you are initialising programmatically you can do:
// as alternative to putting this in ebean.properties GlobalProperties.put("ebean.columnAliasPrefix", "as c"); // set the IdType to SEQUENCE Postgres83Platform pg = new Postgres83Platform(); pg.getDbIdentity().setIdType(IdType.SEQUENCE); ServerConfig c = new ServerConfig(); c.setName("pgtest"); c.loadFromProperties(); c.setDatabasePlatform(pg); c.setDefaultServer(true); c.addClass(TOne.class); ... EbeanServerFactory.create(c);
You can't set the IdType via ebean.properties at the moment which is a bit of a shame.
I have fixed this in HEAD.
I have uploaded a snapshot build with this fix included.This should be downloadable from sourceforge:
https://sourceforge.net/projects/ebeanorm/files/
at...
ebean/2.0.2/snapshot/ebean-2.0.2-postgresfix.jar
Re-organised the folders in sourceforge.
Uploaded the snapshot containing this postgres fix as:
ebean-2.0.2-snapshot-postgresfix.jar