Why are changes in .shp type layers not saved. The edition is correct in PostGIS layer.

The ShapeInMem LayerModel is defined for demo purposes and does not write the changes to the shapefile. Instead you must use the Geotools layermodel if you want to write to the shapefile.

Writing to a shapefile is not encouraged anyhow, as a shapefile is a file based architecture and not optimized for performance over the internet. A good approach is to use the shape file format as an import/export format and to store your editable geo data in a PostGIS environment.