[hibernate-issues] [Hibernate-JIRA] Commented: (HHH-2919) HQL DELETE and map entity mode

Cédric Chantepie (JIRA) noreply at atlassian.com
Mon Oct 29 12:16:38 EDT 2007


    [ http://opensource.atlassian.com/projects/hibernate/browse/HHH-2919?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_28616 ] 

Cédric Chantepie commented on HHH-2919:
---------------------------------------

Doesn't seem to be due to composite-id use, the trouble still occurs with following mapping and test case :

xx.hbm.xml :

  <class entity-name="Test"
    table="test"
    lazy="false">

    <id name="name" column="name" type="string" />

    <property name="value" column="value" type="string" />
  </class>


JUnit test code :

        Map t = null;

        try {
            t = new HashMap(3);

            t.put("name", "Test1");
            t.put("value", "---");

            session.save("Test", t);
        } catch (Exception e) {
            fail(e.getMessage());
        }

        try {
            t = (Map) session.get("Test", "Test1");

            assertNotNull(t);
        } catch (Exception e) {
            fail(e.getMessage());
        }

        try {
            Query q = session.createQuery("DELETE FROM Test t " +
                                          "WHERE t.name = :name");

            q.setString("name", "Test1");

            assertTrue(q.executeUpdate() == 1);

            //WORK:session.delete("Test", (Serializable) t);
        } catch (Exception e) {
            fail(e.getMessage());
        }

        try {
            Map m = (Map) session.get("Test", "Test1");

            assertNull(m);
        } catch (Exception e) {
            fail(e.getMessage());
        }



> HQL DELETE and map entity mode
> ------------------------------
>
>                 Key: HHH-2919
>                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2919
>             Project: Hibernate3
>          Issue Type: Bug
>          Components: caching (L2), core, query-hql
>    Affects Versions: 3.2.5
>         Environment: org.hibernate.transaction.JDBCTransactionFactory as factory_class, postgresql 8.x with postgresql-8.1-407.jdbc3.jar JDBC driver, Linux 2.6.22-gentoo-r8 i686 Pentium III (Coppermine)
>            Reporter: Cédric Chantepie
>
> Cache trouble when deleting object mapped in map mode (dynamic-map) with an HQL DELETE query, where as if deleted with session.delete(...) it works.
> In xxx.hbm.xml :
> <!-- Entity mapping -->
>   <class entity-name="Test"
>     table="test"
>     lazy="false">
>     <composite-id>
>       <key-property name="name" column="name"
>         type="string" />
>       <key-property name="type" column="ptype"
>         type="integer" />
>     </composite-id>
>     <property name="value" column="value" type="string" />
>   </class>
> <!-- endOf Entity mapping -->
> JUnit test code :
>         Map t = null;
>         try {
>             t = new HashMap(3);
>             t.put("name", "Test1");
>             t.put("type", new Integer(2));
>             t.put("value", "---");
>             session.save("Test", t);
>         } catch (Exception e) {
>             fail(e.getMessage());
>         }
>         try {
>             t = (Map) session.get("Test", (Serializable) t);
>             assertNotNull(t);
>         } catch (Exception e) {
>             fail(e.getMessage());
>         }
>         try {
>             Query q = session.createQuery("DELETE FROM Test t " +
>                                           "WHERE t.name = :name");
>             q.setString("name", "Test1");
>             assertTrue(q.executeUpdate() == 1);
>             //WORK:session.delete("Test", (Serializable) t);
>         } catch (Exception e) {
>             fail(e.getMessage());
>         }
>         try {
>             Map m = (Map) session.get("Test", (Serializable) t);
>             assertNull(m); // fails here, find the deleted object, no ObjectDeletedException
>         } catch (Exception e) {
>             fail(e.getMessage());
>         }
> Maybe that due to composite-id and hashCode/equals support in map mode, maybe cache is not notified of objects deleted by HQL in this map mode.

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

       




More information about the hibernate-issues mailing list