[hibernate-issues] [Hibernate-JIRA] Commented: (HSEARCH-1093) Smarter dirty checking with @Transient fields

Marc Schipperheyn (JIRA) noreply at atlassian.com
Fri Apr 13 11:42:48 EDT 2012


    [ https://hibernate.onjira.com/browse/HSEARCH-1093?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=46286#comment-46286 ] 

Marc Schipperheyn commented on HSEARCH-1093:
--------------------------------------------

Well, I'm not sure I agree. I suppose from a purist point of view flagging transient as dirty by default is the same as flagging Classbridged class as dirty by default. But for me, the number one priority is avoiding unnecessary database calls of which hibernate unfortunately generates many, despite my best efforts (which is why I was passionate about includePath). And this would not help in this. You're right about asking for a test just as my accountant is right about asking for receipts. Neither fails to generate a lack of enthusiasm in me :-) I'll open the Jira though.

> Smarter dirty checking with @Transient fields
> ---------------------------------------------
>
>                 Key: HSEARCH-1093
>                 URL: https://hibernate.onjira.com/browse/HSEARCH-1093
>             Project: Hibernate Search
>          Issue Type: Improvement
>    Affects Versions: 4.1.0.Final
>            Reporter: Marc Schipperheyn
>
> I found that if you have a field that is @Transient and depends on a Hibernate managed field, this field is not updated when the underlying field changes. 
> {code}
>    @ManyToOne
>    @JoinColumn
>    @IndexedEmbedded
>    public Photo getPhoto() {
>       return photo;
>    }
>    @Transient
>    @Field
>    public String getMugshot(){
>       if(photo == null)
>          return null;
>       return getUserDirectory() + "/" + photo.getFilename();
>    }
> {code}
> This makes sense. However, it's not desirable. I would therefore want to propose an annotation that can add some magic to dirty checking and inform Hibernate Search that when @Field x gets dirty, the @Transient field should also be considered dirty
> Something like 
> {code}
>    @ManyToOne
>    @JoinColumn
>    @IndexedEmbedded
>    public Photo getPhoto() {
>       return photo;
>    }
>    @Transient
>    @Field
>    @AssociateDirty(fields={"photo"})
>    public String getMugshot(){
>       if(photo == null)
>          return null;
>       return getUserDirectory() + "/" + photo.getFilename();
>    }
> {code}
> There are many names one might give to such an annotation. E.g. @YouDirtyMeDirty, but many somehow sound a little "dirty" :-)

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        


More information about the hibernate-issues mailing list