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
//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);
@Column(name="password", nullable=false) private String password; public String getPassword() { return password; } public void setPassword(String password) { this.password = password; }
<?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>