-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: PropertyValueException: not-null property on delete
PostPosted: Mon Oct 23, 2006 12:02 pm 
Beginner
Beginner

Joined: Thu Sep 22, 2005 10:48 am
Posts: 30
Location: Rio de Janeiro, Brazil
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>



App
Code:
      Categoria categoria = new Categoria();
      categoria.setId(Long.valueOf("50"));
      
      Session s = HibernateSessionFactory.getSession();
      
      Transaction tx = s.beginTransaction();
      s.delete(categoria);
      tx.commit();
      
      s.close();


Exception
Code:
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)


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.