[jboss-user] [Persistence, JBoss/CMP, Hibernate, Database] - Hibernate -> not-null property references a null or transien
sandrocchio_0.1
do-not-reply at jboss.com
Sun Mar 11 11:25:42 EDT 2007
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.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4026959#4026959
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4026959
More information about the jboss-user
mailing list