Hi, Your question is not related to Wicket. You better ask in Hibernate/Spring forums.
I'd remove "readOnly = true" from @Transactional. On Thu, Aug 27, 2015 at 3:12 AM, smoothe19 <[email protected]> wrote: > Having trouble getting my setTestValue method to persist my data in the db > .. > i do not see any exceptions but data is not hitting the database.. I am > using Hibernate and postgres db > > > @Transactional(propagation = Propagation.SUPPORTS, readOnly = true) > @Service > public class TestValueService implements ITestValueService > { > /** > * > */ > private static final long serialVersionUID = -1027211428586214287L; > > @Autowired > GenericDao genericDao; > > private static final Logger LOG = > Logger.getLogger(TestValueService.class); > private TestValue defaultValue; > > public TestValueService() > { > > } > > @Transactional(readOnly = false) > private void setTestValue(TestValue defaultValue){ > genericDao.makePersistent(defaultValue); > LOG.info("ballingss"); > } > /* > * Method to read the defaults csv file and store into the common table > */ > @Override > //@Transactional(readOnly = false) > public void readCSVFile(String fileLocation, Long clientJobId){ > String csvFile = fileLocation; > BufferedReader br = null; > String line = ""; > String cvsSplitBy = ","; > > try { > br = new BufferedReader(new FileReader(csvFile)); > while ((line = br.readLine()) != null) { > > // use comma as separator > String[] currentLine = line.split(cvsSplitBy); > > > TestValue defaultValue = new TestValue(); > Date date = new Date(); > defaultValue.setClient_job_id(clientJobId); > defaultValue.setCreate_dt(date); > defaultValue.setActive(true); > defaultValue.setDef_keyfield(currentLine[0].toUpperCase()); > defaultValue.setDef_value(currentLine[1].toUpperCase()); > setTestValue(defaultValue); > > } > > } catch (FileNotFoundException e) { > LOG.error("File Not found "); > } catch (IOException e) { > e.printStackTrace(); > } finally { > if (br != null) { > try { > br.close(); > } catch (IOException e) { > e.printStackTrace(); > } > } > } > > } > > > > > } > > > here is the table object: > > @Entity > @Table(name = "TEST_VALUE") > public class TestValue implements Serializable { > private static final long serialVersionUID = 1L; > > @Id > @GeneratedValue(strategy = GenerationType.AUTO, generator = > "default_values_def_id_seq") > @SequenceGenerator(name = "default_values_def_id_seq", sequenceName = > "default_values_def_id_seq") > private Long def_id; > > private Long client_job_id; > > @Temporal(TemporalType.TIMESTAMP) > private Date create_dt; > > @Basic > private String def_keyfield; > > @Basic > private String def_value; > > @Basic > boolean active = false; > > public Long getDef_id() > { > return def_id; > } > > public void setDef_id(Long def_id) > { > this.def_id = def_id; > } > > public Long getClient_job_id() > { > return client_job_id; > } > > public void setClient_job_id(Long client_job_id) > { > this.client_job_id = client_job_id; > } > > public Date getCreate_dt() > { > return create_dt; > } > > public void setCreate_dt(Date create_dt) > { > this.create_dt = create_dt; > } > > public String getDef_keyfield() > { > return def_keyfield; > } > > public void setDef_keyfield(String def_keyfield) > { > this.def_keyfield = def_keyfield; > } > > public String getDef_value() > { > return def_value; > } > > public void setDef_value(String def_value) > { > this.def_value = def_value; > } > > public boolean isActive() > { > return active; > } > > public void setActive(boolean active) > { > this.active = active; > } > > public static long getSerialversionuid() > { > return serialVersionUID; > } > > > > } > > > -- > View this message in context: > http://apache-wicket.1842946.n4.nabble.com/Inserting-Persisting-data-into-the-DB-tp4671856.html > Sent from the Users forum mailing list archive at Nabble.com. > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [email protected] > For additional commands, e-mail: [email protected] > >
