java - Saving in a web application -


i have web application (using vaadin, hibernate, , postgres database) in users can add data table. when user adds item table asked enter name, date, , selected table related products. when click save able save name , date database having trouble grabbing items table , putting them set add. bean class table looks this:

/** created hibernate **/ public class beanclass implements serializable {     private string name;     private date date;     private set relatedproducts = new hashset(0);     .     .     .     } 

the code using save item user wants add is:

beanclass toadd = new beanclass(); set temp = null  /** there table user can select products want add  * when select item goes table, doing here * adding looping through latter table , adding items selected * set (supposedly think should work **/ (object item : table) {   temp.add(table.getcontainerproperty("id", item)); }  toadd.setname(namefield.getvalue()); //i have input fields name , date toadd.setdate(datefield.getvalue()); toadd.setrelatedproducts(temp);  hbsession.save(toadd); 

when user clicks save name , date added table, relatedproducts not added relationship table (in database). have looked cascade , inverse in hibernate , thinking have use these not quite understand how.

what datatype relatedproducts set? bean, have define onetomany annotation.

did debug if set filled before writing database?

you dont need iterate on whole table selected values. can items selected via table.getvalue()

getvalue()

gets selected item id or in multiselect mode set of selected ids.

if it's same datatype in table in bean, then

toadd.setrelatedproducts(table.getvalue()); 

should enough.


Comments

Popular posts from this blog

c++ - Creating new partition disk winapi -

Android Prevent Bluetooth Pairing Dialog -

php - joomla get content in onBeforeCompileHead function -