-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Parent/child Relationsship
PostPosted: Thu Jan 21, 2010 5:47 am 
Newbie

Joined: Wed Jan 06, 2010 6:45 pm
Posts: 3
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


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.