-->
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.  [ 4 posts ] 
Author Message
 Post subject: @Audited annotation in Hibernate hbm file
PostPosted: Thu Jan 13, 2011 3:23 am 
Newbie

Joined: Mon Jan 03, 2011 3:53 am
Posts: 3
Hi All,

I am using Hibernate as my orm in my application.

Now I want to integrate it with Envers. At present I am generating entity using hbm files. In that case how can I mention in hbm file that generate class must have @Audited annotation.

Thanks,
jason


Top
 Profile  
 
 Post subject: Re: @Audited annotation in Hibernate hbm file
PostPosted: Thu Jan 13, 2011 7:21 am 
Senior
Senior

Joined: Fri May 08, 2009 12:27 pm
Posts: 168
Is this a reverse engineering issue? Then this sounds like an issue for the Tools subforum.

Short answer: You'll have to modify a template. You'll also have to signal the template whether to add that annotation or not, probably by adding a <meta> tag to the table in reveng.xml.
The basic procedure isn't difficult, but the docs tend to get a bit imprecise or incomplete around such stuff, and it's not always easy to get the attention of an expert. (My expertise isn't enough for the details, witness the "probably" in the paragraph above.)

UPDATE: I'm a bit surprised that you use a combination of hbm and annotations. My experience has been that you can have either one or the other.


Top
 Profile  
 
 Post subject: Re: @Audited annotation in Hibernate hbm file
PostPosted: Thu Jan 13, 2011 9:01 am 
Newbie

Joined: Mon Jan 03, 2011 3:53 am
Posts: 3
I am using Hibernate Envers for auditing purpose. At present my classes are generated by using hbm files. For using Envers the class must be annoted as @Audited.

Like belwo one

Code:
@Entity
@Audited
public class Honey
{

  @Id
  @GeneratedValue
  private Integer id;

  private String name;

  private String taste;
   
  //Getters and Setters goes here.
}


Now my question is how can i mention it in hbm file so that it will enables the entity to be audited bu usng hibernate envers.

In Simple terms My Question is "How can we do Envers hbm xml based configuration"


Top
 Profile  
 
 Post subject: Re: @Audited annotation in Hibernate hbm file
PostPosted: Fri Jan 14, 2011 10:11 am 
Senior
Senior

Joined: Fri May 08, 2009 12:27 pm
Posts: 168
It seems you can simply add @Audited to the Pojos.
(See for example http://stackoverflow.com/questions/4677 ... e-hbm-file )

Are the Pojos and hbm.xmls generated via reveng, or are they hand-written?
If they're hand-written, simply add @Audited.
If they're generated, you'll need to modify a template.


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