tag:blogger.com,1999:blog-5943570861711645804.post2108124451696964643..comments2023-03-13T09:59:48.639+01:00Comments on refaktor: Hibernate Envers with Grails 2.1.0Tomasz Kalkosińskihttp://www.blogger.com/profile/12111381907111251016noreply@blogger.comBlogger26125tag:blogger.com,1999:blog-5943570861711645804.post-24575567435908005202014-01-03T11:33:12.362+01:002014-01-03T11:33:12.362+01:00I stumbled upon this blog, Lukas Ward's Blog, ...I stumbled upon this blog, Lukas Ward's Blog, a few community sites, but I could not get a clear answer on how to implement the following queries using the envers plugin:<br />- When was the domain object created? E.g. when was an instance of 'Hotel' created?<br />- What is the last modified date of some domain object? E.g. when was an instance of 'Hotel' last modified?<br />- Which 'user' has created the object? E.g. who has created a particular instance of a 'Hotel' domain class?<br />- Which 'user' has last modified the object? E.g. who has last modified a particular instance of a 'Hotel' domain class?<br />- Find all instances of a domain class created by some 'user'? E.g. find all instances of domain class 'Hotel' created by the current user.<br /> <br />Also, I would like to know if it is possible to use the audit methods inside named queries. majaX1https://www.blogger.com/profile/09051312691329918286noreply@blogger.comtag:blogger.com,1999:blog-5943570861711645804.post-65675533760647205432013-12-20T15:24:15.079+01:002013-12-20T15:24:15.079+01:00This comment has been removed by the author.Jacksonhttps://www.blogger.com/profile/06040421026034798703noreply@blogger.comtag:blogger.com,1999:blog-5943570861711645804.post-73095829851733474332013-12-16T12:02:50.226+01:002013-12-16T12:02:50.226+01:00Thank you Glenn! I've updated a post.Thank you Glenn! I've updated a post.Tomasz Kalkosińskihttps://www.blogger.com/profile/12111381907111251016noreply@blogger.comtag:blogger.com,1999:blog-5943570861711645804.post-4730516839008134712013-12-06T17:02:04.849+01:002013-12-06T17:02:04.849+01:00It looks like the plug-in has now been pushed live...It looks like the plug-in has now been pushed live to Grails central repository. You can simply add to your plug-in section in BuildConfig.groovy:<br /><br />compile ":envers:2.1.0"<br />Anonymoushttps://www.blogger.com/profile/16755130965129042941noreply@blogger.comtag:blogger.com,1999:blog-5943570861711645804.post-26850630578977495372013-04-12T09:37:25.678+02:002013-04-12T09:37:25.678+02:00Thank you! I've updated my post with your link...Thank you! I've updated my post with your link.Tomasz Kalkosińskihttps://www.blogger.com/profile/12111381907111251016noreply@blogger.comtag:blogger.com,1999:blog-5943570861711645804.post-64061446209091450602013-04-12T00:05:08.556+02:002013-04-12T00:05:08.556+02:00I finally got around to tackling some of this: htt...I finally got around to tackling some of this: http://www.lucasward.net/2013/04/grails-envers-plugin-update.htmlLucas Wardhttps://www.blogger.com/profile/03049876741329496319noreply@blogger.comtag:blogger.com,1999:blog-5943570861711645804.post-55261075766794135172013-03-15T21:26:06.734+01:002013-03-15T21:26:06.734+01:00Thanks...
But Is it possible to add additional col...Thanks...<br />But Is it possible to add additional column having user details like username in audited table. So i can identify that which user did the transaction. Please help me.<br />Thanks in advance. Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-5943570861711645804.post-81149077433168641602013-01-08T10:28:43.942+01:002013-01-08T10:28:43.942+01:00I am using @Audited on getter methods instead of a...I am using @Audited on getter methods instead of at class level for auditing specific properties only. However i am unable to use any of the dynamic finder methods findAllRevisionsById() etc. It says cannot resolve property revision. If i annotate the class @Audited, it works.<br />Is there a work around for this without annotating the class? One option is using AuditReader and write your own logic.Anonymoushttps://www.blogger.com/profile/11017286518686810552noreply@blogger.comtag:blogger.com,1999:blog-5943570861711645804.post-59042220478925139142013-01-03T09:42:40.553+01:002013-01-03T09:42:40.553+01:00Thank you for posting working example.Thank you for posting working example.Tomasz Kalkosińskihttps://www.blogger.com/profile/12111381907111251016noreply@blogger.comtag:blogger.com,1999:blog-5943570861711645804.post-56201717111913295912013-01-03T05:16:46.720+01:002013-01-03T05:16:46.720+01:00That didn't work but the following worked:
Se...That didn't work but the following worked:<br /><br />Set tags<br />static hasMany = [tags: Tag]<br /><br />@Audited<br />Set getTags() {<br /> return tags<br />}Anonymoushttps://www.blogger.com/profile/11017286518686810552noreply@blogger.comtag:blogger.com,1999:blog-5943570861711645804.post-91629776651514005792013-01-02T11:47:43.038+01:002013-01-02T11:47:43.038+01:00Try with:
@Audited
static hasMany = [tags: Tag]
...Try with:<br /><br />@Audited<br />static hasMany = [tags: Tag]<br /><br />Does it work?Tomasz Kalkosińskihttps://www.blogger.com/profile/12111381907111251016noreply@blogger.comtag:blogger.com,1999:blog-5943570861711645804.post-86873067603009549672013-01-02T11:44:17.086+01:002013-01-02T11:44:17.086+01:00I need to audit specific fields in my domain class...I need to audit specific fields in my domain class. I've used @Audited on getter methods and it works fine.<br /><br /> @Audited<br /> String getDescription() {<br /> return description<br /> }<br /><br />I also have relation defined as: <br /><br /> static hasMany = [tags: Tag] <br /><br />that needs to be audited. How do i handle this?Anonymoushttps://www.blogger.com/profile/11017286518686810552noreply@blogger.comtag:blogger.com,1999:blog-5943570861711645804.post-33873382343935672622012-12-17T10:27:05.646+01:002012-12-17T10:27:05.646+01:00Was really helpful. Thanks so much.Was really helpful. Thanks so much.Bhushanhttps://www.blogger.com/profile/04886159013423657172noreply@blogger.comtag:blogger.com,1999:blog-5943570861711645804.post-5102314048989757952012-10-18T00:01:44.550+02:002012-10-18T00:01:44.550+02:00Thanks a lot for this great piece of information. ...Thanks a lot for this great piece of information. Was also meaning to do this myself starting just before googling and finding this awesome post.nicolasdijhttps://www.blogger.com/profile/13208120877167294450noreply@blogger.comtag:blogger.com,1999:blog-5943570861711645804.post-8474309482521299052012-09-26T12:16:42.770+02:002012-09-26T12:16:42.770+02:00Thanks for taking the time to write this post and ...Thanks for taking the time to write this post and publish the plugin in the Grails plugin repo. As Lucas said earlier, I have been meaning to do this myself, but real life keeps getting in the way.Jay Hoganhttps://www.blogger.com/profile/00311742674188413196noreply@blogger.comtag:blogger.com,1999:blog-5943570861711645804.post-85864307151482001842012-09-11T05:46:29.373+02:002012-09-11T05:46:29.373+02:00Thanks tty. I will try from my end.Thanks tty. I will try from my end.Anonymoushttps://www.blogger.com/profile/11017286518686810552noreply@blogger.comtag:blogger.com,1999:blog-5943570861711645804.post-4554721489986676252012-09-07T06:35:17.549+02:002012-09-07T06:35:17.549+02:00In groovy @Audited should be placed before getter ...In groovy @Audited should be placed before getter and getter should be defined explicitly for this case.<br />The fix for code above is :<br /><br />class Booking {<br /><br />String surname<br />Date startDate<br />Integer daysCount<br /><br />static constraints = {<br />}<br /><br />static belongsTo = [hotel: Hotel]<br />}<br /><br />@Audited<br />String getSurname() {<br /> return surname<br />}<br />ttyhttps://www.blogger.com/profile/14712653842794118593noreply@blogger.comtag:blogger.com,1999:blog-5943570861711645804.post-65929658771987840032012-09-07T06:33:32.958+02:002012-09-07T06:33:32.958+02:00I found workaround for issue with field annotation...I found workaround for issue with field annotations in another blog - http://www.lucasward.net/2011/04/grails-envers-plugin.html?showComment=1305581292932#c7672244570118132937ttyhttps://www.blogger.com/profile/14712653842794118593noreply@blogger.comtag:blogger.com,1999:blog-5943570861711645804.post-28587722025500789552012-09-05T17:14:02.892+02:002012-09-05T17:14:02.892+02:00--
class Booking {
@Audited
String surname
Date s...--<br />class Booking {<br /><br />@Audited<br />String surname<br />Date startDate<br />Integer daysCount<br /><br />static constraints = {<br />}<br /><br />static belongsTo = [hotel: Hotel]<br />}<br />--<br /><br />This also not works as expected - according to envers documentation it should make only one field surname audible for Booking. It makes Booking not audible at all.ttyhttps://www.blogger.com/profile/14712653842794118593noreply@blogger.comtag:blogger.com,1999:blog-5943570861711645804.post-23122720350262947022012-09-05T17:11:02.999+02:002012-09-05T17:11:02.999+02:00Hello,
Seems field level annotations are not work...Hello,<br /><br />Seems field level annotations are not working:<br />--<br />@Audited<br />class Booking {<br /><br /> @NotAudited<br /> String surname<br /> Date startDate<br /> Integer daysCount<br /><br /> static constraints = {<br /> }<br /><br /> static belongsTo = [hotel: Hotel]<br />}<br />--<br /><br />Code above does not prevent surname from being audited.ttyhttps://www.blogger.com/profile/14712653842794118593noreply@blogger.comtag:blogger.com,1999:blog-5943570861711645804.post-30352519309397817752012-09-04T16:11:34.653+02:002012-09-04T16:11:34.653+02:00If there are multiple data sources defined in Data...If there are multiple data sources defined in DataSource.groovy, the plugin is not saving any data in the audit tables. Any suggestions?<br /><br />Anonymoushttps://www.blogger.com/profile/11017286518686810552noreply@blogger.comtag:blogger.com,1999:blog-5943570861711645804.post-15631745036987284192012-08-24T13:07:50.273+02:002012-08-24T13:07:50.273+02:00Very useful post Tomasz, after looking at the plug...Very useful post Tomasz, after looking at the plugins available for auditing, my search path took me to hibernate-envers and finally to this post. Thanks for taking the time to write it.<br /><br />Davehttps://www.blogger.com/profile/16310895406193679575noreply@blogger.comtag:blogger.com,1999:blog-5943570861711645804.post-744786710202330462012-08-20T23:58:45.043+02:002012-08-20T23:58:45.043+02:00Thanks for shout-out and the upgrade work. I quite...Thanks for shout-out and the upgrade work. I quite simply haven't gotten around to upgrading our app to grails 2 yet, so I didn't upgrade any of the work I had done on the envers plugins.Lucas Wardhttps://www.blogger.com/profile/03049876741329496319noreply@blogger.comtag:blogger.com,1999:blog-5943570861711645804.post-57985526184697381252012-08-16T17:17:08.128+02:002012-08-16T17:17:08.128+02:00Great! Thanks.Great! Thanks.Lim Chee Kinhttps://www.blogger.com/profile/13560701654092113431noreply@blogger.comtag:blogger.com,1999:blog-5943570861711645804.post-23482765571556067362012-08-16T11:16:45.989+02:002012-08-16T11:16:45.989+02:00Thanks. I will pass this suggestion to plugin main...Thanks. I will pass this suggestion to plugin maintainer.Tomasz Kalkosińskihttps://www.blogger.com/profile/12111381907111251016noreply@blogger.com