I 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 User with User Entity

```
@Entity
@Column(name="USER")
public class User{

private int id;

    @Id
    @GeneratedValue(strategy=GenerationType.IDENTITY)
    @Column(name="ID")
    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

@ManyToMany
@Cascade(org.hibernate.annotations.CascadeType.ALL)
@JoinTable(name="USER_CARS_JOINTABLE", 
                joinColumns=@JoinColumn(name="USER_ID"),
                inverseJoinColumns=@JoinColumn(name="CARS_ID"))
public Cars userCars;

//set and get methods omitted

}

```

Table CARS with Cars Entity

```
@Entity
   @Column(name="CARS")
   public class Cars{

    private int dateId;

    @Id
    @GeneratedValue(strategy=IDENTITY)
    @Column(name="DATE_ID")
    public int getDateId() {
        return dateId;
    }

    public void setDateId(int dateId) {
        this.dateId = dateId;
    }

   @ManyToMany
   @Cascade(org.hibernate.annotations.CascadeType.ALL)
   @JoinTable(name="USER_CARS_JOINTABLE", 
               joinColumns=@JoinColumn(name="CARS_ID"),
               inverseJoinColumns=@JoinColumn(name="USER_ID"))

   public User username;

   //set and get methods omitted

   }

```

As you can see I have a JoinTable "USER\_CARS\_JOINTABLE" between USER and CARS which contain FK on User and Cars tables.

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

```
@Entity
  @Column(name="DESCRIPTION")
  public class Description{

  private int id;

    @Id
    @GeneratedValue(strategy=IDENTITY)
    @Column(name="ID")
    public int getId() {
        return id;
    }
    public void setId(int id) {
        this.id = id;
    }

  private String color;
  private String size;
  private String speed;
  private String type;

  //set and get methods omitted

  }

```

My JoinTable USER\_CARS\_JOINTABLE is:

> 
> USER\_ID INT NOT NULL, CARS\_ID INT NOT NULL, DESCRIPTION\_ID INT NOT
>  NULL, PRIMARY KEY(INSTITUTION\_ID, DATE\_ID, SRC\_ID), CONSTRAINT
>  FK\_USER\_ID\_IN\_USER\_CARS FOREIGN KEY(USER\_ID) REFERENCES USER(ID),
>  CONSTRAINT FK\_CARS\_ID\_IN\_USER\_CARS FOREIGN KEY(CARS\_ID) REFERENCES
>  CARS(ID), CONSTRAINT FK\_DESCRIPTION\_ID\_IN\_USER\_CARS FOREIGN
>  KEY(DESCRIPTION\_ID) REFERENCES DESCRIPTION(ID)
> 
> 
> 

In my case User can have alot's of Cars and one type of Car can belong to number of Users. Also the same Car can have different Description.
Between class Description and User Entity and Cars Entity I will have an Undirectional, JoinTable, OneToMany relationships.That's mean that Classes User and Cars will know about Description class, but Description will not know about User and Cars. When I will try to enset data to my database from User side to class Cars and class Description I will have an exception like this:

> 
> Hibernate: insert into USER\_CARS\_JOINTABLE (User\_ID, Description)
>  values (?, ?) ERROR: org.hibernate.util.JDBCExceptionReporter - Field
>  'Cars\_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 USER\_CARS\_JOINTABLE (Cars\_ID, Description)
>  values (?, ?) ERROR: org.hibernate.util.JDBCExceptionReporter - Field
>  'User\_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 USER\_CARS\_JOINTABLE did not get an ID because I'm inserting it from side which is can not to generate or insert data to this jointable USER\_CARS\_JOINTABLE, I don't know why? 

If I will add to my JoinTable database schema for some of my foreign key like User\_ID or Cars\_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 USER\_CARS\_JOINTABLE the same value as in parient table User or Cars!!! Maybe I can use some of the @Generator annotation from Hibernate for my JoinTable in my Entity class.

Thank you.