Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9192093
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T20:50:30+00:00 2026-06-17T20:50:30+00:00

I tried running this statement in Postgres: insert into field (id, name) values (DEFAULT,

  • 0

I tried running this statement in Postgres:

insert into field (id, name) values (DEFAULT, 'Me')

and I got this error:

ERROR: null value in column "id" violates not-null constraint

I ended up having to manually set the id. The problem with that is when my app inserts a record I get a duplicate key error. I am building a java app using Play framework and ebean ORM. So the entire schema is generated automatically by ebean. In this case, what is the best practice for inserting a record manually into my db?

Edit:
Here is how I’m creating my Field class

@Entity
public class Field {
    @id
    public Long id;
    public String name;
}

Edit:
I checked the field_seq sequence and it looks like this:

CREATE SEQUENCE public.field_seq INCREMENT BY 1 MINVALUE 1 MAXVALUE 9223372036854775807 START 1 CACHE 1; 

Edit:
Here is the generated SQL in pgAdmin III:

CREATE TABLE field
(
  id bigint NOT NULL,
  created timestamp without time zone,
  modified timestamp without time zone,
  name character varying(255),
  enabled boolean,
  auto_set boolean,
  section character varying(17),
  input_type character varying(8),
  user_id bigint,
  CONSTRAINT pk_field PRIMARY KEY (id),
  CONSTRAINT fk_field_user_3 FOREIGN KEY (user_id)
      REFERENCES account (id) MATCH SIMPLE
      ON UPDATE NO ACTION ON DELETE NO ACTION,
  CONSTRAINT ck_field_input_type CHECK (input_type::text = ANY (ARRAY['TEXT'::character varying, 'TEXTAREA'::character varying]::text[])),
  CONSTRAINT ck_field_section CHECK (section::text = ANY (ARRAY['MAIN_CONTACT_INFO'::character varying, 'PARTICIPANT_INFO'::character varying]::text[]))
);

CREATE INDEX ix_field_user_3
  ON field
  USING btree
  (user_id);
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T20:50:31+00:00Added an answer on June 17, 2026 at 8:50 pm

    This works.

    insert into field (id, name) values (nextval('field_seq'), "Me");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I tried running the following statement: INSERT INTO VOUCHER (VOUCHER_NUMBER, BOOK_ID, DENOMINATION) SELECT (a.number,
I tried running a python script: print Hello, World! And I get this error:
Error I tried this page to run on local, it is running perfectly fine
Eclipse was running fine last night, but this morning I tried starting it up
I've tried running the debugger in VS. I see the error list, but I
I am currently running this SQL SELECT jm_recipe.name, jm_recipe.slug FROM jm_recipe LEFT JOIN jm_category_recipe
I have the following insert statement which works fine on one system running SQL
I tried running the following query to restore a database: restore database myDatabase from
I tried running bundle install and it stopped on the json gem. So I
I tried running the following python code in Eclipse on Windows but it is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.