[hibernate-issues] [Hibernate-JIRA] Commented: (HHH-2919) HQL DELETE and map entity mode
Cédric Chantepie (JIRA)
noreply at atlassian.com
Mon Oct 29 13:14:38 EDT 2007
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-2919?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_28619 ]
Cédric Chantepie commented on HHH-2919:
---------------------------------------
Try with following property in .cfg.xml, does not fix this issue :
<property name="hibernate.cache.use_second_level_cache">false</property>
> 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