The problem is that when using repository to select an entity from database, hibernate does not create a new instance of the entity, but casts the selected object to the cor