| Hello
 I have two class
 
 @entity
 public class Ordine {
 
 private Set<MerceQuantita> merceQuantita = new HashSet<MerceQuantita>();
 
 @OneToMany(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST,CascadeType.MERGE},mappedBy="ordine")
 public Set<MerceQuantita> getMerceQuantita() {
 return merceQuantita;
 }
 
 public void addMerceQuantita(MerceQuantita mq){
 mq.setOrdine(this);
 this.merceQuantita.add(mq);
 }
 
 ...
 }
 
 
 @Entity
 public class MerceQuantita {
 
 private Ordine ordine;
 
 @ManyToOne(targetEntity = Ordine.class)
 @JoinColumn(name="ordine",nullable=false)
 public Ordine getOrdine() {
 return ordine;
 }
 
 ...
 }
 
 
 When I run this code
 
 Ordine ordine = new Ordine();
 MerceQuantita mq = new MerceQuantita();
 ordine.addMerceQuantita(mq);
 orc.create(ordine);
 
 It returns
 
 org.springframework.dao.InvalidDataAccessResourceUsageException: could not retrieve generated id after insert: [it.frmandel.springtest.api.model.MerceQuantita]; nested exception is org.hibernate.exception.SQLGrammarException: could not retrieve generated id after insert: [it.frmandel.springtest.api.model.MerceQuantita]
 Caused by: org.hibernate.exception.SQLGrammarException: could not retrieve generated id after insert: [it.frmandel.springtest.api.model.MerceQuantita]
 
 Do you know how to solve this problem?
 
 Thank You
 
 
 |