I have a table like below
create TABLE google_co2_emission_data (
departure text NOT NULL,
arrival text NOT NULL,
);
alter table google_co2_emission_data
add column co2_data_id bigint generated always as identity primary key;
Is there a way I can use the all-argument constructor for the generated POJO like below?
new GoogleCo2EmissionData("abc", "def", ??)`
Database - Postgres 14.4
I understand you'd like to avoid passing any argument value to that parameter, but Java doesn't have named / defaulted parameters, so there's no way to omit that value in your constructor call. Just pass null
instead, or use the default constructor and the setters for those columns that you do care about.
new GoogleCo2EmissionData("abc", "def", null);
var pojo = new GoogleCo2EmissionData();
pojo.setDeparture("abc");
pojo.setArrival("def");