Hi,
you use a unidirectional one-to-many association on a foreign key,
which is an unusual case, and is not recommended
(see
http://docs.jboss.org/hibernate/core/3.3/reference/en/html/associations.html#assoc-unidirectional-12m section 7.2.3 ).
Your current mapping maps the foreign key on the schema with NOT NULL
Therefore before you persists a new role instance, it already must be assigned to a user.
Solution: try to user the not-null="true" property
Code:
<set name="roles" lazy="false" cascade="all">
<key column="user_id" not-null="true"/>
<one-to-many class="com.sample.Role"/>
</set>
Or better: switch to another type of mapping which use is not discouraged.