Hibernate check not-null properties on delete, but
javadoc says:
Quote:
... a transient instance with an identifier associated ...
Hibernate version: 3.0.final
Mapping documents:
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="br.com.teste.model.Categoria" table="CATEGORIA">
<id name="id" type="java.lang.Long">
<column name="ID" precision="12" scale="0" />
<generator class="sequence">
<param name="sequence">SQ_CATEGORIA</param>
</generator>
</id>
<property name="nome" type="java.lang.String">
<column name="NOME" length="100" not-null="true" />
</property>
<set name="produtos" inverse="true">
<key column="CATEGORIA_ID" />
<one-to-many class="br.com.teste.model.Produto" />
</set>
</class>
</hibernate-mapping>
AppCode:
Categoria categoria = new Categoria();
categoria.setId(Long.valueOf("50"));
Session s = HibernateSessionFactory.getSession();
Transaction tx = s.beginTransaction();
s.delete(categoria);
tx.commit();
s.close();
ExceptionCode:
org.hibernate.PropertyValueException: not-null property references a null or transient value: br.com.teste.model.Categoria.nome
at org.hibernate.engine.Nullability.checkNullability(Nullability.java:72)