[hibernate-dev] Annotation name for column-level read/write expression

Steve Ebersole steve at hibernate.org
Tue Sep 28 12:16:21 EDT 2010


Which you are perfectly free to do:

@Whatever( 
  column="credit_card_num", 
  read="decrypt(credit_card_num, '123)",
  write="encrypt(?, '123')"
)

On Tue, 2010-09-28 at 08:12 -0700, Justin Sands wrote:
> There is a perfectly reasonable use case for a binary operation (though it still 
> applies to one column).
> From your credit card example, there is sometimes more than one key.
> 
> @ReadWriteExpression(
>   read="decrypt(credit_card_num, key)", 
>   write="decrypt(credit_card_num, key)")
> 
> 
> 
> 
> ----- Original Message ----
> From: Paul Benedict <pbenedict at apache.org>
> To: Steve Ebersole <steve at hibernate.org>; Hibernate Developers List 
> <hibernate-dev at lists.jboss.org>
> Sent: Tue, September 28, 2010 10:37:37 AM
> Subject: Re: [hibernate-dev] Annotation name for column-level read/write 
> expression
> 
> I am not in favor of @ColumnReadWrite in case someone designs an
> enhancement that's tertiary: read, insert update. Okay, far-fetched,
> but still I don't want to limit any designs.
> 
> @ColumnAccess is too close to JPA's access types of method/field.
> 
> I think we are really dealing with transformations here. Based on some
> internet searching, that seems to be the terminology around for
> wrapping columns in SQL methods.
> 
> I could go for @ColumnTransform or @ColumnWrapper
> 
> On Tue, Sep 28, 2010 at 9:21 AM, Steve Ebersole <steve at hibernate.org> wrote:
> > Really we now have 2 discussions:
> >
> > 1) whether to combine read/write into one annotation : +1 from me, *so
> > long as* neither is required.  And as we discussed, ideally the column
> > name would be optional too for single-column values.
> >
> > 2) What we want to name it.  Personally I like "column" in the name as
> > it makes it clear this applies to the columns.  To me, any of these fit:
> >
> > @ColumnMutation
> > @ColumnReadWrite
> > @ColumnAccess
> >
> > Really to keep the verbiage consistent, if thats a concern , I think
> > @ColumnReadWrite fits the best.  Though certainly we can adjust the docs
> > if we agree on a "better" name.
> >
> >
> > On Tue, 2010-09-28 at 15:55 +0200, Max Rydahl Andersen wrote:
> >> TransformOnRead TransformOnWrite ?
> >>
> >> MutateOnRead/Write ?
> >>
> >> /max
> >>
> >> On Sep 28, 2010, at 15:28, Steve Ebersole wrote:
> >>
> >> > "access" does not capture the essence of what you are doing though which
> >> > is mutating values to and fro.
> >> >
> >> > On Tue, 2010-09-28 at 08:57 -0400, Chris Bredesen wrote:
> >> >> read + write = access
> >> >>
> >> >> @ColumnAccessExpression?
> >> >>
> >> >> On 09/28/2010 07:33 AM, Steve Ebersole wrote:
> >> >>> Really we went through the same discussion when developing the original
> >> >>> feature in terms of what to "call it" when discussing/documenting it.  I
> >> >>> like the "read" and "write" aspects; its the general quality of applying
> >> >>> read/write thats tougher to term.
> >> >>>
> >> >>> Another option is @ColumnReadWrite.
> >> >>>
> >> >>>
> >> >>> On Tue, 2010-09-28 at 11:29 +0200, Emmanuel Bernard wrote:
> >> >>>> As of right now, yes.
> >> >>>> Trying to support it was not super trivial but I can give it a second 
> >>round today.
> >> >>>>
> >> >>>> @ReadWriteWrapper would work. We don't use wrapper though in the doc for 
> >>this feature but that can be changed.
> >> >>>>
> >> >>>>
> >> >>>> On 28 sept. 2010, at 05:54, Steve Ebersole wrote:
> >> >>>>
> >> >>>>> Is the 'forColumn' attribute required if a single column value?
> >> >>>>>
> >> >>>>>
> >> >>>>> On Mon, 2010-09-27 at 22:53 -0500, Steve Ebersole wrote:
> >> >>>>>> @Wrapper(
> >> >>>>>>    forColumn="credit_card_num",
> >> >>>>>>    read="decrypt(credit_card_num)",
> >> >>>>>>    write="encrypt(?)"
> >> >>>>>> )
> >> >>>>>>
> >> >>>>>> @ReadWrapper( forColumn="credit_card_num",
> >> >>>>>> expression="decrypt(credit_card_num)" )
> >> >>>>>> @WriteWrapper( forColumn="credit_card_num", expression="encrypt(?)" )
> >> >>>>>>
> >> >>>>>>
> >> >>>>>>
> >> >>>>>> On Tue, 2010-09-28 at 00:10 +0200, Emmanuel Bernard wrote:
> >> >>>>>>> Hey guys,
> >> >>>>>>> I've implemented 
> >>http://opensource.atlassian.com/projects/hibernate/browse/HHH-4510 and committed 
> >>it. It basically looks like that
> >> >>>>>>>
> >> >>>>>>> @Entity
> >> >>>>>>> class CreditCard {
> >> >>>>>>>   @Column(name="credit_card_num")
> >> >>>>>>>   @ReadWriteExpression(
> >> >>>>>>>      forColumn="credit_card_num",
> >> >>>>>>>      read="decrypt(credit_card_num)",
> >> >>>>>>>      write="encrypt(?)")
> >> >>>>>>>   public String getCreditCardNumber() { return creditCardNumber; }
> >> >>>>>>>   public void setCreditCardNumber(String number) { 
> >>this.creditCardNumber = number; }
> >> >>>>>>>   private String creditCardNumber;
> >> >>>>>>> }
> >> >>>>>>>
> >> >>>>>>> However, I am not super happy about @ReadWriteExpression as a name. 
> >>@ColumnReadWriteExpression is the most correct name but quite mouthful.
> >> >>>>>>>
> >> >>>>>>> Anybody gets a better idea?
> >> >>>>>>>
> >> >>>>>>> Emmanuel
> >> >>>>>>>
> >> >>>>>>> _______________________________________________
> >> >>>>>>> hibernate-dev mailing list
> >> >>>>>>> hibernate-dev at lists.jboss.org
> >> >>>>>>> https://lists.jboss.org/mailman/listinfo/hibernate-dev
> >> >>>>>>
> >> >>>>>
> >> >>>>> --
> >> >>>>> Steve Ebersole<steve at hibernate.org>
> >> >>>>> http://hibernate.org
> >> >>>>>
> >> >>>>
> >> >>>
> >> >> _______________________________________________
> >> >> hibernate-dev mailing list
> >> >> hibernate-dev at lists.jboss.org
> >> >> https://lists.jboss.org/mailman/listinfo/hibernate-dev
> >> >
> >> > --
> >> > Steve Ebersole <steve at hibernate.org>
> >> > http://hibernate.org
> >> >
> >> > _______________________________________________
> >> > hibernate-dev mailing list
> >> > hibernate-dev at lists.jboss.org
> >> > https://lists.jboss.org/mailman/listinfo/hibernate-dev
> >>
> >
> > --
> > Steve Ebersole <steve at hibernate.org>
> > http://hibernate.org
> >
> > _______________________________________________
> > hibernate-dev mailing list
> > hibernate-dev at lists.jboss.org
> > https://lists.jboss.org/mailman/listinfo/hibernate-dev
> >
> 
> _______________________________________________
> hibernate-dev mailing list
> hibernate-dev at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/hibernate-dev
> 
> 
> 
>       

-- 
Steve Ebersole <steve at hibernate.org>
http://hibernate.org




More information about the hibernate-dev mailing list