java - hibernate save and read from DB -


i new in java , use hibernate.

i added in code datapoints instances:

datapoint dp = new datapoint(); dp.setdataset(dataset); dp.setstation(station); 

i run dataset.getdatapointcount() function has count dp dataset id:

public int getdatapointcount()     {          criteria        crit = database.getsession().createcriteria(datapoint.class);          crit = crit.add(restrictions.eq("dataset", this));         crit.setprojection(projections.rowcount());          integer         result = (integer)crit.uniqueresult();          return result.intvalue();     } 

and got 0 datapoints. (when run finished see new datapoints in database).

i added

 database.getsession().flush();  

before getdatapointcount() function , realy return new number (1000 example)

but in end of runing datapoints didnt saved in database!

in addition, if write getdatapointcount() after filush() twice ,i got in first

time right answer(1000) , in second time no right answer (0)

can 1 me?

thanks in advance.

what value of flushmode using ?

a transaction not commited can reason data not saved db.

see hibernate flushmode doc


Comments

Popular posts from this blog

c# - SVN Error : "svnadmin: E205000: Too many arguments" -

c# - Copy ObservableCollection to another ObservableCollection -

All overlapping substrings matching a java regex -