0 Replies Latest reply on Mar 11, 2007 11:25 AM by Alessandro Ilardo

    Hibernate -> not-null property references a null or transien

    Alessandro Ilardo Newbie

      Hello there,
      I've started using Hibernate with EJB3, but I've got the following error:

      javax.ejb.EJBException: javax.persistence.PersistenceException: org.hibernate.PropertyValueException: not-null property references a null or transient value: eu.virtualLab.users.model.Usr.password


      I've followed many tutorials (and probably this is the real problem) and my code seems to be fine

      the facade bean:
      //add user to database
       logger.info("[addUsr] password value? -> "+password);
       Usr user = new Usr(username,password,_role,_name,surname,companyName,vat,
       address,city,postcode,country,email,phone,false);
       em.persist(user);


      The POJO
      @Column(name="password", nullable=false)
       private String password;
       public String getPassword() {
       return password;
       }
       public void setPassword(String password) {
       this.password = password;
       }


      The persistence.xml
      <?xml version="1.0" encoding="UTF-8"?>
      <persistence version="1.0" xmlns="http://java.sun.com/xml/ns/persistence"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd">
       <persistence-unit name="Users-EJBModulePU" transaction-type="RESOURCE_LOCAL">
       <!-- Jboss uses hibernate as default persistence engine
       <provider>org.hibernate.ejb.HibernatePersistence</provider> -->
       <jta-data-source>java:/MySqlDS</jta-data-source>
       <class>eu.virtualLab.users.model.Usr</class>
       <exclude-unlisted-classes>true</exclude-unlisted-classes>
       <properties>
       <property name="hibernate.dialect" value="org.hibernate.dialect.MySQL5Dialect"/>
       <!-- Show and print nice SQL on stdout -->
       <property name="hibernate.show_sql" value="true"/>
       <property name="hibernate.format_sql" value="true"/>
       <!-- Use it just in development -->
       <property name="hibernate.hbm2ddl.auto" value="create-drop"/>
       </properties>
       </persistence-unit>
      </persistence>

      The password parameter is not empty (it is showed by the logger), so where is my mistake?

      Thanks in advance.