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.