[SOLVED] Persistence with JDBC+Mysql restores ".0" for integers

Hi all,

I have been using OH2 + persistence with JDBC + mysql.

Since few days (update to 2.4 ?), integer values are restored from persistence with “.0” (for number items). For example, I used to restore “9” for 9AM, now it restores “9.0”.
As a consequence, the Selection module on the sitemap does not identify the value 9.0 as 9, and selection is not restored to its previous state.

Is there an extra parameter to avoid this ?

Thanks,

Rudy

Please post your number items.

Also this link may help.

No, but it is recommend to usemapDB for restoreOnStartup (First line)
And I can confirm that it doesn’t restore integers as floats.

Thank-you for your answer.

variables.items
Number prog_absent_retour_heure

jdbc.persist:
prog_absent_retour_heure : strategy = everyChange, everyHour, restoreOnStartup

default.sitemap:
Selection label=“Heure de retour [%s]” item=prog_absent_retour_heure mappings=[0=“0”, 1=“1”, 2=“2”, 3=“3”, 4=“4”, 5=“5”, 6=“6”, 7=“7”, 8=“8”, 9=“9”, 10=“10”, 11=“11”, 12=“12”, 13=“13”, 14=“14”, 15=“15”, 16=“16”, 17=“17”, 18=“18”, 19=“19”, 20=“20”, 21=“21”, 22=“22”, 23=“23”] visibility=[prog_absent==ON]

events.log when I change the selection after OH2 restart:
2019-01-05 18:22:01.927 [ome.event.ItemCommandEvent] - Item ‘prog_absent_retour_heure’ received command 9
2019-01-05 18:22:01.932 [vent.ItemStateChangedEvent] - prog_absent_retour_heure changed from 15.0 to 9

Thank-you for the suggestion, I think this issue is different.

Try changing the item like below.

Number prog_absent_retour_heure "[%d]"

The persistence service (I think) get’s info from the item not the sitemap so changing the item might help.

If this doen’t work, I would take the advice given above, use the recommended mapDB for restoreOnStartup.

I tried mapdb which seems to be the right way to restore, and it solved my problem.

Thanks both of you for your help!

Please tick the solution, thanks