Win a copy of Practice Tests for OCP Java 17 Certification Exam (1Z0-829) this week in the OCPJP forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Rob Spoor
  • Junilu Lacar
  • paul wheaton
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
  • Scott Selikoff
Bartenders:
  • Piet Souris
  • Jj Roberts
  • fred rosenberger

Hibernate, error org.hibernate.util.JDBCExceptionReporter Field 'Variable_ID' doesn't have a default

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
have problem with insert data from one side relationships to other tables and to other side of relationships at the same time

I have: Table Institution with Institution Entity




Table CREATIONDATE with CreationDate Entity


As you can see I have a JoinTable "INSTITUTION_DATE_CHILD" between INSTITUTION and CREATIONDATE which contain FK on User and Cars tables.

I also will have the table CHILD and Entity class the name Description:




My JoinTable INSTITUTION_DATE_CHILD is:

INSTITUTION_ID INT NOT NULL,
CREATIONDATE_ID INT NOT NULL,
CHILD_ID INT NOT NULL,
PRIMARY KEY(INSTITUTION_ID, DATE_ID, SRC_ID),
CONSTRAINT FK_INSTITUTION_ID_IN_USER_CARS FOREIGN KEY(INSTITUTION_ID) REFERENCES INSTITUTION(ID),
CONSTRAINT FK_CREATIONDATE_ID_IN_USER_CARS FOREIGN KEY(CREATIONDATE_ID) REFERENCES CREATIONDATE(ID),
CONSTRAINT FK_CHILD_ID_IN_USER_CARS FOREIGN KEY(CHILD_ID) REFERENCES CHILD(ID)


Hibernate: insert into INSTITUTION_DATE_CHILD (Institution_ID, Description) values (?, ?) ERROR: org.hibernate.util.JDBCExceptionReporter - Field 'Institution_ID' doesn't have a default value ERROR: org.hibernate.event.def.AbstractFlushingEventListe ner - Could not synchronize database state with session



If I will do this from Cars side I will have an error like this:

Hibernate: insert into INSTITUTION_DATE_CHILD (CREATIONDATE_ID, Description) values (?, ?) ERROR: org.hibernate.util.JDBCExceptionReporter - Field 'CREATIONDATE_ID' doesn't have a default value ERROR: org.hibernate.event.def.AbstractFlushingEventListe ner - Could not synchronize database state with session



That's meant that some of my foreign keys an JoinTable INSTITUTION_DATE_CHILD did not get an ID because I'm inserting it from side which is can not to generate or insert data to this jointable INSTITUTION_DATE_CHILD, I don't know why?

I have Institution and I have CreationDate table between them also ManyToMany biderectional jointable assosiations. Also I have aChild table, so between Institution <---> Child and CreationDate <---> NumberOfChild undirectional OneToMany relationships. Each Institution will have different number of Child in particular CreatiionDate. How can I extract this Child coressponding with my Institution name and partucular CreationDate. That why I decided to use one JoinTable for 3 other

If I will add to my JoinTable database schema for some of my foreign key like Institution_ID or CreationDate_ID the DEFAULT "number" than it is works, it's inser data, but it will always insert the same Number by DEFAULT which I put in "number". But What I want, is to give for one of my problem foreign key's in joinTable INSTITUTION_DATE_CHILD the same value as in parient table Institution or CreationDate!!! Maybe I can use some of the @Generator annotation from Hibernate for my JoinTable in my Entity class.

Thank you.
 
pie. tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic