Hi,
You shouldn't inject an adapter in the constructor, it's not in DI
container directly. Try to define only default constructor:
public PcExpressPosUUIDPkGenerator() {
super();
}
On Tue, Jan 28, 2020 at 4:28 AM Juan Manuel Diaz Lara
<[email protected]> wrote:
>
> 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
--
Best regards,
Nikita Timofeev