java - UniqueConstrait on a table not working in Hibernate -
hibernate verstion 3.x
below table structure,
firstname | lastname | salary ----------------------------------- firstname | lastname | 100 firstname | lastname | 500 firstname | lastname | 1000
below java code,
@entity @table(name="table_name",schema="schemaname", uniqueconstraints={@uniqueconstraint(columnnames={"firstname","lastname"})})
though have mentioned unique constraint on tuples 'firstname' , 'lastname', still able add rows same firstname , lastname values.
i thought, hibernateexception
or otherwise , won't allowed add same firstname , lastname values multiple rows. don't have unique constraint created @ database level. there in code.
why able add duplicate rows? or understanding of unique constraint wrong?
have read javadoc?
it hint include unique constraint in generated ddl. not @ runtime. need create constraint @ database level.
Comments
Post a Comment