datanucleus-rdbms
                                
                                 datanucleus-rdbms copied to clipboard
                                
                                    datanucleus-rdbms copied to clipboard
                            
                            
                            
                        Wrong identity type generated for type `long` with PostgreSQL
Bug Report
When using @PrimaryKey fields of type long like this:
@PrimaryKey
@Persistent(valueStrategy = IdGeneratorStrategy.NATIVE)
private long id;
with PostgreSQL, the column in the schema generated by DataNucleus will be of type SERIAL instead of BIGSERIAL.
SERIAL is equivalent to integer / int4, whereas BIGSERIAL would be the equivalent of biginteger / int8, see https://www.postgresql.org/docs/14/datatype-numeric.html
The BIGSERIAL type is correctly mapped to the JDBC Type BIGINT by DN
https://github.com/datanucleus/datanucleus-rdbms/blob/8b0f2651b6768a96482214f18b37ed8e7db530ef/docs/postgresql-13.5-jdbc-42.3.3.txt#L49-L69
However, the choice of SERIAL for autoincremented values is hardcoded, and independent of the type of the Java field:
https://github.com/datanucleus/datanucleus-rdbms/blob/8b0f2651b6768a96482214f18b37ed8e7db530ef/src/main/java/org/datanucleus/store/rdbms/adapter/PostgreSQLAdapter.java#L492-L500
I think DataNucleus should return BIGSERIAL or SERIAL depending on the Java field type or JDBC type of the column. Users who choose long over int for their ID column are expecting to need the increased value space, and the database schema should reflect this.