2

I created an entity class that has the same properties as project.java, and created a class where I can persist the entity object. Also, I created a database using databases in Netbeans using embedded JDBC. I have the persistence.xml, which provides the properties to connect the db, and is used the persitence class on entitymanagerfactory object. The connection seems fine but I am having Internal Exception: java.sql.SQLIntegrityConstraintViolationException: Column 'PROJECT_ID' cannot accept a NULL value. error.

Is it ok to create the db manually (executing the ddl) or should I create the table in the persistence.xml using property name="javax.persistence.jdbc.url"" value="create-tables ?

Regards

Odiin
  • 150
  • 16
mussdroid
  • 732
  • 1
  • 9
  • 22
  • 3
    The exception tells you clearly you can't have the value as NULL.Either you should put checks in your code and make sure you insert non-NULL values [proper values of PROJECT_ID] or remove the constraint on the database based on your application requirement – RaceBase Mar 20 '14 at 09:23

1 Answers1

0

You have to set the value of the column PROJECT_ID.

You can either do this in your code, for example by using the annotations @SequenceGenerator or @GenericGenerator, or use db features (trigger) to set the id during insert.

user3335966
  • 2,673
  • 4
  • 30
  • 33
mursch
  • 1
  • 1