java - add a new entity -One-To-Many relation -
i define following entities :baseentity
, magasin
, article
:
@entity(name = "magasin") @table(name = "magasin") public class magasin extends baseentity { private static final long serialversionuid = 1l; @basic @size(min=5, max=100, message="the name must between {min} , {max} characters") private string name; @onetomany(cascade=cascadetype.all, mappedby="magasin") @valid private set<article> article; public string getname() { return name; } public void setname(string name) { this.name = name; } public set<article> getarticle() { return article; } public void setarticle(set<article> article) { this.article = article; } } @entity(name="article") @table(name="article") public class article extends baseentity { private static final long serialversionuid = 1l; @manytoone private magasin magasin; @basic @size(min=5, max=100, message="the name must between {min} , {max} characters") private string name; @basic private float price; public magasin getmagasin() { return magasin; } public void setmagasin(magasin magasin) { this.magasin = magasin; } public string getname() { return name; } public void setname(string nom) { this.name = nom; } public float getprice() { return price; } public void setprice(float price) { this.price = price; } } @mappedsuperclass public class baseentity { @id @generatedvalue(strategy=generationtype.identity) private integer id; public void setid(integer id) { this.id = id; } public integer getid() { return id; } public boolean isnew() { return (this.id == null); }
i try add new entity bit didn't work .no new entity inserted .there no error .how can modify in order add new entity article ?
function genericdao
public t add(t entity) { system.out.println("start"); gethibernatetemplate().save(entity); system.out.println("end"); return entity; }
flex main
private function submitdata(event:event):void { var article_ajout=new article(); article_ajout.name=pop1.art_name.text; article_ajout.price=parsefloat(pop1.art_prix.text); article_ajout.magasin=magasin(imagasin.selecteditem); alert.show("test"); articleservice.add(article_ajout); removeme(event); }
Comments
Post a Comment