[hibernate-issues] [Hibernate-JIRA] Created: (HV-13) Bug on the Oracle dialect : empty String is authorized whereas the field is declared as not-null.

Fabien PERIE (JIRA) noreply at atlassian.com
Tue Apr 17 04:11:04 EDT 2007


Bug on the Oracle dialect : empty String is authorized whereas the field is declared as not-null.
-------------------------------------------------------------------------------------------------

                 Key: HV-13
                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HV-13
             Project: Hibernate Validator
          Issue Type: Bug
         Environment: Hibernate version :3.1.2
Hibernate dialect : org.hibernate.dialect.OracleDialect
Database : Oracle 10g

            Reporter: Fabien PERIE
            Priority: Minor


Hello,

The purpose of this example is to show a bug with the Oracle dialect.
I use Hibernate 3.1.2 !

I define a POJO in a mapping file :

<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping package="fr.modele">
	<class name="Person" table="PERS">

		<!-- Identifiant de la personne -->
		<id name="idPerson" type="string" unsaved-value="null">
			<column name="PERS_IDEN" sql-type="char(12)" not-null="true"/>
			<generator class="sequence">
				<param name="sequence">pers.pers_seq_iden</param>
			</generator>
		</id>

		<property name="name" column="PERS_NAME" not-null="true" />
		<property name="firstName" column="PERS_FIRSTNAME"/>

	</class>
</hibernate-mapping>


Detail Person Java object :

import fr.modele;
import java.io.Serializable;

public class Person implements Serializable {
	private String idPerson;
	private String name;
	private String firstName;

	/**
	 * Constructeur par défaut.
	 */
	public Person() {
	}


	public Serializable getId() {
		return idPerson;
	}
	
	public void setId(Serializable id) {
		this.idPerson = (String)id;
	}

	public String getIdPerson() {
		return idPerson;
	}
	
	public void setIdPerson(String idPerson) {
		this.idPerson = idPerson;
	}

	
	public String getName() {
		return name;
	}
	
	public void setName(String name) {
		this.name = name;
	}

	public String getFirstName() {
		return firstName;
	}
	
	public void setFirstName(String firstName) {
		this.firstName = firstName;
	}
}


If I try to save an objet which contains the following informations :
	* idPerson : 1
	* name : null
	* nickName : Jim

Hibernate 3 logically returns the error : « 
	fr.org.springframework.orm.hibernate3.HibernateSystemException: not-null property references a null or 
	transient value: fr.modele.Person.name; nested exception is org.hibernate.PropertyValueException: 
	not-null property references a null or transient value: fr.modele.Person.name ».

But, if I persist an object which has an empty String instead of null value in the name attribute, 
Hibernate 3 does not return an error. (!!!)

I think that the problem comes of the Oracle dialect object because Oracle does not make the difference between 
an empty String and a null value.

Thanks,
Fabien PERIE.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

       




More information about the hibernate-issues mailing list