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.  [ 1 post ] 
Author Message
 Post subject: Hibernate <any> audit history mapping
PostPosted: Tue Oct 21, 2008 5:52 pm 
Newbie

Joined: Tue Oct 21, 2008 4:13 pm
Posts: 3
Hibernate version: 3.2


Name and version of the database you are using: SQLServer Express


Hi,

I am trying to create an audit history mapping like so in my AuditRecord Mapping file:
Code:
   <any id-type="java.lang.Integer" meta-type="java.lang.String"
         name="entityAuditRecord" >
         <meta-value
            class="model.Balance"
            value="Balance" />
         <column name="ENTITY_NAME" />
         <column name="ENTITY_ID" />
      </any>

In Balance's Mapping file I have the following:
Code:
<one-to-one name="entityAuditRecord"
         class="model.EntityAuditRecord"
         />

(EntityAuditRecord extends the AuditRecord class)

Ideally I would like to be able to call the following code to get the corresponding audit message.
Code:
balance.getEntityAuditRecord().getAuditMessage()


The issue I am having at the moment is that I can't set ENTITY_NAME and ENTITY_ID in the Hibernate interceptor. I created the corresponding fields and getters and setters in the AuditRecord class, however these don't seem to get persisted to the database. I then tried creating a property for each, but Hibernate complained that the column was defined twice. As far as I can tell the correct SQL is generated, however the values are not set.

I have yet to test getting audit messages as above, and would like feedback on this too as I can't find any information for bidirectional <any> mappings.
My next alternative would be to create a BalanceAuditRecord mapping table which gets populated dynamically (by class name) in the interceptor.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.