-->
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.  [ 9 posts ] 
Author Message
 Post subject: CGLIB bug, unit test provided....
PostPosted: Fri Jul 29, 2005 6:15 am 
Beginner
Beginner

Joined: Wed May 04, 2005 5:17 am
Posts: 40
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version: 3.0.5

Mapping documents:
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
    "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
    "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">

<hibernate-mapping default-access="field">
  <class name="uk.ac.warwick.sbr.AbstractPageImpl"
         proxy="uk.ac.warwick.sbr.Page"
         table="PAGE"
         dynamic-insert="true"
         dynamic-update="true">
    <id name="id"
        column="id"
        type="java.lang.String"
        unsaved-value="null">
        <generator class="org.hibernate.id.UUIDHexGenerator"/>
    </id>
    <discriminator column="discriminator"/>
    <property name="url" column="URL"/>
  </class>

  <subclass discriminator-value="html"
            name="uk.ac.warwick.sbr.HtmlPageImpl"
            proxy="uk.ac.warwick.sbr.HtmlPage"
            extends="uk.ac.warwick.sbr.AbstractPageImpl"
            dynamic-insert="true"
            dynamic-update="true">
  </subclass>

  <subclass discriminator-value="binary"
            name="uk.ac.warwick.sbr.BinaryPageImpl"
            proxy="uk.ac.warwick.sbr.BinaryPage"
            extends="uk.ac.warwick.sbr.AbstractPageImpl"
            dynamic-insert="true"
            dynamic-update="true"/>
</hibernate-mapping>


Code between sessionFactory.openSession() and session.close():
Code:
        Configuration configuration = new Configuration();
        configuration = configuration.configure("local_hibernate.cfg.xml");

        factory = configuration.buildSessionFactory();
        this.siteUrl = "/site";
        session = factory.openSession();

        sitePage = new HtmlPageImpl();
        sitePage.setUrl(siteUrl);

        session.saveOrUpdate(sitePage);
        session.flush();

        // make sure the page was saved.
        Session anotherSession = factory.openSession();
        Collection<Page> sitePages = anotherSession.createQuery("from AbstractPageImpl p").list();
        assertEquals("pages on site", 1, sitePages.size());

        // make sure we can retrieve by id.
        anotherSession.evict(sitePage);
        session.close();
        anotherSession.close();
        session = factory.openSession();
        Page loadedSitePage = (Page) session.load(AbstractPageImpl.class, sitePage.getId());
        assertTrue("should be html page", loadedSitePage instanceof HtmlPage);
        assertFalse("should not be binary page", loadedSitePage instanceof BinaryPage);
        anotherSession.close();


Full stack trace of any exception that occurs:


Name and version of the database you are using:
hypersonic and oracle 9.1

The generated SQL (show_sql=true):
[code]
11:08:55,952 DEBUG SchemaExport:143 - drop table PAGE if exists
11:08:55,952 DEBUG SchemaExport:161 - create table PAGE (
id varchar(255) not null,
discriminator varchar(255) not null,
URL varchar(255),
primary key (id)
)
Hibernate: insert into PAGE (URL, discriminator, id) values (?, 'html', ?)
Hibernate: select abstractpa0_.id as id, abstractpa0_.URL as URL0_, abstractpa0_.discriminator as discrimi2_ from PAGE abstractpa0_

Debug level Hibernate log excerpt:
[code]
11:08:53,936 INFO Environment:464 - Hibernate 3.0.5
11:08:53,936 INFO Environment:477 - hibernate.properties not found
11:08:53,952 INFO Environment:510 - using CGLIB reflection optimizer
11:08:53,952 INFO Environment:540 - using JDK 1.4 java.sql.Timestamp handling
11:08:54,061 INFO Configuration:1110 - configuring from resource: local_hibernate.cfg.xml
11:08:54,061 INFO Configuration:1081 - Configuration resource: local_hibernate.cfg.xml
11:08:54,186 DEBUG DTDEntityResolver:42 - trying to locate http://hibernate.sourceforge.net/hibern ... on-3.0.dtd in classpath under org/hibernate/
11:08:54,186 DEBUG DTDEntityResolver:53 - found http://hibernate.sourceforge.net/hibern ... on-3.0.dtd in classpath
11:08:54,249 DEBUG Configuration:1067 - connection.driver_class=org.hsqldb.jdbcDriver
11:08:54,249 DEBUG Configuration:1067 - connection.url=jdbc:hsqldb:.
11:08:54,249 DEBUG Configuration:1067 - dialect=org.hibernate.dialect.HSQLDialect
11:08:54,249 DEBUG Configuration:1067 - show_sql=true
11:08:54,249 DEBUG Configuration:1067 - use_outer_join=true
11:08:54,249 DEBUG Configuration:1067 - hbm2ddl.auto=create-drop
11:08:54,249 DEBUG Configuration:1262 - java:comp/env/hibernate/SessionFactory<-org.dom4j.tree.DefaultAttribute@1e859c0 [Attribute: name resource value "uk/ac/warwick/sbr/Page.hbm.xml"]
11:08:54,249 INFO Configuration:444 - Mapping resource: uk/ac/warwick/sbr/Page.hbm.xml
11:08:54,249 DEBUG DTDEntityResolver:42 - trying to locate http://hibernate.sourceforge.net/hibern ... ng-3.0.dtd in classpath under org/hibernate/
11:08:54,264 DEBUG DTDEntityResolver:53 - found http://hibernate.sourceforge.net/hibern ... ng-3.0.dtd in classpath
11:08:54,452 INFO HbmBinder:260 - Mapping class: uk.ac.warwick.sbr.AbstractPageImpl -> PAGE
11:08:54,452 DEBUG HbmBinder:1099 - Mapped property: id -> id
11:08:54,483 DEBUG HbmBinder:1099 - Mapped property: url -> URL
11:08:54,546 INFO HbmBinder:737 - Mapping subclass: uk.ac.warwick.sbr.HtmlPageImpl -> PAGE
11:08:54,546 INFO HbmBinder:737 - Mapping subclass: uk.ac.warwick.sbr.BinaryPageImpl -> PAGE
11:08:54,546 INFO Configuration:1222 - Configured SessionFactory: java:comp/env/hibernate/SessionFactory
11:08:54,546 DEBUG Configuration:1223 - properties: {java.runtime.name=Java(TM) 2 Runtime Environment, Standard Edition, sun.boot.library.path=C:\Program Files\Java\jre1.5.0_03\bin, java.vm.version=1.5.0_03-b07, 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, use_outer_join=true, user.country=GB, sun.os.patch.level=Service Pack 2, java.vm.specification.name=Java Virtual Machine Specification, user.dir=C:\Documents and Settings\xusqac\workspace\cglibtest, java.runtime.version=1.5.0_03-b07, java.awt.graphicsenv=sun.awt.Win32GraphicsEnvironment, hbm2ddl.auto=create-drop, java.endorsed.dirs=C:\Program Files\Java\jre1.5.0_03\lib\endorsed, os.arch=x86, java.io.tmpdir=C:\DOCUME~1\xusqac\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:\Program Files\Java\jre1.5.0_03\bin;.;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\Program Files\ATI Technologies\ATI Control Panel, 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\xusqac, user.timezone=Europe/London, java.awt.printerjob=sun.awt.windows.WPrinterJob, file.encoding=Cp1252, java.specification.version=1.5, hibernate.connection.driver_class=org.hsqldb.jdbcDriver, show_sql=true, user.name=xusqac, java.class.path=C:\Documents and Settings\xusqac\workspace\cglibtest\bin;C:\Documents and Settings\xusqac\workspace\cglibtest\lib\container\javax.servlet.jar;C:\Documents and Settings\xusqac\workspace\cglibtest\lib\external\log4j\log4j-1.2.9.jar;C:\Documents and Settings\xusqac\workspace\cglibtest\lib\external\junit\jmock-1.0.1.jar;C:\Documents and Settings\xusqac\workspace\cglibtest\lib\external\junit\junit.jar;C:\Documents and Settings\xusqac\workspace\cglibtest\lib\external\hibernate\hibernate3.jar;C:\Documents and Settings\xusqac\workspace\cglibtest\lib\external\hibernate\dom4j-1.6.jar;C:\Documents and Settings\xusqac\workspace\cglibtest\lib\external\hibernate\ehcache-1.1.jar;C:\Documents and Settings\xusqac\workspace\cglibtest\lib\container\jboss-j2ee.jar;C:\Documents and Settings\xusqac\workspace\cglibtest\lib\external\hibernate\cglib-2.1.jar;C:\Documents and Settings\xusqac\workspace\cglibtest\lib\external\hibernate\antlr-2.7.5H3.jar;C:\Documents and Settings\xusqac\workspace\cglibtest\lib\external\hibernate\asm.jar;C:\Documents and Settings\xusqac\workspace\cglibtest\lib\external\hsql\hsqldb.jar;C:\Documents and Settings\xusqac\workspace\cglibtest\lib\external\commons\commons-collections-3.1.jar;C:\Documents and Settings\xusqac\workspace\cglibtest\lib\external\commons\commons-logging.jar;C:\Documents and Settings\xusqac\workspace\cglibtest\lib\external\commons\commons-logging-api.jar;/c:/apps/eclipse/plugins/org.eclipse.jdt.junit_3.1.0/junitsupport.jar;/c:/apps/eclipse/plugins/org.eclipse.jdt.junit.runtime_3.1.0/junitruntime.jar, hibernate.show_sql=true, java.vm.specification.version=1.0, java.home=C:\Program Files\Java\jre1.5.0_03, sun.arch.data.model=32, hibernate.dialect=org.hibernate.dialect.HSQLDialect, hibernate.connection.url=jdbc:hsqldb:., user.language=en, java.specification.vendor=Sun Microsystems Inc., awt.toolkit=sun.awt.windows.WToolkit, hibernate.cglib.use_reflection_optimizer=true, java.vm.info=mixed mode, sharing, java.version=1.5.0_03, java.ext.dirs=C:\Program Files\Java\jre1.5.0_03\lib\ext, sun.boot.class.path=C:\Program Files\Java\jre1.5.0_03\lib\rt.jar;C:\Program Files\Java\jre1.5.0_03\lib\i18n.jar;C:\Program Files\Java\jre1.5.0_03\lib\sunrsasign.jar;C:\Program Files\Java\jre1.5.0_03\lib\jsse.jar;C:\Program Files\Java\jre1.5.0_03\lib\jce.jar;C:\Program Files\Java\jre1.5.0_03\lib\charsets.jar;C:\Program Files\Java\jre1.5.0_03\classes, java.vendor=Sun Microsystems Inc., connection.driver_class=org.hsqldb.jdbcDriver, file.separator=\, hibernate.session_factory_name=java:comp/env/hibernate/SessionFactory, 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, hibernate.use_outer_join=true, sun.desktop=windows, connection.url=jdbc:hsqldb:., dialect=org.hibernate.dialect.HSQLDialect, sun.cpu.isalist=}
11:08:54,546 DEBUG Configuration:998 - Preparing to build session factory with filters : {}
11:08:54,546 INFO Configuration:875 - processing extends queue
11:08:54,546 INFO Configuration:879 - processing collection mappings
11:08:54,546 INFO Configuration:888 - processing association property references
11:08:54,546 INFO Configuration:917 - processing foreign key constraints
11:08:54,655 INFO DriverManagerConnectionProvider:41 - Using Hibernate built-in connection pool (not for production use!)
11:08:54,655 INFO DriverManagerConnectionProvider:42 - Hibernate connection pool size: 20
11:08:54,655 INFO DriverManagerConnectionProvider:45 - autocommit mode: false
11:08:54,671 INFO DriverManagerConnectionProvider:80 - using driver: org.hsqldb.jdbcDriver at URL: jdbc:hsqldb:.
11:08:54,671 INFO DriverManagerConnectionProvider:83 - connection properties: {}
11:08:54,671 DEBUG DriverManagerConnectionProvider:93 - total checked-out connections: 0
11:08:54,671 DEBUG DriverManagerConnectionProvider:109 - opening new JDBC connection
11:08:55,030 DEBUG DriverManagerConnectionProvider:115 - created connection to: jdbc:hsqldb:., Isolation Level: 1
11:08:55,077 INFO SettingsFactory:77 - RDBMS: HSQL Database Engine, version: 1.7.3
11:08:55,077 INFO SettingsFactory:78 - JDBC driver: HSQL Database Engine Driver, version: 1.7.3
11:08:55,077 DEBUG DriverManagerConnectionProvider:129 - returning connection to pool, pool size: 1
11:08:55,108 INFO Dialect:92 - Using dialect: org.hibernate.dialect.HSQLDialect
11:08:55,124 INFO TransactionFactoryFactory:31 - Using default transaction strategy (direct JDBC transactions)
11:08:55,124 INFO TransactionManagerLookupFactory:33 - No TransactionManagerLookup configured (in JTA environment, use of read-write or transactional second-level cache is not recommended)
11:08:55,124 INFO SettingsFactory:125 - Automatic flush during beforeCompletion(): disabled
11:08:55,139 INFO SettingsFactory:129 - Automatic session close at end of transaction: disabled
11:08:55,139 INFO SettingsFactory:136 - JDBC batch size: 15
11:08:55,139 INFO SettingsFactory:139 - JDBC batch updates for versioned data: disabled
11:08:55,139 INFO SettingsFactory:144 - Scrollable result sets: enabled
11:08:55,139 DEBUG SettingsFactory:148 - Wrap result sets: disabled
11:08:55,139 INFO SettingsFactory:152 - JDBC3 getGeneratedKeys(): disabled
11:08:55,139 INFO SettingsFactory:160 - Connection release mode: null
11:08:55,139 INFO SettingsFactory:187 - Default batch fetch size: 1
11:08:55,139 INFO SettingsFactory:191 - Generate SQL with comments: disabled
11:08:55,139 INFO SettingsFactory:195 - Order SQL updates by primary key: disabled
11:08:55,139 INFO SettingsFactory:334 - Query translator: org.hibernate.hql.ast.ASTQueryTranslatorFactory
11:08:55,155 INFO ASTQueryTranslatorFactory:21 - Using ASTQueryTranslatorFactory
11:08:55,155 INFO SettingsFactory:203 - Query language substitutions: {}
11:08:55,155 INFO SettingsFactory:209 - Second-level cache: enabled
11:08:55,155 INFO SettingsFactory:213 - Query cache: disabled
11:08:55,155 INFO SettingsFactory:321 - Cache provider: org.hibernate.cache.EhCacheProvider
11:08:55,155 INFO SettingsFactory:228 - Optimize cache for minimal puts: disabled
11:08:55,155 INFO SettingsFactory:237 - Structured second-level cache entries: disabled
11:08:55,155 DEBUG SQLExceptionConverterFactory:52 - Using dialect defined converter
11:08:55,171 INFO SettingsFactory:257 - Echoing all SQL to stdout
11:08:55,171 INFO SettingsFactory:261 - Statistics: disabled
11:08:55,171 INFO SettingsFactory:265 - Deleted entity synthetic identifier rollback: disabled
11:08:55,171 INFO SettingsFactory:279 - Default entity-mode: pojo
11:08:55,358 INFO SessionFactoryImpl:152 - building session factory
11:08:55,358 DEBUG SessionFactoryImpl:161 - Session factory constructed with filter configurations : {}
11:08:55,358 DEBUG SessionFactoryImpl:164 - instantiating session factory with properties: {java.runtime.name=Java(TM) 2 Runtime Environment, Standard Edition, sun.boot.library.path=C:\Program Files\Java\jre1.5.0_03\bin, java.vm.version=1.5.0_03-b07, 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, use_outer_join=true, user.country=GB, sun.os.patch.level=Service Pack 2, java.vm.specification.name=Java Virtual Machine Specification, user.dir=C:\Documents and Settings\xusqac\workspace\cglibtest, java.runtime.version=1.5.0_03-b07, java.awt.graphicsenv=sun.awt.Win32GraphicsEnvironment, hbm2ddl.auto=create-drop, java.endorsed.dirs=C:\Program Files\Java\jre1.5.0_03\lib\endorsed, os.arch=x86, java.io.tmpdir=C:\DOCUME~1\xusqac\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:\Program Files\Java\jre1.5.0_03\bin;.;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\Program Files\ATI Technologies\ATI Control Panel, 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\xusqac, user.timezone=Europe/London, java.awt.printerjob=sun.awt.windows.WPrinterJob, file.encoding=Cp1252, java.specification.version=1.5, hibernate.connection.driver_class=org.hsqldb.jdbcDriver, show_sql=true, user.name=xusqac, java.class.path=C:\Documents and Settings\xusqac\workspace\cglibtest\bin;C:\Documents and Settings\xusqac\workspace\cglibtest\lib\container\javax.servlet.jar;C:\Documents and Settings\xusqac\workspace\cglibtest\lib\external\log4j\log4j-1.2.9.jar;C:\Documents and Settings\xusqac\workspace\cglibtest\lib\external\junit\jmock-1.0.1.jar;C:\Documents and Settings\xusqac\workspace\cglibtest\lib\external\junit\junit.jar;C:\Documents and Settings\xusqac\workspace\cglibtest\lib\external\hibernate\hibernate3.jar;C:\Documents and Settings\xusqac\workspace\cglibtest\lib\external\hibernate\dom4j-1.6.jar;C:\Documents and Settings\xusqac\workspace\cglibtest\lib\external\hibernate\ehcache-1.1.jar;C:\Documents and Settings\xusqac\workspace\cglibtest\lib\container\jboss-j2ee.jar;C:\Documents and Settings\xusqac\workspace\cglibtest\lib\external\hibernate\cglib-2.1.jar;C:\Documents and Settings\xusqac\workspace\cglibtest\lib\external\hibernate\antlr-2.7.5H3.jar;C:\Documents and Settings\xusqac\workspace\cglibtest\lib\external\hibernate\asm.jar;C:\Documents and Settings\xusqac\workspace\cglibtest\lib\external\hsql\hsqldb.jar;C:\Documents and Settings\xusqac\workspace\cglibtest\lib\external\commons\commons-collections-3.1.jar;C:\Documents and Settings\xusqac\workspace\cglibtest\lib\external\commons\commons-logging.jar;C:\Documents and Settings\xusqac\workspace\cglibtest\lib\external\commons\commons-logging-api.jar;/c:/apps/eclipse/plugins/org.eclipse.jdt.junit_3.1.0/junitsupport.jar;/c:/apps/eclipse/plugins/org.eclipse.jdt.junit.runtime_3.1.0/junitruntime.jar, hibernate.show_sql=true, java.vm.specification.version=1.0, java.home=C:\Program Files\Java\jre1.5.0_03, sun.arch.data.model=32, hibernate.dialect=org.hibernate.dialect.HSQLDialect, hibernate.connection.url=jdbc:hsqldb:., user.language=en, java.specification.vendor=Sun Microsystems Inc., awt.toolkit=sun.awt.windows.WToolkit, hibernate.cglib.use_reflection_optimizer=true, java.vm.info=mixed mode, sharing, java.version=1.5.0_03, java.ext.dirs=C:\Program Files\Java\jre1.5.0_03\lib\ext, sun.boot.class.path=C:\Program Files\Java\jre1.5.0_03\lib\rt.jar;C:\Program Files\Java\jre1.5.0_03\lib\i18n.jar;C:\Program Files\Java\jre1.5.0_03\lib\sunrsasign.jar;C:\Program Files\Java\jre1.5.0_03\lib\jsse.jar;C:\Program Files\Java\jre1.5.0_03\lib\jce.jar;C:\Program Files\Java\jre1.5.0_03\lib\charsets.jar;C:\Program Files\Java\jre1.5.0_03\classes, java.vendor=Sun Microsystems Inc., connection.driver_class=org.hsqldb.jdbcDriver, file.separator=\, hibernate.session_factory_name=java:comp/env/hibernate/SessionFactory, 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, hibernate.use_outer_join=true, sun.desktop=windows, connection.url=jdbc:hsqldb:., dialect=org.hibernate.dialect.HSQLDialect, sun.cpu.isalist=}
11:08:55,358 DEBUG CacheManager:191 - Creating new CacheManager with default config
11:08:55,374 DEBUG CacheManager:164 - Configuring ehcache from classpath.
11:08:55,374 WARN Configurator:126 - No configuration found. Configuring ehcache from ehcache-failsafe.xml found in the classpath: jar:file:/C:/Documents%20and%20Settings/xusqac/workspace/cglibtest/lib/external/hibernate/ehcache-1.1.jar!/ehcache-failsafe.xml
11:08:55,389 DEBUG Configuration$DiskStore:185 - Disk Store Path: C:\DOCUME~1\xusqac\LOCALS~1\Temp\
11:08:55,717 DEBUG BasicEntityPersister:2220 - Static SQL for entity: uk.ac.warwick.sbr.AbstractPageImpl
11:08:55,717 DEBUG BasicEntityPersister:2222 - Version select: select id from PAGE where id =?
11:08:55,717 DEBUG BasicEntityPersister:2223 - Snapshot select: select abstractpa_.id, abstractpa_.URL as URL0_ from PAGE abstractpa_ where abstractpa_.id=?
11:08:55,717 DEBUG BasicEntityPersister:2225 - Insert 0: insert into PAGE (URL, discriminator, id) values (?, 'uk.ac.warwick.sbr.AbstractPageImpl', ?)
11:08:55,717 DEBUG BasicEntityPersister:2226 - Update 0: update PAGE set URL=? where id=?
11:08:55,717 DEBUG BasicEntityPersister:2227 - Delete 0: delete from PAGE where id=?
11:08:55,749 DEBUG BasicEntityPersister:2220 - Static SQL for entity: uk.ac.warwick.sbr.HtmlPageImpl
11:08:55,749 DEBUG BasicEntityPersister:2222 - Version select: select id from PAGE where id =?
11:08:55,749 DEBUG BasicEntityPersister:2223 - Snapshot select: select htmlpageim_.id, htmlpageim_.URL as URL0_ from PAGE htmlpageim_ where htmlpageim_.id=?
11:08:55,749 DEBUG BasicEntityPersister:2225 - Insert 0: insert into PAGE (URL, discriminator, id) values (?, 'html', ?)
11:08:55,749 DEBUG BasicEntityPersister:2226 - Update 0: update PAGE set URL=? where id=?
11:08:55,764 DEBUG BasicEntityPersister:2227 - Delete 0: delete from PAGE where id=?
11:08:55,780 DEBUG BasicEntityPersister:2220 - Static SQL for entity: uk.ac.warwick.sbr.BinaryPageImpl
11:08:55,780 DEBUG BasicEntityPersister:2222 - Version select: select id from PAGE where id =?
11:08:55,796 DEBUG BasicEntityPersister:2223 - Snapshot select: select binarypage_.id, binarypage_.URL as URL0_ from PAGE binarypage_ where binarypage_.id=?
11:08:55,796 DEBUG BasicEntityPersister:2225 - Insert 0: insert into PAGE (URL, discriminator, id) values (?, 'binary', ?)
11:08:55,796 DEBUG BasicEntityPersister:2226 - Update 0: update PAGE set URL=? where id=?
11:08:55,796 DEBUG BasicEntityPersister:2227 - Delete 0: delete from PAGE where id=?
11:08:55,905 DEBUG EntityLoader:95 - Static select for entity uk.ac.warwick.sbr.AbstractPageImpl: select abstractpa0_.id as id0_, abstractpa0_.URL as URL0_0_, abstractpa0_.discriminator as discrimi2_0_ from PAGE abstractpa0_ where abstractpa0_.id=?
11:08:55,905 DEBUG EntityLoader:95 - Static select for entity uk.ac.warwick.sbr.AbstractPageImpl: select abstractpa0_.id as id0_, abstractpa0_.URL as URL0_0_, abstractpa0_.discriminator as discrimi2_0_ from PAGE abstractpa0_ where abstractpa0_.id=?
11:08:55,905 DEBUG EntityLoader:95 - Static select for entity uk.ac.warwick.sbr.AbstractPageImpl: select abstractpa0_.id as id0_, abstractpa0_.URL as URL0_0_, abstractpa0_.discriminator as discrimi2_0_ from PAGE abstractpa0_ where abstractpa0_.id=?
11:08:55,905 DEBUG EntityLoader:95 - Static select for entity uk.ac.warwick.sbr.AbstractPageImpl: select abstractpa0_.id as id0_, abstractpa0_.URL as URL0_0_, abstractpa0_.discriminator as discrimi2_0_ from PAGE abstractpa0_ where abstractpa0_.id=?
11:08:55,905 DEBUG EntityLoader:95 - Static select for entity uk.ac.warwick.sbr.HtmlPageImpl: select htmlpageim0_.id as id0_, htmlpageim0_.URL as URL0_0_ from PAGE htmlpageim0_ where htmlpageim0_.id=? and htmlpageim0_.discriminator='html'
11:08:55,905 DEBUG EntityLoader:95 - Static select for entity uk.ac.warwick.sbr.HtmlPageImpl: select htmlpageim0_.id as id0_, htmlpageim0_.URL as URL0_0_ from PAGE htmlpageim0_ where htmlpageim0_.id=? and htmlpageim0_.discriminator='html'
11:08:55,905 DEBUG EntityLoader:95 - Static select for entity uk.ac.warwick.sbr.HtmlPageImpl: select htmlpageim0_.id as id0_, htmlpageim0_.URL as URL0_0_ from PAGE htmlpageim0_ where htmlpageim0_.id=? and htmlpageim0_.discriminator='html'
11:08:55,905 DEBUG EntityLoader:95 - Static select for entity uk.ac.warwick.sbr.HtmlPageImpl: select htmlpageim0_.id as id0_, htmlpageim0_.URL as URL0_0_ from PAGE htmlpageim0_ where htmlpageim0_.id=? and htmlpageim0_.discriminator='html'
11:08:55,905 DEBUG EntityLoader:95 - Static select for entity uk.ac.warwick.sbr.BinaryPageImpl: select binarypage0_.id as id0_, binarypage0_.URL as URL0_0_ from PAGE binarypage0_ where binarypage0_.id=? and binarypage0_.discriminator='binary'
11:08:55,905 DEBUG EntityLoader:95 - Static select for entity uk.ac.warwick.sbr.BinaryPageImpl: select binarypage0_.id as id0_, binarypage0_.URL as URL0_0_ from PAGE binarypage0_ where binarypage0_.id=? and binarypage0_.discriminator='binary'
11:08:55,905 DEBUG EntityLoader:95 - Static select for entity uk.ac.warwick.sbr.BinaryPageImpl: select binarypage0_.id as id0_, binarypage0_.URL as URL0_0_ from PAGE binarypage0_ where binarypage0_.id=? and binarypage0_.discriminator='binary'
11:08:55,905 DEBUG EntityLoader:95 - Static select for entity uk.ac.warwick.sbr.BinaryPageImpl: select binarypage0_.id as id0_, binarypage0_.URL as URL0_0_ from PAGE binarypage0_ where binarypage0_.id=? and binarypage0_.discriminator='binary'
11:08:55,921 DEBUG SessionFactoryObjectFactory:39 - initializing class SessionFactoryObjectFactory
11:08:55,921 DEBUG SessionFactoryObjectFactory:76 - registered: 094d42a0056210d701056210da610000 (java:comp/env/hibernate/SessionFactory)
11:08:55,921 INFO SessionFactoryObjectFactory:86 - Factory name: java:comp/env/hibernate/SessionFactory
11:08:55,921 INFO NamingHelper:26 - JNDI InitialContext properties:{}
11:08:55,921 DEBUG NamingHelper:48 - binding: java:comp/env/hibernate/SessionFactory
11:08:55,936 WARN SessionFactoryObjectFactory:98 - Could not bind factory to JNDI
javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial
at javax.naming.spi.NamingManager.getInitialContext(Unknown Source)
at javax.naming.InitialContext.getDefaultInitCtx(Unknown Source)
at javax.naming.InitialContext.getURLOrDefaultInitCtx(Unknown Source)
at javax.naming.InitialContext.getNameParser(Unknown Source)
at org.hibernate.util.NamingHelper.bind(NamingHelper.java:52)
at org.hibernate.impl.SessionFactoryObjectFactory.addInstance(SessionFactoryObjectFactory.java:90)
at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:260)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1005)
at uk.ac.warwick.sbr.dao.hibernate.ManipulatePageTest.testItWorks(ManipulatePageTest.java:27)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at junit.framework.TestCase.runTest(TestCase.java:154)
at junit.framework.TestCase.runBare(TestCase.java:127)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:118)
at junit.framework.TestSuite.runTest(TestSuite.java:208)
at junit.framework.TestSuite.run(TestSuite.java:203)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:478)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:344)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
11:08:55,936 DEBUG SessionFactoryImpl:262 - instantiated session factory
11:08:55,936 INFO Dialect:92 - Using dialect: org.hibernate.dialect.HSQLDialect
11:08:55,936 INFO Configuration:875 - processing extends queue
11:08:55,952 INFO Configuration:879 - processing collection mappings
11:08:55,952 INFO Configuration:888 - processing association property references
11:08:55,952 INFO Configuration:917 - processing foreign key constraints
11:08:55,952 INFO Configuration:875 - processing extends queue
11:08:55,952 INFO Configuration:879 - processing collection mappings
11:08:55,952 INFO Configuration:888 - processing association property references
11:08:55,952 INFO Configuration:917 - processing foreign key constraints
11:08:55,952 INFO SchemaExport:113 - Running hbm2ddl schema export
11:08:55,952 INFO SchemaExport:129 - exporting generated schema to database
11:08:55,952 INFO DriverManagerConnectionProvider:41 - Using Hibernate built-in connection pool (not for production use!)
11:08:55,952 INFO DriverManagerConnectionProvider:42 - Hibernate connection pool size: 20
11:08:55,952 INFO DriverManagerConnectionProvider:45 - autocommit mode: false
11:08:55,952 INFO DriverManagerConnectionProvider:80 - using driver: org.hsqldb.jdbcDriver at URL: jdbc:hsqldb:.
11:08:55,952 INFO DriverManagerConnectionProvider:83 - connection properties: {}
11:08:55,952 DEBUG DriverManagerConnectionProvider:93 - total checked-out connections: 0
11:08:55,952 DEBUG DriverManagerConnectionProvider:109 - opening new JDBC connection
11:08:55,952 DEBUG DriverManagerConnectionProvider:115 - created connection to: jdbc:hsqldb:., Isolation Level: 1
11:08:55,952 DEBUG SchemaExport:143 - drop table PAGE if exists
11:08:55,952 DEBUG SchemaExport:161 - create table PAGE (
id varchar(255) not null,
discriminator varchar(255) not null,
URL varchar(255),
primary key (id)
)
11:08:55,967 INFO SchemaExport:173 - schema export complete
11:08:55,967 DEBUG DriverManagerConnectionProvider:129 - returning connection to pool, pool size: 1
11:08:55,967 INFO DriverManagerConnectionProvider:147 - cleaning up connection pool: jdbc:hsqldb:.
11:08:55,967 INFO Dialect:92 - Using dialect: org.hibernate.dialect.HSQLDialect
11:08:55,967 INFO Configuration:875 - processing extends queue
11:08:55,983 INFO Configuration:879 - processing collection mappings
11:08:55,983 INFO Configuration:888 - processing association property references
11:08:55,983 INFO Configuration:917 - processing foreign key constraints
11:08:55,983 INFO Configuration:875 - processing extends queue
11:08:55,983 INFO Configuration:879 - processing collection mappings
11:08:55,983 INFO DriverManagerConnectionProvider:147 - cleaning up connection pool: jdbc:hsqldb:.
11:08:55,983 INFO Configuration:888 - processing association property references
11:08:55,983 INFO Configuration:917 - processing foreign key constraints
11:08:55,983 INFO SessionFactoryImpl:379 - Checking 0 named queries
11:08:56,030 DEBUG SessionImpl:250 - opened session at timestamp: 4598299590586368
11:08:56,046 DEBUG AbstractSaveEventListener:410 - transient instance of: uk.ac.warwick.sbr.HtmlPageImpl
11:08:56,046 DEBUG DefaultSaveOrUpdateEventListener:159 - saving transient instance
11:08:56,046 DEBUG AbstractSaveEventListener:100 - generated identifier: 094d42a0056210d701056210daee0001, using strategy: org.hibernate.id.UUIDHexGenerator
11:08:56,046 DEBUG AbstractSaveEventListener:133 - saving [uk.ac.warwick.sbr.HtmlPageImpl#094d42a0056210d701056210daee0001]
11:08:56,061 DEBUG AbstractFlushingEventListener:52 - flushing session
11:08:56,061 DEBUG AbstractFlushingEventListener:102 - processing flush-time cascades
11:08:56,077 DEBUG AbstractFlushingEventListener:150 - dirty checking collections
11:08:56,077 DEBUG AbstractFlushingEventListener:167 - Flushing entities and processing referenced collections
11:08:56,077 DEBUG AbstractFlushingEventListener:203 - Processing unreferenced collections
11:08:56,077 DEBUG AbstractFlushingEventListener:217 - Scheduling collection removes/(re)creates/updates
11:08:56,077 DEBUG AbstractFlushingEventListener:79 - Flushed: 1 insertions, 0 updates, 0 deletions to 1 objects
11:08:56,077 DEBUG AbstractFlushingEventListener:85 - Flushed: 0 (re)creations, 0 updates, 0 removals to 0 collections
11:08:56,077 DEBUG Printer:83 - listing entities:
11:08:56,077 DEBUG Printer:90 - uk.ac.warwick.sbr.HtmlPageImpl{url=/site, id=094d42a0056210d701056210daee0001}
11:08:56,077 DEBUG AbstractFlushingEventListener:267 - executing flush
11:08:56,092 DEBUG BasicEntityPersister:1825 - Inserting entity: [uk.ac.warwick.sbr.HtmlPageImpl#094d42a0056210d701056210daee0001]
11:08:56,092 DEBUG AbstractBatcher:290 - about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
11:08:56,092 DEBUG ConnectionManager:296 - opening JDBC connection
11:08:56,092 DEBUG DriverManagerConnectionProvider:93 - total checked-out connections: 0
11:08:56,092 DEBUG DriverManagerConnectionProvider:99 - using pooled JDBC connection, pool size: 0
11:08:56,092 DEBUG SQL:324 - insert into PAGE (URL, discriminator, id) values (?, 'html', ?)
Hibernate: insert into PAGE (URL, discriminator, id) values (?, 'html', ?)
11:08:56,092 DEBUG AbstractBatcher:378 - preparing statement
11:08:56,108 DEBUG BasicEntityPersister:1612 - Dehydrating entity: [uk.ac.warwick.sbr.HtmlPageImpl#094d42a0056210d701056210daee0001]
11:08:56,108 DEBUG AbstractBatcher:27 - Adding to batch
11:08:56,124 DEBUG AbstractBatcher:54 - Executing batch size: 1
11:08:56,124 DEBUG AbstractBatcher:298 - about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
11:08:56,124 DEBUG AbstractBatcher:416 - closing statement
11:08:56,124 DEBUG AbstractFlushingEventListener:294 - post flush
11:08:56,124 DEBUG SessionImpl:250 - opened session at timestamp: 4598299591163904
11:08:56,139 DEBUG SessionImpl:829 - find: from AbstractPageImpl p
11:08:56,139 DEBUG QueryParameters:224 - named parameters: {}
11:08:56,249 DEBUG QueryTranslatorImpl:207 - parse() - HQL: from uk.ac.warwick.sbr.AbstractPageImpl p
11:08:56,264 DEBUG AST:223 - --- HQL AST ---
\-[QUERY] 'query'
\-[SELECT_FROM] 'SELECT_FROM'
\-[FROM] 'from'
\-[RANGE] 'RANGE'
+-[DOT] '.'
| +-[DOT] '.'
| | +-[DOT] '.'
| | | +-[DOT] '.'
| | | | +-[IDENT] 'uk'
| | | | \-[IDENT] 'ac'
| | | \-[IDENT] 'warwick'
| | \-[IDENT] 'sbr'
| \-[IDENT] 'AbstractPageImpl'
\-[ALIAS] 'p'

11:08:56,264 DEBUG ErrorCounter:72 - throwQueryException() : no errors
11:08:56,327 DEBUG HqlSqlBaseWalker:120 - query() << begin, level = 1
11:08:56,358 DEBUG FromElement:88 - FromClause{level=1} : uk.ac.warwick.sbr.AbstractPageImpl (p) -> abstractpa0_
11:08:56,358 DEBUG HqlSqlBaseWalker:125 - query() : finishing up , level = 1
11:08:56,358 DEBUG HqlSqlWalker:331 - processQuery() : ( SELECT ( FromClause{level=1} PAGE abstractpa0_ ) )
11:08:56,374 DEBUG HqlSqlWalker:451 - Derived SELECT clause created.
11:08:56,389 DEBUG JoinProcessor:112 - Using FROM fragment [PAGE abstractpa0_]
11:08:56,389 DEBUG HqlSqlBaseWalker:128 - query() >> end, level = 1
11:08:56,389 DEBUG AST:193 - --- SQL AST ---
\-[SELECT] QueryNode: 'SELECT' querySpaces (PAGE)
+-[SELECT_CLAUSE] SelectClause: '{derived select clause}'
| +-[SELECT_EXPR] SelectExpressionImpl: 'abstractpa0_.id as id' {FromElement{explicit,not a collection join,not a fetch join,fetch non-lazy properties,classAlias=p,role=null,tableName=PAGE,tableAlias=abstractpa0_,colums={,className=uk.ac.warwick.sbr.AbstractPageImpl}}}
| \-[SQL_TOKEN] SqlFragment: 'abstractpa0_.URL as URL0_, abstractpa0_.discriminator as discrimi2_'
\-[FROM] FromClause: 'from' FromClause{level=1, fromElementCounter=1, fromElements=1, fromElementByClassAlias=[p], fromElementByTableAlias=[abstractpa0_], fromElementsByPath=[], collectionJoinFromElementsByPath=[], impliedElements=[]}
\-[FROM_FRAGMENT] FromElement: 'PAGE abstractpa0_' FromElement{explicit,not a collection join,not a fetch join,fetch non-lazy properties,classAlias=p,role=null,tableName=PAGE,tableAlias=abstractpa0_,colums={,className=uk.ac.warwick.sbr.AbstractPageImpl}}

11:08:56,389 DEBUG ErrorCounter:72 - throwQueryException() : no errors
11:08:56,421 DEBUG QueryTranslatorImpl:177 - HQL: from uk.ac.warwick.sbr.AbstractPageImpl p
11:08:56,421 DEBUG QueryTranslatorImpl:178 - SQL: select abstractpa0_.id as id, abstractpa0_.URL as URL0_, abstractpa0_.discriminator as discrimi2_ from PAGE abstractpa0_
11:08:56,421 DEBUG ErrorCounter:72 - throwQueryException() : no errors
11:08:56,421 DEBUG AbstractBatcher:290 - about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
11:08:56,421 DEBUG ConnectionManager:296 - opening JDBC connection
11:08:56,436 DEBUG DriverManagerConnectionProvider:93 - total checked-out connections: 1
11:08:56,436 DEBUG DriverManagerConnectionProvider:109 - opening new JDBC connection
11:08:56,436 DEBUG DriverManagerConnectionProvider:115 - created connection to: jdbc:hsqldb:., Isolation Level: 1
11:08:56,436 DEBUG SQL:324 - select abstractpa0_.id as id, abstractpa0_.URL as URL0_, abstractpa0_.discriminator as discrimi2_ from PAGE abstractpa0_
Hibernate: select abstractpa0_.id as id, abstractpa0_.URL as URL0_, abstractpa0_.discriminator as discrimi2_ from PAGE abstractpa0_
11:08:56,436 DEBUG AbstractBatcher:378 - preparing statement
11:08:56,452 DEBUG AbstractBatcher:306 - about to open ResultSet (open ResultSets: 0, globally: 0)
11:08:56,452 DEBUG Loader:405 - processing result set
11:08:56,452 DEBUG Loader:410 - result set row: 0
11:08:56,452 DEBUG Loader:828 - result row: EntityKey[uk.ac.warwick.sbr.AbstractPageImpl#094d42a0056210d701056210daee0001]
11:08:56,452 DEBUG Loader:978 - Initializing object from ResultSet: [uk.ac.warwick.sbr.HtmlPageImpl#094d42a0056210d701056210daee0001]
11:08:56,452 DEBUG BasicEntityPersister:1651 - Hydrating entity: [uk.ac.warwick.sbr.HtmlPageImpl#094d42a0056210d701056210daee0001]
11:08:56,452 DEBUG Loader:429 - done processing result set (1 rows)
11:08:56,452 DEBUG AbstractBatcher:313 - about to close ResultSet (open ResultSets: 1, globally: 1)
11:08:56,452 DEBUG AbstractBatcher:298 - about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
11:08:56,452 DEBUG AbstractBatcher:416 - closing statement
11:08:56,467 DEBUG Loader:528 - total objects hydrated: 1
11:08:56,467 DEBUG TwoPhaseLoad:96 - resolving associations for [uk.ac.warwick.sbr.HtmlPageImpl#094d42a0056210d701056210daee0001]
11:08:56,467 DEBUG TwoPhaseLoad:167 - done materializing entity [uk.ac.warwick.sbr.HtmlPageImpl#094d42a0056210d701056210daee0001]
11:08:56,467 DEBUG PersistenceContext:789 - initializing non-lazy collections
11:08:56,467 DEBUG JDBCContext:322 - after autocommit
11:08:56,467 DEBUG SessionImpl:269 - closing session
11:08:56,467 DEBUG ConnectionManager:317 - closing JDBC connection [ (open PreparedStatements: 0, globally: 0) (open ResultSets: 0, globally: 0)]
11:08:56,467 DEBUG DriverManagerConnectionProvider:129 - returning connection to pool, pool size: 1
11:08:56,467 DEBUG JDBCContext:283 - after transaction completion
11:08:56,467 DEBUG SessionImpl:403 - after transaction completion
11:08:56,483 DEBUG SessionImpl:269 - closing session
11:08:56,483 DEBUG ConnectionManager:317 - closing JDBC connection [ (open PreparedStatements: 0, globally: 0) (open ResultSets: 0, globally: 0)]
11:08:56,483 DEBUG DriverManagerConnectionProvider:129 - returning connection to pool, pool size: 2
11:08:56,483 DEBUG JDBCContext:283 - after transaction completion
11:08:56,483 DEBUG SessionImpl:403 - after transaction completion
11:08:56,483 DEBUG SessionImpl:250 - opened session at timestamp: 4598299592634368
11:08:56,483 DEBUG DefaultLoadEventListener:143 - loading entity: [uk.ac.warwick.sbr.AbstractPageImpl#094d42a0056210d701056210daee0001]
11:08:56,483 DEBUG DefaultLoadEventListener:216 - creating new proxy for entity
11:08:56,499 DEBUG JDBCContext:322 - after autocommit
11:08:56,499 DEBUG SessionImpl:403 - after transaction completion
[/code]

Basically, I have a Page interface which is extended by HtmlPage and BinaryPage. I create an instance of HtmlPageImpl, save it and then execute a query (select * from page) to verify it is there. If I try and load it *whilst it is still in the session* then I get back an object of type HtmlPage. If I close the session and re-open it and load by it's id, I get a freaky class which looks like it is a BinaryPage(!!!) but is actually an instanceof HtmlPage and BinaryPage!

I have an eclipse project of about 4mb which I can post if I knew how.

Many thanks,

Colin


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jul 29, 2005 7:34 am 
CGLIB Developer
CGLIB Developer

Joined: Thu Aug 28, 2003 1:44 pm
Posts: 1217
Location: Vilnius, Lithuania
It is not a cglib bug, try to reproduce cglib bugs cglib unit tests.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jul 29, 2005 7:39 am 
Beginner
Beginner

Joined: Wed May 04, 2005 5:17 am
Posts: 40
The class that is coming back is BinaryPage$ENHANCED_BY_CGLIB (or something like that), and that class is an implementation of both HtmlPage and BinaryPage. I assumed it was a cglib bug because the class is "enhanced by cglib".

Do you have any idea what the bug is, or are you simply shrugging responsibility ;) :)


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jul 29, 2005 9:37 am 
CGLIB Developer
CGLIB Developer

Joined: Thu Aug 28, 2003 1:44 pm
Posts: 1217
Location: Vilnius, Lithuania
This is lazy loading impementation limitation, as I understand there is no solution at this time. You can cast this generated class instance to HibernateProxy to get the real implementation.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jul 29, 2005 9:39 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
No, you should read and understand proxies and their limitations and some workarounds, reference documentation, "Performance" chapter.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jul 29, 2005 10:01 am 
Beginner
Beginner

Joined: Wed May 04, 2005 5:17 am
Posts: 40
Yeah, I did read about CGLIB proxies etc.

I thought that providing an explicit "proxy=interfaceName" in the mapping meant you didn't need to use CGLIB?

I still don't understand why the class that is created needs to implement all possible subclass implementations?

So what is the workaround for this? Is casting to HibernateProxy the only way?


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jul 29, 2005 11:11 am 
CGLIB Developer
CGLIB Developer

Joined: Thu Aug 28, 2003 1:44 pm
Posts: 1217
Location: Vilnius, Lithuania
It is not a trivial problem. Hibernate doe's not know exact entity type before it hits database, if it will hit it then lazy loading will not make any sence.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jul 29, 2005 12:10 pm 
Beginner
Beginner

Joined: Wed May 04, 2005 5:17 am
Posts: 40
I am confused ;)

Surely it has already hit the database because I am doing an explicit session.load and it throws ObjectNotFound if the entity isn't in the database. Is this wrong? Are you saying I turn off lazy-loading of the class (i.e. the instance variables) it will work?

BTW; when I retrieve the object as a result of a query it works fine.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jul 29, 2005 12:22 pm 
Newbie

Joined: Fri Jul 29, 2005 12:03 pm
Posts: 1
baliukas wrote:
This is lazy loading impementation limitation, as I understand there is no solution at this time. You can cast this generated class instance to HibernateProxy to get the real implementation.


by the generated class, do you mean the <classname>$$EnhancerByCGLIB$$<Address> ??

I guess I have two questions about this scenario:

I'm running into issues with running merge() on preexisting objects.

1) when you run a merge on an existing object in session, it returns the EnhancerByCGLIB modified object. are you saying that this object, casted to HibernateProxy will load the object? (with only a bit of testing, it seems like more is needed to actually load the object)

2) are merge() and saveOrUpdate() meant not to be run sequentially? for example: if you don't necessarily know if the object already exists in session you can do something like the following:

Code:
Object mergedObject = hibernateService.merge(sessionBoundObject);
hibernateService.saveOrUpdate(mergedObject);


I hope I'm not missing anything blaringly obvious


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 9 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.