What I have found is you have to add these attributes when you have the same column mapped multiple times on an entity.
I
think this is because Hibernate wants only one of these fields to actually "own" the column/mapping value. By setting the insertable=false, updateable=false attributes you're telling Hibernate to NOT change this particular column for this particular mapping.
In other words, when you have something like this:
Code:
@Column(name="CGES41")
private String cges41;
@ManyToOne
@JoinColumn(name="cges41", referencedColumnName="cods42")
private S42gruppiEvento gruppiEvento;
...then what happens if you change the 'gruppiEvento' object but don't change the value in the cges41 field? When it comes time to flush data to the database, how does Hibernate know which value to persist?
By setting the "insertable = false, updatable = false" attributes on the @JoinColumn mapping, then you're telling Hibernate that the field cges41 is what actually owns the column value. The 'gruppiEvento' object will be populated, but it doesn't control the cges41 column on this table. If you change the 'gruppiEvento' object you also need to ensure you update the cges41 field.
Of course, typically I would expect to see the exception "org.hibernate.MappingException: Repeated column in mapping..." in this sort of situation... So maybe there's something else in your entities that you aren't showing causing your exception.