My DB is postgres, how can I contribute/replace de PostgresPkGenerator with my 
own implementation to genera UUID's as PK's:
public class PcExpressPosUUIDPkGenerator extends PostgresPkGenerator {
    public PcExpressPosUUIDPkGenerator(@Inject PostgresAdapter adapter) {
        super(adapter);
    }

    @Override
    public Object generatePk(DataNode arg0, DbAttribute attribute) throws 
Exception {
        if (    attribute.getType() == java.sql.Types.OTHER)
            return java.util.UUID.randomUUID();
        else if (attribute.getType() == java.sql.Types.VARCHAR)
            return java.util.UUID.randomUUID().toString();
        else 
            return super.generatePk(arg0, attribute);
    }
}
I tryied this in a new Module:

ServerModule.contributePkGenerators(binder).put(PostgresAdapter.class.getName(),
 PcExpressPosUUIDPkGenerator.class);
But when trying to create my first context get this error:
org.apache.cayenne.di.DIRuntimeException: DI container has no binding for key 
<BindingKey: org.apache.cayenne.dba.postgres.PostgresAdapter>

Atte. Juan Manuel Díaz Lara

Reply via email to