I’m trying to directly fetch the nextval form a postgres sequence using 
Cayenne, and am baffled but why I am getting nothing back.

I’m using SqlTemplate to build my query, since the modeler does;t seem to let 
me model a sequence DB object directly.

Code snippets:

1) using performQuery
SQLTemplate query = new SQLTemplate(EdiProfile.class,"select 
nextval('live.edi_control_number_sequence') as seqNum");
List response = ORMContext.performQuery(query);

2) using performGenericQuery

SQLTemplate query = new SQLTemplate(EdiProfile.class,"select 
nextval('live.edi_control_number_sequence') as seqNum");
QueryResponse response = ORMContext.performGenericQuery(query);

In both cases I am getting back null from the query.

Here’s what the log shows:

INFO: Detected and installed adapter: 
org.apache.cayenne.dba.postgres.PostgresAdapter
INFO: --- transaction started.
INFO: select nextval('live.edi_control_number_sequence') as seqNum
INFO: === returned 1 row. - took 10 ms.
INFO: +++ transaction committed.


And in fact if I go out and look in the postgres database, the sequence is 
getting hit and incremented.

Is this something that just won;t work with Cayenne (in which case I suppose 
I’ll have to fall back to using JDBC directly).

Thanks

Reply via email to