-->
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.  [ 2 posts ] 
Author Message
 Post subject: Restrictions.eq() Method Does Not Handle nulls properly?
PostPosted: Fri Jun 22, 2007 5:08 pm 
Beginner
Beginner

Joined: Tue Jun 07, 2005 8:24 am
Posts: 33
Location: Cincinnati, OH
I'm having a little trouble here. If I try to use Restrictions.eq() passing in null as the value, it returns 0 results. But, if I use Restrictions.isNull(), it returns 1 result (the property is null, btw). I know the work-around, but I was wondering if this is either a bug or just poor documentation? I don't see anything in the javadocs for the Restrictions.eq() method that says "if your value is null, use isNull() instead."

Hibernate version:

3.2.4.sp1

Entity Class:

Code:
public class StringPropertyEntity extends Entity
{
    private String property;
    private Long id;

    public Long getId()
    {
        return id;
    }

    private void setId(Long id)
    {
        this.id = id;
    }

    public String getProperty()
    {
        return property;
    }

    public void setProperty(String property)
    {
        this.property = property;
    }
}


Mapping document:

Code:
<hibernate-mapping package="com.carmanconsulting.hibernate.bug">
    <class name="StringPropertyEntity">
        <id name="id">
            <generator class="sequence"/>
        </id>
        <property name="property"/>
    </class>
</hibernate-mapping>


Code between sessionFactory.openSession() and session.close():

Code:
Transaction tx = s.beginTransaction();
StringPropertyEntity entity = new StringPropertyEntity();
s.save(entity);
tx.commit();
Collection c = s.createCriteria(StringPropertyEntity.class).add(Restrictions.eq("property",null)).list();
System.out.println("I found " + c.size() + " results using eq null");
c = s.createCriteria(StringPropertyEntity.class).add(Restrictions.isNull("property")).list();
System.out.println("I found " + c.size() + " results using isNull");


Name and version of the database you are using:

HSQL Database Engine, version: 1.8.0

The generated SQL (show_sql=true):

Hibernate: select next value for hibernate_sequence from dual_hibernate_sequence
Hibernate: insert into StringPropertyEntity (property, id) values (?, ?)
Hibernate: select this_.id as id0_0_, this_.property as property0_0_ from StringPropertyEntity this_ where this_.property=?
Hibernate: select this_.id as id0_0_, this_.property as property0_0_ from StringPropertyEntity this_ where this_.property is null

Debug level Hibernate log excerpt:

06-22@16:59:17 INFO (Environment) - Hibernate 3.2.4.sp1
06-22@16:59:17 INFO (Environment) - hibernate.properties not found
06-22@16:59:17 INFO (Environment) - Bytecode provider name : cglib
06-22@16:59:17 INFO (Environment) - using JDK 1.4 java.sql.Timestamp handling
06-22@16:59:17 INFO (Configuration) - configuring from resource: /hibernate.cfg.xml
06-22@16:59:17 INFO (Configuration) - Configuration resource: /hibernate.cfg.xml
06-22@16:59:17 DEBUG (DTDEntityResolver) - trying to resolve system-id [http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd]
06-22@16:59:17 DEBUG (DTDEntityResolver) - recognized hibernate namespace; attempting to resolve on classpath under org/hibernate/
06-22@16:59:17 DEBUG (DTDEntityResolver) - located [http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd] in classpath
06-22@16:59:17 DEBUG (Configuration) - connection.driver_class=org.hsqldb.jdbcDriver
06-22@16:59:17 DEBUG (Configuration) - connection.username=sa
06-22@16:59:17 DEBUG (Configuration) - connection.password=
06-22@16:59:17 DEBUG (Configuration) - connection.url=jdbc:hsqldb:mem://hibernate-bug
06-22@16:59:17 DEBUG (Configuration) - dialect=org.hibernate.dialect.HSQLDialect
06-22@16:59:17 DEBUG (Configuration) - hbm2ddl.auto=create-drop
06-22@16:59:17 DEBUG (Configuration) - show_sql=true
06-22@16:59:17 DEBUG (Configuration) - null<-org.dom4j.tree.DefaultAttribute@1d7fbfb [Attribute: name resource value "mapping.hbm.xml"]
06-22@16:59:17 INFO (Configuration) - Reading mappings from resource : mapping.hbm.xml
06-22@16:59:17 DEBUG (DTDEntityResolver) - trying to resolve system-id [http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd]
06-22@16:59:17 DEBUG (DTDEntityResolver) - recognized hibernate namespace; attempting to resolve on classpath under org/hibernate/
06-22@16:59:17 DEBUG (DTDEntityResolver) - located [http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd] in classpath
06-22@16:59:17 INFO (HbmBinder) - Mapping class: com.carmanconsulting.hibernate.bug.StringPropertyEntity -> StringPropertyEntity
06-22@16:59:17 DEBUG (HbmBinder) - Mapped property: id -> id
06-22@16:59:17 DEBUG (HbmBinder) - Mapped property: property -> property
06-22@16:59:17 INFO (Configuration) - Configured SessionFactory: null
06-22@16:59:17 DEBUG (Configuration) - properties: {hibernate.connection.password=, java.runtime.name=Java(TM) 2 Runtime Environment, Standard Edition, sun.boot.library.path=C:\java\jdks\jdk1.5.0_11\jre\bin, java.vm.version=1.5.0_11-b03, hibernate.connection.username=sa, java.vm.vendor=Sun Microsystems Inc., java.vendor.url=http://java.sun.com/, path.separator=;, java.vm.name=Java HotSpot(TM) Client VM, file.encoding.pkg=sun.io, idea.launcher.port=7536, user.country=US, sun.java.launcher=SUN_STANDARD, sun.os.patch.level=Service Pack 2, java.vm.specification.name=Java Virtual Machine Specification, user.dir=C:\Documents and Settings\jcarman\IdeaProjects\hibernate-bug, java.runtime.version=1.5.0_11-b03, java.awt.graphicsenv=sun.awt.Win32GraphicsEnvironment, hbm2ddl.auto=create-drop, java.endorsed.dirs=C:\java\jdks\jdk1.5.0_11\jre\lib\endorsed, os.arch=x86, java.io.tmpdir=C:\DOCUME~1\jcarman\LOCALS~1\Temp\, line.separator=
, java.vm.specification.vendor=Sun Microsystems Inc., user.variant=, os.name=Windows XP, sun.jnu.encoding=Cp1252, java.library.path=C:\java\jdks\jdk1.5.0_11\bin;.;C:\WINDOWS\system32;C:\WINDOWS;C:\java\jdks\j2sdk1.4.2_13\bin;C:\java\libraries\apache-ant-1.6.1\bin;c:\acero\secant\bin;C:\oracle\instantclient_10_2;c:\cygwin\bin;c:\java\libraries\maven-2.0.6\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\Program Files\IDM Computer Solutions\UltraEdit-32;C:\Program Files\ATI Technologies\ATI.ACE\;, java.specification.name=Java Platform API Specification, java.class.version=49.0, sun.management.compiler=HotSpot Client Compiler, os.version=5.1, connection.password=, user.home=C:\Documents and Settings\jcarman, user.timezone=America/New_York, connection.username=sa, java.awt.printerjob=sun.awt.windows.WPrinterJob, file.encoding=windows-1252, idea.launcher.bin.path=C:\Program Files\JetBrains\IntelliJ IDEA 7.0M1b\bin, java.specification.version=1.5, hibernate.connection.driver_class=org.hsqldb.jdbcDriver, show_sql=true, java.class.path=C:\Documents and Settings\jcarman\.IntelliJIdea70\config\plugins\testngrunner\lib\testngrunner.jar;C:\Documents and Settings\jcarman\.IntelliJIdea70\config\plugins\testngrunner\lib\testng-jdk15.jar;C:\java\jdks\jdk1.5.0_11\jre\lib\charsets.jar;C:\java\jdks\jdk1.5.0_11\jre\lib\deploy.jar;C:\java\jdks\jdk1.5.0_11\jre\lib\javaws.jar;C:\java\jdks\jdk1.5.0_11\jre\lib\jce.jar;C:\java\jdks\jdk1.5.0_11\jre\lib\jsse.jar;C:\java\jdks\jdk1.5.0_11\jre\lib\plugin.jar;C:\java\jdks\jdk1.5.0_11\jre\lib\rt.jar;C:\java\jdks\jdk1.5.0_11\jre\lib\ext\dnsns.jar;C:\java\jdks\jdk1.5.0_11\jre\lib\ext\localedata.jar;C:\java\jdks\jdk1.5.0_11\jre\lib\ext\sunjce_provider.jar;C:\java\jdks\jdk1.5.0_11\jre\lib\ext\sunpkcs11.jar;C:\Documents and Settings\jcarman\IdeaProjects\hibernate-bug\target\test-classes;C:\Documents and Settings\jcarman\IdeaProjects\hibernate-bug\target\classes;C:\Documents and Settings\jcarman\.m2\repository\asm\asm\1.5.3\asm-1.5.3.jar;C:\Documents and Settings\jcarman\.m2\repository\commons-collections\commons-collections\2.1.1\commons-collections-2.1.1.jar;C:\Documents and Settings\jcarman\.m2\repository\javax\transaction\jta\1.0.1B\jta-1.0.1B.jar;C:\Documents and Settings\jcarman\.m2\repository\commons-logging\commons-logging\1.0.4\commons-logging-1.0.4.jar;C:\Documents and Settings\jcarman\.m2\repository\org\hibernate\hibernate\3.2.4.sp1\hibernate-3.2.4.sp1.jar;C:\Documents and Settings\jcarman\.m2\repository\dom4j\dom4j\1.6.1\dom4j-1.6.1.jar;C:\Documents and Settings\jcarman\.m2\repository\cglib\cglib\2.1_3\cglib-2.1_3.jar;C:\Documents and Settings\jcarman\.m2\repository\asm\asm-attrs\1.5.3\asm-attrs-1.5.3.jar;C:\Documents and Settings\jcarman\.m2\repository\antlr\antlr\2.7.6\antlr-2.7.6.jar;C:\Documents and Settings\jcarman\.m2\repository\hsqldb\hsqldb\1.8.0.7\hsqldb-1.8.0.7.jar;C:\Documents and Settings\jcarman\.m2\repository\net\sf\ehcache\ehcache\1.2.3\ehcache-1.2.3.jar;C:\Documents and Settings\jcarman\.m2\repository\junit\junit\3.8.1\junit-3.8.1.jar;C:\Documents and Settings\jcarman\.m2\repository\org\testng\testng\5.5\testng-5.5-jdk15.jar;C:\Documents and Settings\jcarman\.m2\repository\log4j\log4j\1.2.14\log4j-1.2.14.jar;C:\Program Files\JetBrains\IntelliJ IDEA 7.0M1b\lib\idea_rt.jar, user.name=jcarman, hibernate.bytecode.use_reflection_optimizer=false, hibernate.show_sql=true, java.vm.specification.version=1.0, java.home=C:\java\jdks\jdk1.5.0_11\jre, sun.arch.data.model=32, hibernate.dialect=org.hibernate.dialect.HSQLDialect, hibernate.connection.url=jdbc:hsqldb:mem://hibernate-bug, user.language=en, java.specification.vendor=Sun Microsystems Inc., awt.toolkit=sun.awt.windows.WToolkit, java.vm.info=mixed mode, java.version=1.5.0_11, java.ext.dirs=C:\java\jdks\jdk1.5.0_11\jre\lib\ext, sun.boot.class.path=C:\java\jdks\jdk1.5.0_11\jre\lib\rt.jar;C:\java\jdks\jdk1.5.0_11\jre\lib\i18n.jar;C:\java\jdks\jdk1.5.0_11\jre\lib\sunrsasign.jar;C:\java\jdks\jdk1.5.0_11\jre\lib\jsse.jar;C:\java\jdks\jdk1.5.0_11\jre\lib\jce.jar;C:\java\jdks\jdk1.5.0_11\jre\lib\charsets.jar;C:\java\jdks\jdk1.5.0_11\jre\classes, java.vendor=Sun Microsystems Inc., connection.driver_class=org.hsqldb.jdbcDriver, file.separator=\, hibernate.hbm2ddl.auto=create-drop, java.vendor.url.bug=http://java.sun.com/cgi-bin/bugreport.cgi, sun.io.unicode.encoding=UnicodeLittle, sun.cpu.endian=little, sun.desktop=windows, connection.url=jdbc:hsqldb:mem://hibernate-bug, dialect=org.hibernate.dialect.HSQLDialect, sun.cpu.isalist=}
06-22@16:59:17 DEBUG (Configuration) - Preparing to build session factory with filters : {}
06-22@16:59:17 DEBUG (Configuration) - processing extends queue
06-22@16:59:17 DEBUG (Configuration) - processing collection mappings
06-22@16:59:17 DEBUG (Configuration) - processing native query and ResultSetMapping mappings
06-22@16:59:17 DEBUG (Configuration) - processing association property references
06-22@16:59:17 DEBUG (Configuration) - processing foreign key constraints
06-22@16:59:17 INFO (DriverManagerConnectionProvider) - Using Hibernate built-in connection pool (not for production use!)
06-22@16:59:17 INFO (DriverManagerConnectionProvider) - Hibernate connection pool size: 20
06-22@16:59:17 INFO (DriverManagerConnectionProvider) - autocommit mode: false
06-22@16:59:17 INFO (DriverManagerConnectionProvider) - using driver: org.hsqldb.jdbcDriver at URL: jdbc:hsqldb:mem://hibernate-bug
06-22@16:59:17 INFO (DriverManagerConnectionProvider) - connection properties: {user=sa, password=}
06-22@16:59:17 DEBUG (DriverManagerConnectionProvider) - total checked-out connections: 0
06-22@16:59:17 DEBUG (DriverManagerConnectionProvider) - opening new JDBC connection
06-22@16:59:18 DEBUG (DriverManagerConnectionProvider) - created connection to: jdbc:hsqldb:mem://hibernate-bug, Isolation Level: 2
06-22@16:59:18 INFO (SettingsFactory) - RDBMS: HSQL Database Engine, version: 1.8.0
06-22@16:59:18 INFO (SettingsFactory) - JDBC driver: HSQL Database Engine Driver, version: 1.8.0
06-22@16:59:18 DEBUG (DriverManagerConnectionProvider) - returning connection to pool, pool size: 1
06-22@16:59:18 INFO (Dialect) - Using dialect: org.hibernate.dialect.HSQLDialect
06-22@16:59:18 INFO (TransactionFactoryFactory) - Using default transaction strategy (direct JDBC transactions)
06-22@16:59:18 INFO (TransactionManagerLookupFactory) - No TransactionManagerLookup configured (in JTA environment, use of read-write or transactional second-level cache is not recommended)
06-22@16:59:18 INFO (SettingsFactory) - Automatic flush during beforeCompletion(): disabled
06-22@16:59:18 INFO (SettingsFactory) - Automatic session close at end of transaction: disabled
06-22@16:59:18 INFO (SettingsFactory) - JDBC batch size: 15
06-22@16:59:18 INFO (SettingsFactory) - JDBC batch updates for versioned data: disabled
06-22@16:59:18 INFO (SettingsFactory) - Scrollable result sets: enabled
06-22@16:59:18 DEBUG (SettingsFactory) - Wrap result sets: disabled
06-22@16:59:18 INFO (SettingsFactory) - JDBC3 getGeneratedKeys(): disabled
06-22@16:59:18 INFO (SettingsFactory) - Connection release mode: auto
06-22@16:59:18 INFO (SettingsFactory) - Default batch fetch size: 1
06-22@16:59:18 INFO (SettingsFactory) - Generate SQL with comments: disabled
06-22@16:59:18 INFO (SettingsFactory) - Order SQL updates by primary key: disabled
06-22@16:59:18 INFO (SettingsFactory) - Order SQL inserts for batching: disabled
06-22@16:59:18 INFO (SettingsFactory) - Query translator: org.hibernate.hql.ast.ASTQueryTranslatorFactory
06-22@16:59:18 INFO (ASTQueryTranslatorFactory) - Using ASTQueryTranslatorFactory
06-22@16:59:18 INFO (SettingsFactory) - Query language substitutions: {}
06-22@16:59:18 INFO (SettingsFactory) - JPA-QL strict compliance: disabled
06-22@16:59:18 INFO (SettingsFactory) - Second-level cache: enabled
06-22@16:59:18 INFO (SettingsFactory) - Query cache: disabled
06-22@16:59:18 INFO (SettingsFactory) - Cache provider: org.hibernate.cache.NoCacheProvider
06-22@16:59:18 INFO (SettingsFactory) - Optimize cache for minimal puts: disabled
06-22@16:59:18 INFO (SettingsFactory) - Structured second-level cache entries: disabled
06-22@16:59:18 DEBUG (SQLExceptionConverterFactory) - Using dialect defined converter
06-22@16:59:18 INFO (SettingsFactory) - Echoing all SQL to stdout
06-22@16:59:18 INFO (SettingsFactory) - Statistics: disabled
06-22@16:59:18 INFO (SettingsFactory) - Deleted entity synthetic identifier rollback: disabled
06-22@16:59:18 INFO (SettingsFactory) - Default entity-mode: pojo
06-22@16:59:18 INFO (SettingsFactory) - Named query checking : enabled
06-22@16:59:18 INFO (SessionFactoryImpl) - building session factory
06-22@16:59:18 DEBUG (SessionFactoryImpl) - Session factory constructed with filter configurations : {}
06-22@16:59:18 DEBUG (SessionFactoryImpl) - instantiating session factory with properties: {java.runtime.name=Java(TM) 2 Runtime Environment, Standard Edition, hibernate.connection.password=, sun.boot.library.path=C:\java\jdks\jdk1.5.0_11\jre\bin, java.vm.version=1.5.0_11-b03, hibernate.connection.username=sa, java.vm.vendor=Sun Microsystems Inc., java.vendor.url=http://java.sun.com/, path.separator=;, java.vm.name=Java HotSpot(TM) Client VM, file.encoding.pkg=sun.io, idea.launcher.port=7536, user.country=US, sun.java.launcher=SUN_STANDARD, sun.os.patch.level=Service Pack 2, java.vm.specification.name=Java Virtual Machine Specification, user.dir=C:\Documents and Settings\jcarman\IdeaProjects\hibernate-bug, java.runtime.version=1.5.0_11-b03, java.awt.graphicsenv=sun.awt.Win32GraphicsEnvironment, hbm2ddl.auto=create-drop, java.endorsed.dirs=C:\java\jdks\jdk1.5.0_11\jre\lib\endorsed, os.arch=x86, java.io.tmpdir=C:\DOCUME~1\jcarman\LOCALS~1\Temp\, line.separator=
, java.vm.specification.vendor=Sun Microsystems Inc., user.variant=, os.name=Windows XP, sun.jnu.encoding=Cp1252, java.library.path=C:\java\jdks\jdk1.5.0_11\bin;.;C:\WINDOWS\system32;C:\WINDOWS;C:\java\jdks\j2sdk1.4.2_13\bin;C:\java\libraries\apache-ant-1.6.1\bin;c:\acero\secant\bin;C:\oracle\instantclient_10_2;c:\cygwin\bin;c:\java\libraries\maven-2.0.6\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\Program Files\IDM Computer Solutions\UltraEdit-32;C:\Program Files\ATI Technologies\ATI.ACE\;, java.specification.name=Java Platform API Specification, java.class.version=49.0, sun.management.compiler=HotSpot Client Compiler, os.version=5.1, user.home=C:\Documents and Settings\jcarman, connection.password=, user.timezone=America/New_York, java.awt.printerjob=sun.awt.windows.WPrinterJob, connection.username=sa, java.specification.version=1.5, idea.launcher.bin.path=C:\Program Files\JetBrains\IntelliJ IDEA 7.0M1b\bin, file.encoding=windows-1252, hibernate.connection.driver_class=org.hsqldb.jdbcDriver, show_sql=true, user.name=jcarman, java.class.path=C:\Documents and Settings\jcarman\.IntelliJIdea70\config\plugins\testngrunner\lib\testngrunner.jar;C:\Documents and Settings\jcarman\.IntelliJIdea70\config\plugins\testngrunner\lib\testng-jdk15.jar;C:\java\jdks\jdk1.5.0_11\jre\lib\charsets.jar;C:\java\jdks\jdk1.5.0_11\jre\lib\deploy.jar;C:\java\jdks\jdk1.5.0_11\jre\lib\javaws.jar;C:\java\jdks\jdk1.5.0_11\jre\lib\jce.jar;C:\java\jdks\jdk1.5.0_11\jre\lib\jsse.jar;C:\java\jdks\jdk1.5.0_11\jre\lib\plugin.jar;C:\java\jdks\jdk1.5.0_11\jre\lib\rt.jar;C:\java\jdks\jdk1.5.0_11\jre\lib\ext\dnsns.jar;C:\java\jdks\jdk1.5.0_11\jre\lib\ext\localedata.jar;C:\java\jdks\jdk1.5.0_11\jre\lib\ext\sunjce_provider.jar;C:\java\jdks\jdk1.5.0_11\jre\lib\ext\sunpkcs11.jar;C:\Documents and Settings\jcarman\IdeaProjects\hibernate-bug\target\test-classes;C:\Documents and Settings\jcarman\IdeaProjects\hibernate-bug\target\classes;C:\Documents and Settings\jcarman\.m2\repository\asm\asm\1.5.3\asm-1.5.3.jar;C:\Documents and Settings\jcarman\.m2\repository\commons-collections\commons-collections\2.1.1\commons-collections-2.1.1.jar;C:\Documents and Settings\jcarman\.m2\repository\javax\transaction\jta\1.0.1B\jta-1.0.1B.jar;C:\Documents and Settings\jcarman\.m2\repository\commons-logging\commons-logging\1.0.4\commons-logging-1.0.4.jar;C:\Documents and Settings\jcarman\.m2\repository\org\hibernate\hibernate\3.2.4.sp1\hibernate-3.2.4.sp1.jar;C:\Documents and Settings\jcarman\.m2\repository\dom4j\dom4j\1.6.1\dom4j-1.6.1.jar;C:\Documents and Settings\jcarman\.m2\repository\cglib\cglib\2.1_3\cglib-2.1_3.jar;C:\Documents and Settings\jcarman\.m2\repository\asm\asm-attrs\1.5.3\asm-attrs-1.5.3.jar;C:\Documents and Settings\jcarman\.m2\repository\antlr\antlr\2.7.6\antlr-2.7.6.jar;C:\Documents and Settings\jcarman\.m2\repository\hsqldb\hsqldb\1.8.0.7\hsqldb-1.8.0.7.jar;C:\Documents and Settings\jcarman\.m2\repository\net\sf\ehcache\ehcache\1.2.3\ehcache-1.2.3.jar;C:\Documents and Settings\jcarman\.m2\repository\junit\junit\3.8.1\junit-3.8.1.jar;C:\Documents and Settings\jcarman\.m2\repository\org\testng\testng\5.5\testng-5.5-jdk15.jar;C:\Documents and Settings\jcarman\.m2\repository\log4j\log4j\1.2.14\log4j-1.2.14.jar;C:\Program Files\JetBrains\IntelliJ IDEA 7.0M1b\lib\idea_rt.jar, hibernate.bytecode.use_reflection_optimizer=false, hibernate.show_sql=true, java.vm.specification.version=1.0, sun.arch.data.model=32, java.home=C:\java\jdks\jdk1.5.0_11\jre, hibernate.connection.url=jdbc:hsqldb:mem://hibernate-bug, hibernate.dialect=org.hibernate.dialect.HSQLDialect, java.specification.vendor=Sun Microsystems Inc., user.language=en, awt.toolkit=sun.awt.windows.WToolkit, java.vm.info=mixed mode, java.version=1.5.0_11, java.ext.dirs=C:\java\jdks\jdk1.5.0_11\jre\lib\ext, sun.boot.class.path=C:\java\jdks\jdk1.5.0_11\jre\lib\rt.jar;C:\java\jdks\jdk1.5.0_11\jre\lib\i18n.jar;C:\java\jdks\jdk1.5.0_11\jre\lib\sunrsasign.jar;C:\java\jdks\jdk1.5.0_11\jre\lib\jsse.jar;C:\java\jdks\jdk1.5.0_11\jre\lib\jce.jar;C:\java\jdks\jdk1.5.0_11\jre\lib\charsets.jar;C:\java\jdks\jdk1.5.0_11\jre\classes, java.vendor=Sun Microsystems Inc., file.separator=\, connection.driver_class=org.hsqldb.jdbcDriver, java.vendor.url.bug=http://java.sun.com/cgi-bin/bugreport.cgi, hibernate.hbm2ddl.auto=create-drop, sun.cpu.endian=little, sun.io.unicode.encoding=UnicodeLittle, sun.desktop=windows, connection.url=jdbc:hsqldb:mem://hibernate-bug, sun.cpu.isalist=, dialect=org.hibernate.dialect.HSQLDialect}
06-22@16:59:18 DEBUG (AbstractEntityPersister) - Static SQL for entity: com.carmanconsulting.hibernate.bug.StringPropertyEntity
06-22@16:59:18 DEBUG (AbstractEntityPersister) - Version select: select id from StringPropertyEntity where id =?
06-22@16:59:18 DEBUG (AbstractEntityPersister) - Snapshot select: select stringprop_.id, stringprop_.property as property0_ from StringPropertyEntity stringprop_ where stringprop_.id=?
06-22@16:59:18 DEBUG (AbstractEntityPersister) - Insert 0: insert into StringPropertyEntity (property, id) values (?, ?)
06-22@16:59:18 DEBUG (AbstractEntityPersister) - Update 0: update StringPropertyEntity set property=? where id=?
06-22@16:59:18 DEBUG (AbstractEntityPersister) - Delete 0: delete from StringPropertyEntity where id=?
06-22@16:59:18 DEBUG (EntityLoader) - Static select for entity com.carmanconsulting.hibernate.bug.StringPropertyEntity: select stringprop0_.id as id0_0_, stringprop0_.property as property0_0_ from StringPropertyEntity stringprop0_ where stringprop0_.id=?
06-22@16:59:18 DEBUG (EntityLoader) - Static select for entity com.carmanconsulting.hibernate.bug.StringPropertyEntity: select stringprop0_.id as id0_0_, stringprop0_.property as property0_0_ from StringPropertyEntity stringprop0_ where stringprop0_.id=?
06-22@16:59:18 DEBUG (EntityLoader) - Static select for entity com.carmanconsulting.hibernate.bug.StringPropertyEntity: select stringprop0_.id as id0_0_, stringprop0_.property as property0_0_ from StringPropertyEntity stringprop0_ where stringprop0_.id=?
06-22@16:59:18 DEBUG (EntityLoader) - Static select for entity com.carmanconsulting.hibernate.bug.StringPropertyEntity: select stringprop0_.id as id0_0_, stringprop0_.property as property0_0_ from StringPropertyEntity stringprop0_ where stringprop0_.id=?
06-22@16:59:18 DEBUG (EntityLoader) - Static select for entity com.carmanconsulting.hibernate.bug.StringPropertyEntity: select stringprop0_.id as id0_0_, stringprop0_.property as property0_0_ from StringPropertyEntity stringprop0_ where stringprop0_.id=?
06-22@16:59:18 DEBUG (EntityLoader) - Static select for action ACTION_MERGE on entity com.carmanconsulting.hibernate.bug.StringPropertyEntity: select stringprop0_.id as id0_0_, stringprop0_.property as property0_0_ from StringPropertyEntity stringprop0_ where stringprop0_.id=?
06-22@16:59:18 DEBUG (EntityLoader) - Static select for action ACTION_REFRESH on entity com.carmanconsulting.hibernate.bug.StringPropertyEntity: select stringprop0_.id as id0_0_, stringprop0_.property as property0_0_ from StringPropertyEntity stringprop0_ where stringprop0_.id=?
06-22@16:59:18 DEBUG (SessionFactoryObjectFactory) - initializing class SessionFactoryObjectFactory
06-22@16:59:18 DEBUG (SessionFactoryObjectFactory) - registered: 0f859ff413553b550113553b573e0000 (unnamed)
06-22@16:59:18 INFO (SessionFactoryObjectFactory) - Not binding factory to JNDI, no JNDI name configured
06-22@16:59:18 DEBUG (SessionFactoryImpl) - instantiated session factory
06-22@16:59:18 DEBUG (Configuration) - processing extends queue
06-22@16:59:18 DEBUG (Configuration) - processing collection mappings
06-22@16:59:18 DEBUG (Configuration) - processing native query and ResultSetMapping mappings
06-22@16:59:18 DEBUG (Configuration) - processing association property references
06-22@16:59:18 DEBUG (Configuration) - processing foreign key constraints
06-22@16:59:18 DEBUG (Configuration) - processing extends queue
06-22@16:59:18 DEBUG (Configuration) - processing collection mappings
06-22@16:59:18 DEBUG (Configuration) - processing native query and ResultSetMapping mappings
06-22@16:59:18 DEBUG (Configuration) - processing association property references
06-22@16:59:18 DEBUG (Configuration) - processing foreign key constraints
06-22@16:59:18 INFO (SchemaExport) - Running hbm2ddl schema export
06-22@16:59:18 DEBUG (SchemaExport) - import file not found: /import.sql
06-22@16:59:18 INFO (SchemaExport) - exporting generated schema to database
06-22@16:59:18 DEBUG (DriverManagerConnectionProvider) - total checked-out connections: 0
06-22@16:59:18 DEBUG (DriverManagerConnectionProvider) - using pooled JDBC connection, pool size: 0
06-22@16:59:18 DEBUG (SchemaExport) - drop table StringPropertyEntity if exists
06-22@16:59:18 DEBUG (SchemaExport) - drop table dual_hibernate_sequence if exists
06-22@16:59:18 DEBUG (SchemaExport) - drop sequence hibernate_sequence
06-22@16:59:18 DEBUG (SchemaExport) - Unsuccessful: drop sequence hibernate_sequence
06-22@16:59:18 DEBUG (SchemaExport) - Sequence not found in statement [drop sequence hibernate_sequence]
06-22@16:59:18 DEBUG (SchemaExport) - create table StringPropertyEntity (id bigint not null, property varchar(255), primary key (id))
06-22@16:59:18 DEBUG (SchemaExport) - create table dual_hibernate_sequence (zero integer)
06-22@16:59:18 DEBUG (SchemaExport) - insert into dual_hibernate_sequence values (0)
06-22@16:59:18 DEBUG (SchemaExport) - create sequence hibernate_sequence start with 1 increment by 1
06-22@16:59:18 INFO (SchemaExport) - schema export complete
06-22@16:59:18 DEBUG (DriverManagerConnectionProvider) - returning connection to pool, pool size: 1
06-22@16:59:18 DEBUG (Configuration) - processing extends queue
06-22@16:59:18 DEBUG (Configuration) - processing collection mappings
06-22@16:59:18 DEBUG (Configuration) - processing native query and ResultSetMapping mappings
06-22@16:59:18 DEBUG (Configuration) - processing association property references
06-22@16:59:18 DEBUG (Configuration) - processing foreign key constraints
06-22@16:59:18 DEBUG (Configuration) - processing extends queue
06-22@16:59:18 DEBUG (Configuration) - processing collection mappings
06-22@16:59:18 DEBUG (Configuration) - processing native query and ResultSetMapping mappings
06-22@16:59:18 DEBUG (Configuration) - processing association property references
06-22@16:59:18 DEBUG (Configuration) - processing foreign key constraints
06-22@16:59:18 DEBUG (SessionFactoryImpl) - Checking 0 named HQL queries
06-22@16:59:18 DEBUG (SessionFactoryImpl) - Checking 0 named SQL queries
06-22@16:59:18 DEBUG (SessionImpl) - opened session at timestamp: 11825459587
06-22@16:59:18 DEBUG (JDBCTransaction) - begin
06-22@16:59:18 DEBUG (ConnectionManager) - opening JDBC connection
06-22@16:59:18 DEBUG (DriverManagerConnectionProvider) - total checked-out connections: 0
06-22@16:59:18 DEBUG (DriverManagerConnectionProvider) - using pooled JDBC connection, pool size: 0
06-22@16:59:18 DEBUG (JDBCTransaction) - current autocommit status: false
06-22@16:59:18 DEBUG (JDBCContext) - after transaction begin
06-22@16:59:18 DEBUG (DefaultSaveOrUpdateEventListener) - saving transient instance
06-22@16:59:18 DEBUG (AbstractBatcher) - about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
06-22@16:59:18 DEBUG (SQL) - select next value for hibernate_sequence from dual_hibernate_sequence
Hibernate: select next value for hibernate_sequence from dual_hibernate_sequence
06-22@16:59:18 DEBUG (AbstractBatcher) - preparing statement
06-22@16:59:18 DEBUG (SequenceGenerator) - Sequence identifier generated: 1
06-22@16:59:18 DEBUG (AbstractBatcher) - about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
06-22@16:59:18 DEBUG (AbstractBatcher) - closing statement
06-22@16:59:18 DEBUG (AbstractSaveEventListener) - generated identifier: 1, using strategy: org.hibernate.id.SequenceGenerator
06-22@16:59:18 DEBUG (AbstractSaveEventListener) - saving [com.carmanconsulting.hibernate.bug.StringPropertyEntity#1]
06-22@16:59:18 DEBUG (JDBCTransaction) - commit
06-22@16:59:18 DEBUG (SessionImpl) - automatically flushing session
06-22@16:59:18 DEBUG (AbstractFlushingEventListener) - flushing session
06-22@16:59:18 DEBUG (AbstractFlushingEventListener) - processing flush-time cascades
06-22@16:59:18 DEBUG (AbstractFlushingEventListener) - dirty checking collections
06-22@16:59:18 DEBUG (AbstractFlushingEventListener) - Flushing entities and processing referenced collections
06-22@16:59:18 DEBUG (AbstractFlushingEventListener) - Processing unreferenced collections
06-22@16:59:18 DEBUG (AbstractFlushingEventListener) - Scheduling collection removes/(re)creates/updates
06-22@16:59:18 DEBUG (AbstractFlushingEventListener) - Flushed: 1 insertions, 0 updates, 0 deletions to 1 objects
06-22@16:59:18 DEBUG (AbstractFlushingEventListener) - Flushed: 0 (re)creations, 0 updates, 0 removals to 0 collections
06-22@16:59:18 DEBUG (Printer) - listing entities:
06-22@16:59:18 DEBUG (Printer) - com.carmanconsulting.hibernate.bug.StringPropertyEntity{property=null, id=1}
06-22@16:59:18 DEBUG (AbstractFlushingEventListener) - executing flush
06-22@16:59:18 DEBUG (ConnectionManager) - registering flush begin
06-22@16:59:18 DEBUG (AbstractEntityPersister) - Inserting entity: [com.carmanconsulting.hibernate.bug.StringPropertyEntity#1]
06-22@16:59:18 DEBUG (AbstractBatcher) - about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
06-22@16:59:18 DEBUG (SQL) - insert into StringPropertyEntity (property, id) values (?, ?)
Hibernate: insert into StringPropertyEntity (property, id) values (?, ?)
06-22@16:59:18 DEBUG (AbstractBatcher) - preparing statement
06-22@16:59:18 DEBUG (AbstractEntityPersister) - Dehydrating entity: [com.carmanconsulting.hibernate.bug.StringPropertyEntity#1]
06-22@16:59:18 DEBUG (StringType) - binding null to parameter: 1
06-22@16:59:18 DEBUG (LongType) - binding '1' to parameter: 2
06-22@16:59:18 DEBUG (AbstractBatcher) - Executing batch size: 1
06-22@16:59:18 DEBUG (AbstractBatcher) - about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
06-22@16:59:18 DEBUG (AbstractBatcher) - closing statement
06-22@16:59:18 DEBUG (ConnectionManager) - registering flush end
06-22@16:59:18 DEBUG (AbstractFlushingEventListener) - post flush
06-22@16:59:18 DEBUG (JDBCContext) - before transaction completion
06-22@16:59:18 DEBUG (SessionImpl) - before transaction completion
06-22@16:59:18 DEBUG (JDBCTransaction) - committed JDBC Connection
06-22@16:59:18 DEBUG (JDBCContext) - after transaction completion
06-22@16:59:18 DEBUG (ConnectionManager) - aggressively releasing JDBC connection
06-22@16:59:18 DEBUG (ConnectionManager) - releasing JDBC connection [ (open PreparedStatements: 0, globally: 0) (open ResultSets: 0, globally: 0)]
06-22@16:59:18 DEBUG (DriverManagerConnectionProvider) - returning connection to pool, pool size: 1
06-22@16:59:18 DEBUG (SessionImpl) - after transaction completion
06-22@16:59:18 DEBUG (AbstractBatcher) - about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
06-22@16:59:18 DEBUG (ConnectionManager) - opening JDBC connection
06-22@16:59:18 DEBUG (DriverManagerConnectionProvider) - total checked-out connections: 0
06-22@16:59:18 DEBUG (DriverManagerConnectionProvider) - using pooled JDBC connection, pool size: 0
06-22@16:59:18 DEBUG (SQL) - select this_.id as id0_0_, this_.property as property0_0_ from StringPropertyEntity this_ where this_.property=?
Hibernate: select this_.id as id0_0_, this_.property as property0_0_ from StringPropertyEntity this_ where this_.property=?
06-22@16:59:18 DEBUG (AbstractBatcher) - preparing statement
06-22@16:59:18 DEBUG (StringType) - binding null to parameter: 1
06-22@16:59:18 DEBUG (AbstractBatcher) - about to open ResultSet (open ResultSets: 0, globally: 0)
06-22@16:59:18 DEBUG (Loader) - processing result set
06-22@16:59:18 DEBUG (Loader) - done processing result set (0 rows)
06-22@16:59:18 DEBUG (AbstractBatcher) - about to close ResultSet (open ResultSets: 1, globally: 1)
06-22@16:59:18 DEBUG (AbstractBatcher) - about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
06-22@16:59:18 DEBUG (AbstractBatcher) - closing statement
06-22@16:59:18 DEBUG (Loader) - total objects hydrated: 0
06-22@16:59:18 DEBUG (StatefulPersistenceContext) - initializing non-lazy collections
06-22@16:59:18 DEBUG (JDBCContext) - after autocommit
06-22@16:59:18 DEBUG (ConnectionManager) - aggressively releasing JDBC connection
06-22@16:59:18 DEBUG (ConnectionManager) - releasing JDBC connection [ (open PreparedStatements: 0, globally: 0) (open ResultSets: 0, globally: 0)]
06-22@16:59:18 DEBUG (DriverManagerConnectionProvider) - returning connection to pool, pool size: 1
I found 0 results using eq null
06-22@16:59:18 DEBUG (AbstractBatcher) - about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
06-22@16:59:18 DEBUG (ConnectionManager) - opening JDBC connection
06-22@16:59:18 DEBUG (DriverManagerConnectionProvider) - total checked-out connections: 0
06-22@16:59:18 DEBUG (DriverManagerConnectionProvider) - using pooled JDBC connection, pool size: 0
06-22@16:59:18 DEBUG (SQL) - select this_.id as id0_0_, this_.property as property0_0_ from StringPropertyEntity this_ where this_.property is null
Hibernate: select this_.id as id0_0_, this_.property as property0_0_ from StringPropertyEntity this_ where this_.property is null
06-22@16:59:18 DEBUG (AbstractBatcher) - preparing statement
06-22@16:59:18 DEBUG (AbstractBatcher) - about to open ResultSet (open ResultSets: 0, globally: 0)
06-22@16:59:18 DEBUG (Loader) - processing result set
06-22@16:59:18 DEBUG (Loader) - result set row: 0
06-22@16:59:18 DEBUG (LongType) - returning '1' as column: id0_0_
06-22@16:59:18 DEBUG (Loader) - result row: EntityKey[com.carmanconsulting.hibernate.bug.StringPropertyEntity#1]
06-22@16:59:18 DEBUG (Loader) - done processing result set (1 rows)
06-22@16:59:18 DEBUG (AbstractBatcher) - about to close ResultSet (open ResultSets: 1, globally: 1)
06-22@16:59:18 DEBUG (AbstractBatcher) - about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
06-22@16:59:18 DEBUG (AbstractBatcher) - closing statement
06-22@16:59:18 DEBUG (Loader) - total objects hydrated: 0
06-22@16:59:18 DEBUG (StatefulPersistenceContext) - initializing non-lazy collections
06-22@16:59:18 DEBUG (JDBCContext) - after autocommit
06-22@16:59:18 DEBUG (ConnectionManager) - aggressively releasing JDBC connection
06-22@16:59:18 DEBUG (ConnectionManager) - releasing JDBC connection [ (open PreparedStatements: 0, globally: 0) (open ResultSets: 0, globally: 0)]
06-22@16:59:18 DEBUG (DriverManagerConnectionProvider) - returning connection to pool, pool size: 1
I found 1 results using isNull
06-22@16:59:18 DEBUG (SessionImpl) - closing session
06-22@16:59:18 DEBUG (ConnectionManager) - connection already null in cleanup : no action
06-22@16:59:18 INFO (SessionFactoryImpl) - closing
06-22@16:59:18 INFO (DriverManagerConnectionProvider) - cleaning up connection pool: jdbc:hsqldb:mem://hibernate-bug
06-22@16:59:18 INFO (SchemaExport) - Running hbm2ddl schema export
06-22@16:59:18 DEBUG (SchemaExport) - import file not found: /import.sql
06-22@16:59:18 INFO (SchemaExport) - exporting generated schema to database
06-22@16:59:18 DEBUG (DriverManagerConnectionProvider) - total checked-out connections: 0
06-22@16:59:18 DEBUG (DriverManagerConnectionProvider) - opening new JDBC connection
06-22@16:59:18 DEBUG (DriverManagerConnectionProvider) - created connection to: jdbc:hsqldb:mem://hibernate-bug, Isolation Level: 2
06-22@16:59:18 DEBUG (SchemaExport) - drop table StringPropertyEntity if exists
06-22@16:59:18 DEBUG (SchemaExport) - drop table dual_hibernate_sequence if exists
06-22@16:59:18 DEBUG (SchemaExport) - drop sequence hibernate_sequence
06-22@16:59:18 INFO (SchemaExport) - schema export complete
06-22@16:59:18 DEBUG (DriverManagerConnectionProvider) - returning connection to pool, pool size: 1[/code]


Top
 Profile  
 
 Post subject: Re: Restrictions.eq() Method Does Not Handle nulls properly?
PostPosted: Sat Jun 23, 2007 6:41 am 
Beginner
Beginner

Joined: Tue Jun 07, 2005 8:24 am
Posts: 33
Location: Cincinnati, OH
Shouldn't the Restrictions.eq() method look like this instead?

Code:
public static SimpleExpression eq(String propertyName, Object value)
{
    if( value == null )
    {
        return isNull(propertyName);
    }
    else
    {
        return new SimpleExpression(propertyName, value, "=");
    }
}


It shouldn't break existing code, because if someone was passing nulls into this method in the past, it wasn't really working as expected (at least not how I would have expected it to work) anyway. Should I file I JIRA issue for this?


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

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.