-->
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.  [ 30 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: Cache bug in 2.1.3 ??
PostPosted: Tue Jun 01, 2004 10:35 am 
Pro
Pro

Joined: Mon Sep 08, 2003 4:30 pm
Posts: 203
Hi All,

Maps:

Code:
<hibernate-mapping>
   <!-- com.diatem.db.qos.ViewContainer root -->
   <class name="com.cache.test.ViewContainer" table="viewc">
      <cache usage="read-write" />
      <id name="id" type="long" column="id" unsaved-value="0">
         <generator class="native"/>
      </id>
      <property name="name" column="name" type="string" not-null="true" unique="true"/>

        <set name="neTemplates" inverse="true" cascade="all-delete-orphan" lazy="false">
        <cache usage="read-write" />
         <key column="view_ne_template"/>
         <one-to-many class="com.cache.test.NetworkElementTemplate"/>
        </set>

   </class>
   

</hibernate-mapping>

<hibernate-mapping default-cascade="none" auto-import="true" default-access="field">
    <class name="com.cache.test.NetworkElementTemplate" table="ne_tmpl" mutable="true" polymorphism="implicit" dynamic-update="false" dynamic-insert="false">
      <cache usage="read-write"/>
      <id name="id" type="long" unsaved-value="0">
         <generator class="native">
         </generator>
      </id>
      <property name="creationUser" column="creationUser" type="string"/>
      <property name="modificationUser" column="modificationUser" type="string"/>
      <property name="lastModified" column="lastModified" type="timestamp"/>
      <property name="creationTime" column="creationTime" type="timestamp"/>

        <property name="name" type="string"/>
        <property name="description" type="string"/>
       
      <many-to-one name="view" column="view_ne_template" class="com.cache.test.ViewContainer"/>
    </class>

</hibernate-mapping>

and code:

Code:
   private void initHibernate() throws HibernateException {

      // Load Configuration and build SessionFactory
      Configuration cfg = new Configuration();
      sessionFactory = cfg.configure().buildSessionFactory();
      new SchemaExport(cfg).create(true, true);
      //new SchemaUpdate(cfg).execute(true, true);
   }

   private void go() throws HibernateException{

      initHibernate();
      populateDb();


      beginTransaction();
      ViewContainer[] views = getViews();
      endTransaction(false);

      beginTransaction();
      NetworkElementTemplate t1 =
         (NetworkElementTemplate) session.load(
            NetworkElementTemplate.class,
            new Long(5));
      endTransaction(false);

      beginTransaction();
      session.delete(t1);
      endTransaction(true);
      System.out.println("<<<<<<<<Deleted succesfully>>>>>>>>>");

      beginTransaction();
      views = getViews();
      endTransaction(false);


      System.out.println(views);

   }

   private void beginTransaction() throws HibernateException {

      session = sessionFactory.openSession();
      transaction = session.beginTransaction();
   }

   private void endTransaction(boolean commit) throws HibernateException {

      if (commit) {
         transaction.commit();
      } else {
         // Don't commit the transaction, can be faster for read-only operations
         transaction.rollback();
      }
      session.close();
   }

   public ViewContainer[] getViews() {
      Query q = null;
      List newList = null;
      try {
         q =
            session.createQuery(
               "from viewc in class com.cache.test.ViewContainer");
         newList = q.list();
      } catch (HibernateException e) {
         System.out.println("<<<<<<<getViews failed !!!>>>>>>>>");
         e.printStackTrace();
         System.exit(1);
      }

      ViewContainer[] views = new ViewContainer[newList.size()];
      for (int i = 0; i < newList.size(); ++i) {
         views[i] = (ViewContainer) newList.get(i);
      }

      System.out.println("<<<<<<<<<getViews OK.>>>>>>>>");
      return views;
   }

   private void populateDb() throws HibernateException{
      // add some stuff in the db ( 1 view + set of templates )
      ViewContainer view = new ViewContainer();
      view.setName("view1");
      view.setNeTemplates(new HashSet());
      for (int i = 0; i < 20; ++i) {
         NetworkElementTemplate t = new NetworkElementTemplate();
         t.setName("t_" + i);
         view.getNeTemplates().add(t);
         t.setView(view);
      }

      beginTransaction();
      session.save(view);
      endTransaction(true);
   }


output:

Code:
10:32:02,408  INFO Environment:462 - Hibernate 2.1.3
10:32:02,424  INFO Environment:496 - loaded properties from resource hibernate.properties: {hibernate.connection.driver_class=com.mysql.jdbc.Driver, hibernate.jdbc.fetch_size=0, hibernate.cglib.use_reflection_optimizer=true, hibernate.cache.provider_class=net.sf.ehcache.hibernate.Provider, hibernate.cache.use_query_cache=true , hibernate.dialect=net.sf.hibernate.dialect.MySQLDialect, hibernate.jdbc.use_streams_for_binary=true, hibernate.jdbc.batch_size=0, hibernate.query.substitutions=true 1, false 0, yes 'Y', no 'N', hibernate.query.imports=net.sf.hibernate.test, net.sf.hibernate.eg, hibernate.use_outer_join=false, hibernate.proxool.pool_alias=pool1, hibernate.connection.username=admin, hibernate.jdbc.use_scrollable_resultset=true, hibernate.connection.url=jdbc:mysql:///test1, hibernate.show_sql=true, hibernate.connection.password=}
10:32:02,424  INFO Environment:518 - using java.io streams to persist binary types
10:32:02,424  INFO Environment:519 - using CGLIB reflection optimizer
10:32:02,440  INFO Configuration:872 - configuring from resource: /hibernate.cfg.xml
10:32:02,440  INFO Configuration:844 - Configuration resource: /hibernate.cfg.xml
10:32:02,893  INFO Configuration:328 - Mapping resource: com/cache/test/NetworkElementTemplate.hbm.xml
10:32:03,049  INFO Binder:229 - Mapping class: com.cache.test.NetworkElementTemplate -> ne_tmpl
10:32:03,158  INFO Configuration:328 - Mapping resource: com/cache/test/QoSAll.hbm.xml
10:32:03,190  INFO Binder:229 - Mapping class: com.cache.test.ViewContainer -> viewc
10:32:03,205  INFO Configuration:1030 - Configured SessionFactory: null
10:32:03,205  INFO Configuration:613 - processing one-to-many association mappings
10:32:03,205  INFO Binder:1168 - Mapping collection: com.cache.test.ViewContainer.neTemplates -> ne_tmpl
10:32:03,205  INFO Configuration:622 - processing one-to-one association property references
10:32:03,221  INFO Configuration:647 - processing foreign key constraints
10:32:03,237  INFO Dialect:82 - Using dialect: net.sf.hibernate.dialect.MySQLDialect
10:32:03,252  INFO SettingsFactory:55 - JDBC result set fetch size: 0
10:32:03,252  INFO SettingsFactory:62 - Use outer join fetching: false
10:32:03,252  INFO DriverManagerConnectionProvider:42 - Using Hibernate built-in connection pool (not for production use!)
10:32:03,252  INFO DriverManagerConnectionProvider:43 - Hibernate connection pool size: 20
10:32:03,268  INFO DriverManagerConnectionProvider:77 - using driver: com.mysql.jdbc.Driver at URL: jdbc:mysql:///test1
10:32:03,268  INFO DriverManagerConnectionProvider:78 - connection properties: {user=admin, password=}
10:32:03,283  INFO TransactionManagerLookupFactory:33 - No TransactionManagerLookup configured (in JTA environment, use of process level read-write cache is not recommended)
10:32:03,533  INFO SettingsFactory:102 - Use scrollable result sets: true
10:32:03,533  INFO SettingsFactory:105 - Use JDBC3 getGeneratedKeys(): true
10:32:03,533  INFO SettingsFactory:108 - Optimize cache for minimal puts: false
10:32:03,533  INFO SettingsFactory:114 - echoing all SQL to stdout
10:32:03,533  INFO SettingsFactory:117 - Query language substitutions: {no='N', true=1, yes='Y', false=0}
10:32:03,533  INFO SettingsFactory:128 - cache provider: net.sf.ehcache.hibernate.Provider
10:32:03,549  INFO Configuration:1093 - instantiating and configuring caches
10:32:03,596  WARN Plugin:95 - Could not find configuration for com.cache.test.ViewContainer.neTemplates. Configuring using the defaultCache settings.
10:32:03,612  WARN Plugin:95 - Could not find configuration for com.cache.test.NetworkElementTemplate. Configuring using the defaultCache settings.
10:32:03,612  WARN Plugin:95 - Could not find configuration for com.cache.test.ViewContainer. Configuring using the defaultCache settings.
10:32:03,737  INFO SessionFactoryImpl:119 - building session factory
10:32:04,112  INFO SessionFactoryObjectFactory:82 - no JNDI name configured
10:32:04,112  INFO Dialect:82 - Using dialect: net.sf.hibernate.dialect.MySQLDialect
10:32:04,112  INFO Configuration:613 - processing one-to-many association mappings
10:32:04,112  INFO Configuration:622 - processing one-to-one association property references
10:32:04,112  INFO Configuration:647 - processing foreign key constraints
10:32:04,112  INFO Configuration:613 - processing one-to-many association mappings
10:32:04,112  INFO Configuration:622 - processing one-to-one association property references
10:32:04,112  INFO Configuration:647 - processing foreign key constraints
10:32:04,127  INFO SchemaExport:98 - Running hbm2ddl schema export
10:32:04,127  INFO SchemaExport:117 - exporting generated schema to database
10:32:04,127  INFO DriverManagerConnectionProvider:42 - Using Hibernate built-in connection pool (not for production use!)
10:32:04,127  INFO DriverManagerConnectionProvider:43 - Hibernate connection pool size: 20
10:32:04,127  INFO DriverManagerConnectionProvider:77 - using driver: com.mysql.jdbc.Driver at URL: jdbc:mysql:///test1
10:32:04,127  INFO DriverManagerConnectionProvider:78 - connection properties: {user=admin, password=}
drop table if exists ne_tmpl
drop table if exists viewc
create table ne_tmpl (
   id BIGINT NOT NULL AUTO_INCREMENT,
   creationUser VARCHAR(255),
   modificationUser VARCHAR(255),
   lastModified DATETIME,
   creationTime DATETIME,
   name VARCHAR(255),
   description VARCHAR(255),
   view_ne_template BIGINT,
   primary key (id)
)
create table viewc (
   id BIGINT NOT NULL AUTO_INCREMENT,
   name VARCHAR(255) not null unique,
   primary key (id)
)
alter table ne_tmpl add index (view_ne_template), add constraint FK6CB807BDBC6E3768 foreign key (view_ne_template) references viewc (id)
10:32:04,315  INFO SchemaExport:160 - schema export complete
10:32:04,315  INFO DriverManagerConnectionProvider:143 - cleaning up connection pool: jdbc:mysql:///test1
Hibernate: insert into viewc (name) values (?)
Hibernate: insert into ne_tmpl (creationUser, modificationUser, lastModified, creationTime, name, description, view_ne_template) values (?, ?, ?, ?, ?, ?, ?)
Hibernate: insert into ne_tmpl (creationUser, modificationUser, lastModified, creationTime, name, description, view_ne_template) values (?, ?, ?, ?, ?, ?, ?)
Hibernate: insert into ne_tmpl (creationUser, modificationUser, lastModified, creationTime, name, description, view_ne_template) values (?, ?, ?, ?, ?, ?, ?)
Hibernate: insert into ne_tmpl (creationUser, modificationUser, lastModified, creationTime, name, description, view_ne_template) values (?, ?, ?, ?, ?, ?, ?)
Hibernate: insert into ne_tmpl (creationUser, modificationUser, lastModified, creationTime, name, description, view_ne_template) values (?, ?, ?, ?, ?, ?, ?)
Hibernate: select viewc.id as id, viewc.name as name from viewc viewc
Hibernate: select netemplate0_.id as id__, netemplate0_.view_ne_template as view_ne_8___, netemplate0_.id as id0_, netemplate0_.creationUser as creation2_0_, netemplate0_.modificationUser as modifica3_0_, netemplate0_.lastModified as lastModi4_0_, netemplate0_.creationTime as creation5_0_, netemplate0_.name as name0_, netemplate0_.description as descript7_0_, netemplate0_.view_ne_template as view_ne_8_0_ from ne_tmpl netemplate0_ where netemplate0_.view_ne_template=?
<<<<<<<<<getViews OK.>>>>>>>>
Hibernate: delete from ne_tmpl where id=?
<<<<<<<<Deleted succesfully>>>>>>>>>
Hibernate: select viewc.id as id, viewc.name as name from viewc viewc
Hibernate: select networkele0_.id as id0_, networkele0_.creationUser as creation2_0_, networkele0_.modificationUser as modifica3_0_, networkele0_.lastModified as lastModi4_0_, networkele0_.creationTime as creation5_0_, networkele0_.name as name0_, networkele0_.description as descript7_0_, networkele0_.view_ne_template as view_ne_8_0_ from ne_tmpl networkele0_ where networkele0_.id=?
<<<<<<<getViews failed !!!>>>>>>>>
net.sf.hibernate.UnresolvableObjectException: No row with the given identifier exists: 2, of class: com.cache.test.NetworkElementTemplate
   at net.sf.hibernate.UnresolvableObjectException.throwIfNull(UnresolvableObjectException.java:38)
   at net.sf.hibernate.impl.SessionImpl.internalLoad(SessionImpl.java:1943)
   at net.sf.hibernate.type.ManyToOneType.resolveIdentifier(ManyToOneType.java:68)
   at net.sf.hibernate.type.EntityType.assemble(EntityType.java:130)
   at net.sf.hibernate.collection.Set.initializeFromCache(Set.java:92)
   at net.sf.hibernate.impl.SessionImpl.initializeCollectionFromCache(SessionImpl.java:3954)
   at net.sf.hibernate.impl.SessionImpl.initializeCollection(SessionImpl.java:3253)
   at net.sf.hibernate.collection.PersistentCollection.forceInitialization(PersistentCollection.java:336)
   at net.sf.hibernate.impl.SessionImpl.initializeNonLazyCollections(SessionImpl.java:3114)
   at net.sf.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:138)
   at net.sf.hibernate.loader.Loader.doList(Loader.java:955)
   at net.sf.hibernate.loader.Loader.list(Loader.java:946)
   at net.sf.hibernate.hql.QueryTranslator.list(QueryTranslator.java:834)
   at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1536)
   at net.sf.hibernate.impl.QueryImpl.list(QueryImpl.java:39)
   at com.cache.test.CacheTest.getViews(CacheTest.java:94)
   at com.cache.test.CacheTest.go(CacheTest.java:62)
   at com.cache.test.CacheTest.main(CacheTest.java:27)


If I remove the

Code:
  <cache usage="read-write" />

from

Code:
<set name="neTemplates" inverse="true" cascade="all-delete-orphan" lazy="false">
        <cache usage="read-write" />
         <key column="view_ne_template"/>
         <one-to-many class="com.cache.test.NetworkElementTemplate"/>
        </set>


everything works !

TIA.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jun 02, 2004 7:57 am 
Pro
Pro

Joined: Mon Sep 08, 2003 4:30 pm
Posts: 203
Please, could someone confirm if this is a bug or just me doing something wrong?

I would really appreciate.

Thank you so much.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 03, 2004 9:35 am 
Pro
Pro

Joined: Mon Sep 08, 2003 4:30 pm
Posts: 203
I tried with 2.1.4 and still having the error.

Please advice.

Thank you again.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jun 04, 2004 2:06 pm 
Pro
Pro

Joined: Mon Sep 08, 2003 4:30 pm
Posts: 203
Could anyone give an advice for my problem?

Maybe someone from the Hibernate team?

Thanks again.


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jun 05, 2004 2:30 pm 
Pro
Pro

Joined: Mon Sep 08, 2003 4:30 pm
Posts: 203
...still hoping for an answer, after 4 posts ...


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jun 05, 2004 3:28 pm 
Hibernate Team
Hibernate Team

Joined: Thu Dec 18, 2003 9:55 am
Posts: 1977
Location: France
have you upgraded all jars?
Are you 100% of your test?

_________________
Anthony,
Get value thanks to your skills: http://www.redhat.com/certification


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jun 05, 2004 6:57 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
I find it incredibly difficult to believe that this could be a bug. Use your debugger,


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jun 06, 2004 9:43 am 
Pro
Pro

Joined: Mon Sep 08, 2003 4:30 pm
Posts: 203
anthony wrote:
have you upgraded all jars?
Are you 100% of your test?


Yes, I have repeated this simple test with 2.1.4 and same result.

I was hoping that someone from Hibernate team could try my scenario to confirm it.

thank you.


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jun 06, 2004 10:44 am 
Hibernate Team
Hibernate Team

Joined: Thu Dec 18, 2003 9:55 am
Posts: 1977
Location: France
if you want someone from the dream team to test it, submit a jira with your classes and bdd scripts.

But seeing what gavin think about it, the but must not be in hibernate or ehcache core...

try jira, you'll see if hibernate team take time to test it.

_________________
Anthony,
Get value thanks to your skills: http://www.redhat.com/certification


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jun 06, 2004 8:17 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Negative. Do not create an issue in JIRA until you have found the cause yourself, by using your debugger.


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jun 06, 2004 9:00 pm 
Pro
Pro

Joined: Mon Sep 08, 2003 4:30 pm
Posts: 203
anthony wrote:
if you want someone from the dream team to test it, submit a jira with your classes and bdd scripts.

But seeing what gavin think about it, the but must not be in hibernate or ehcache core...

try jira, you'll see if hibernate team take time to test it.


OK, if the Hibernate team is too busy to test it, maybe someone from the community could test this _very_ simple scenario to confirm/not confirm the problem?

'Cause I think it is much more simple/reasonable to test a _very_ simple case than using the debugger and step thru the code and understand it, as Gavin suggests.

Thanks to everybody.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jun 07, 2004 3:19 pm 
Pro
Pro

Joined: Mon Sep 08, 2003 4:30 pm
Posts: 203
Here's an excerpt of what happens after I delete the NetworkElementTemplate object (id#2)

Hibernate: delete from ne_tmpl where id=?
15:07:40,966 DEBUG BatcherImpl:241 - preparing statement
15:07:40,966 DEBUG LongType:46 - binding '2' to parameter: 1
15:07:40,966 DEBUG BatcherImpl:203 - done closing: 0 open PreparedStatements, 0 open ResultSets
15:07:40,966 DEBUG BatcherImpl:261 - closing statement
15:07:40,966 DEBUG SessionImpl:3440 - post flush
15:07:40,966 DEBUG SessionImpl:619 - transaction completion
15:07:40,966 DEBUG ReadWriteCache:178 - Releasing: 2
15:07:40,966 DEBUG SessionImpl:608 - closing session
15:07:40,966 DEBUG SessionImpl:4057 - disconnecting session
15:07:40,966 DEBUG DriverManagerConnectionProvider:120 - returning connection to pool, pool size: 1
15:07:40,966 DEBUG SessionImpl:619 - transaction completion
<<<<<<<<Deleted succesfully>>>>>>>>>
15:07:40,966 DEBUG SessionImpl:590 - opened session
15:07:40,966 DEBUG JDBCTransaction:37 - begin
15:07:40,982 DEBUG DriverManagerConnectionProvider:84 - total checked-out connections: 0
15:07:40,982 DEBUG DriverManagerConnectionProvider:90 - using pooled JDBC connection, pool size: 0
15:07:40,982 DEBUG JDBCTransaction:41 - current autocommit status:false
15:07:40,982 DEBUG SessionImpl:1774 - find: from viewc in class com.cache.test.ViewContainer
15:07:40,982 DEBUG QueryParameters:109 - named parameters: {}
15:07:40,982 DEBUG SessionImpl:2732 - flushing session
15:07:40,982 DEBUG SessionImpl:2950 - Flushing entities and processing referenced collections
15:07:40,982 DEBUG SessionImpl:3383 - Processing unreferenced collections
15:07:40,982 DEBUG SessionImpl:3397 - Scheduling collection removes/(re)creates/updates
15:07:40,982 DEBUG SessionImpl:2755 - Flushed: 0 insertions, 0 updates, 0 deletions to 0 objects
15:07:40,982 DEBUG SessionImpl:2765 - Flushed: 0 (re)creations, 0 updates, 0 removals to 0 collections
15:07:40,982 DEBUG SessionImpl:2128 - Dont need to execute flush
15:07:40,982 DEBUG QueryTranslator:199 - HQL: from viewc in class com.cache.test.ViewContainer
15:07:40,982 DEBUG QueryTranslator:200 - SQL: select viewc.id as id, viewc.name as name from viewc viewc
15:07:40,982 DEBUG BatcherImpl:196 - about to open: 0 open PreparedStatements, 0 open ResultSets
15:07:40,982 DEBUG SQL:237 - select viewc.id as id, viewc.name as name from viewc viewc
Hibernate: select viewc.id as id, viewc.name as name from viewc viewc
15:07:40,982 DEBUG BatcherImpl:241 - preparing statement
15:07:40,997 DEBUG Loader:197 - processing result set
15:07:40,997 DEBUG SessionImpl:4110 - running Session.finalize()
15:07:40,997 DEBUG LongType:68 - returning '1' as column: id
15:07:40,997 DEBUG Loader:405 - result row: 1
15:07:40,997 DEBUG Loader:536 - Initializing object from ResultSet: 1
15:07:40,997 DEBUG Loader:605 - Hydrating entity: com.cache.test.ViewContainer#1
15:07:40,997 DEBUG StringType:68 - returning 'view1' as column: name
15:07:40,997 DEBUG Loader:226 - done processing result set (1 rows)
15:07:40,997 DEBUG BatcherImpl:203 - done closing: 0 open PreparedStatements, 0 open ResultSets
15:07:40,997 DEBUG BatcherImpl:261 - closing statement
15:07:40,997 DEBUG Loader:239 - total objects hydrated: 1
15:07:40,997 DEBUG SessionImpl:2665 - resolving associations for [com.cache.test.ViewContainer#1]
15:07:40,997 DEBUG SessionImpl:4782 - creating collection wrapper:[com.cache.test.ViewContainer.neTemplates#1]
15:07:40,997 DEBUG SessionImpl:2685 - adding entity to second-level cache [com.cache.test.ViewContainer#1]
15:07:40,997 DEBUG ReadWriteCache:132 - Caching: 1
15:07:40,997 DEBUG ReadWriteCache:152 - Item was already cached: 1
15:07:40,997 DEBUG SessionImpl:2709 - done materializing entity [com.cache.test.ViewContainer#1]
15:07:40,997 DEBUG SessionImpl:3796 - initializing non-lazy collections
15:07:41,013 DEBUG SessionImpl:3965 - initializing collection [com.cache.test.ViewContainer.neTemplates#1]
15:07:41,013 DEBUG SessionImpl:3970 - checking second-level cache
15:07:41,013 DEBUG ReadWriteCache:68 - Cache lookup: 1
15:07:41,013 DEBUG ReadWriteCache:78 - Cache hit: 1
15:07:41,013 DEBUG SessionImpl:2353 - loading [com.cache.test.NetworkElementTemplate#3]
15:07:41,013 DEBUG SessionImpl:2477 - attempting to resolve [com.cache.test.NetworkElementTemplate#3]
15:07:41,013 DEBUG ReadWriteCache:68 - Cache lookup: 3
15:07:41,013 DEBUG ReadWriteCache:78 - Cache hit: 3
15:07:41,013 DEBUG SessionImpl:2543 - resolved object in second-level cache [com.cache.test.NetworkElementTemplate#3]
15:07:41,013 DEBUG SessionImpl:2353 - loading [com.cache.test.ViewContainer#1]
15:07:41,013 DEBUG SessionImpl:2477 - attempting to resolve [com.cache.test.ViewContainer#1]
15:07:41,013 DEBUG SessionImpl:2499 - resolved object in session cache [com.cache.test.ViewContainer#1]
15:07:41,013 DEBUG SessionImpl:2575 - Cached Version: null
15:07:41,013 DEBUG SessionImpl:2353 - loading [com.cache.test.NetworkElementTemplate#2]
15:07:41,013 DEBUG SessionImpl:2477 - attempting to resolve [com.cache.test.NetworkElementTemplate#2]
15:07:41,013 DEBUG ReadWriteCache:68 - Cache lookup: 2
15:07:41,013 DEBUG ReadWriteCache:87 - Cached item was locked: 2
15:07:41,013 DEBUG SessionImpl:2521 - object not resolved in any cache [com.cache.test.NetworkElementTemplate#2]
15:07:41,013 DEBUG EntityPersister:416 - Materializing entity: [com.cache.test.NetworkElementTemplate#2]
15:07:41,029 DEBUG BatcherImpl:196 - about to open: 0 open PreparedStatements, 0 open ResultSets
15:07:41,029 DEBUG SQL:237 - select networkele0_.id as id0_, networkele0_.creationUser as creation2_0_, networkele0_.modificationUser as modifica3_0_, networkele0_.lastModified as lastModi4_0_, networkele0_.creationTime as creation5_0_, networkele0_.name as name0_, networkele0_.description as descript7_0_, networkele0_.view_ne_template as view_ne_8_0_ from ne_tmpl networkele0_ where networkele0_.id=?
Hibernate: select networkele0_.id as id0_, networkele0_.creationUser as creation2_0_, networkele0_.modificationUser as modifica3_0_, networkele0_.lastModified as lastModi4_0_, networkele0_.creationTime as creation5_0_, networkele0_.name as name0_, networkele0_.description as descript7_0_, networkele0_.view_ne_template as view_ne_8_0_ from ne_tmpl networkele0_ where networkele0_.id=?
15:07:41,029 DEBUG BatcherImpl:241 - preparing statement
15:07:41,029 DEBUG LongType:46 - binding '2' to parameter: 1
15:07:41,029 DEBUG Loader:197 - processing result set
15:07:41,029 DEBUG Loader:226 - done processing result set (0 rows)
15:07:41,044 DEBUG BatcherImpl:203 - done closing: 0 open PreparedStatements, 0 open ResultSets
15:07:41,044 DEBUG BatcherImpl:261 - closing statement
15:07:41,044 DEBUG Loader:239 - total objects hydrated: 0
<<<<<<<getViews failed !!!>>>>>>>>
net.sf.hibernate.UnresolvableObjectException: No row with the given identifier exists: 2, of class: com.cache.test.NetworkElementTemplate
at net.sf.hibernate.UnresolvableObjectException.throwIfNull(UnresolvableObjectException.java:38)
at net.sf.hibernate.impl.SessionImpl.internalLoad(SessionImpl.java:2311)
at net.sf.hibernate.type.ManyToOneType.resolveIdentifier(ManyToOneType.java:69)
at net.sf.hibernate.type.ManyToOneType.assemble(ManyToOneType.java:108)
at net.sf.hibernate.collection.Set.initializeFromCache(Set.java:93)
at net.sf.hibernate.impl.SessionImpl.initializeCollectionFromCache(SessionImpl.java:4818)
at net.sf.hibernate.impl.SessionImpl.initializeCollection(SessionImpl.java:3972)
at net.sf.hibernate.collection.PersistentCollection.forceInitialization(PersistentCollection.java:336)
at net.sf.hibernate.impl.SessionImpl.initializeNonLazyCollections(SessionImpl.java:3805)
at net.sf.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:138)
at net.sf.hibernate.loader.Loader.doList(Loader.java:955)
at net.sf.hibernate.loader.Loader.list(Loader.java:946)
at net.sf.hibernate.hql.QueryTranslator.list(QueryTranslator.java:846)
at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1792)
at net.sf.hibernate.impl.QueryImpl.list(QueryImpl.java:39)
at com.cache.test.CacheTest.getViews(CacheTest.java:98)
at com.cache.test.CacheTest.go(CacheTest.java:67)
at com.cache.test.CacheTest.main(CacheTest.java:32)

It can be easily observed that Hibernate tries to load the deleted object:

...........
15:07:41,013 DEBUG SessionImpl:2477 - attempting to resolve [com.cache.test.NetworkElementTemplate#2]
15:07:41,013 DEBUG ReadWriteCache:68 - Cache lookup: 2
15:07:41,013 DEBUG ReadWriteCache:87 - Cached item was locked: 2
15:07:41,013 DEBUG SessionImpl:2521 - object not resolved in any cache [com.cache.test.NetworkElementTemplate#2]
...........

why?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jun 07, 2004 6:17 pm 
Pro
Pro

Joined: Mon Sep 08, 2003 4:30 pm
Posts: 203
Firing up the debugger I found that the deleted entry (#2) is never deleted from the cache.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jun 07, 2004 6:19 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
I doubt that. If it was never removed from the cache, then Hibernate would be able to find it, and no ObjectNotFoundException would occur.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jun 07, 2004 6:23 pm 
Pro
Pro

Joined: Mon Sep 08, 2003 4:30 pm
Posts: 203
I have spent all the day tracing thru Hibernate code. I think on my side I did whatever was possible.

All I asked someone from Hibernate team for is to test this simple scenario and confirm if it is or not a bug.

Am I absurd? Sorry ...


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

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.