-->
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.  [ 3 posts ] 
Author Message
 Post subject: mutable=false ignored after upgrade from 3.0.5 to 3.2.2
PostPosted: Tue Feb 20, 2007 1:03 pm 
Newbie

Joined: Tue Feb 20, 2007 12:38 pm
Posts: 2
Using Hibernate 3.05, a class with <class ... mutable="false" ... > properly threw on any attempt to delete instances of that class from the database via Hibernate.

After upgrading to Hibernate 3.2.2, Hibernate allows deletion of class instances.

What am I (or, less likely, is Hibernate) doing wrong?

Thanks,
Tom

Code fragment:
Code:
        final AuditRecord record = new AuditRecord();
        // setting of object properties elided
        System.out.println("saving");
        dao.save(record);

        assertThat(record.getPrimaryKey(), NOT_NULL);
       
        System.out.println("removing");
        try {
            dao.remove(record);
            // In Hibernate 3.0.5, an exception is raised here.
            // In Hibernate 3.2.2, the instance is deleted
            fail("Should raise exception on attempt to delete an AuditRecord.");
        }
        catch (final Exception e) {
            assertThat(e.getMessage(), NOT_NULL);
        }


Code in dao.remove() method (extending Spring's HibernateDaoSupport):
Code:
    public void remove(final Object object) {
        getHibernateTemplate().delete(object);
    }


Hibernate version: 3.2.2

Mapping documents: (fragment)
Code:
    <class
        name="com.foo.audit.model.AuditRecord"
        table="audit_record"
        mutable="false"
    >

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

Full stack trace of any exception that occurs:
No exception occurs; this is the problem. ;)

Name and version of the database you are using:
MySQL 5.0

The generated SQL (show_sql=true):
[junit] saving
[junit] Hibernate: insert into audit_record (entity_class, entity_id, event_time, event_type, username, entity_version) values (?, ?, ?, ?, ?, ?)
[junit] Hibernate: insert into audit_record_state (audit_record_id, property_name, property_value) values (?, ?, ?)
[junit] Hibernate: insert into audit_record_state (audit_record_id, property_name, property_value) values (?, ?, ?)
[junit] removing
[junit] Hibernate: delete from audit_record_state where audit_record_id=?
[junit] Hibernate: delete from audit_record where id=?
[junit] Hibernate: select auditrecor0_.id as id5_0_, auditrecor0_.entity_class as entity2_5_0_, auditrecor0_.entity_id as entity3_5_0_, auditrecor0_.event_time as event4_5_0_, auditrecor0_.event_type as event5_5_0_, auditrecor0_.username as username5_0_, auditrecor0_.entity_version as entity7_5_0_ from audit_record auditrecor0_ where auditrecor0_.id=?
[junit] Hibernate: select state0_.audit_record_id as audit1_0_, state0_.property_value as property2_0_, state0_.property_name as property3_0_ from audit_record_state state0_ where state0_.audit_record_id=?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Feb 20, 2007 2:00 pm 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
Not-mutable means you can't update it, not that you can't delete it.

_________________
JAVA PERSISTENCE WITH HIBERNATE
http://jpwh.org
Get the book, training, and consulting for your Hibernate team.


Top
 Profile  
 
 Post subject: Thnaks.
PostPosted: Tue Feb 20, 2007 3:12 pm 
Newbie

Joined: Tue Feb 20, 2007 12:38 pm
Posts: 2
Thanks. That does explain it, although not why deletion was prevented in 3.0.5. (Was there an explicit change in behavior? It's not noted, so far as I grepped, in the upgrade docs.)


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