The LifeCycle events are actually associated with the Entity class. You have the option of defining your callbacks inline in your Entity class, or you can define a separate callback class and reference that in your Entity definition. When your defined callback methods are invoked, you will have access to your Entity instance and then you can modify the fields as needed for encryption/decryption.
The doc link provides more information and examples on how to define these callbacks. Kevin On Thu, Jul 7, 2011 at 3:20 PM, Saibabu Vallurupalli < [email protected]> wrote: > Hi Kevin, > > Thank you for the prompt response. I am sure the below workaround should > work for me. > Where do I need to add these LifeCycle callbacks? I have a model class in > James source for the field I am trying to Encrypt/Decrypt as shown below: > > ********* > public class JPAMessage extends AbstractJPAMessage { > > /** The value for the body field. Lazy loaded */ > /** We use a max length to represent 1gb data. Thats prolly overkill, > but who knows */ > @Basic(optional = false, fetch = FetchType.LAZY) > @Column(name = "MAIL_BYTES", length = 1048576000, nullable = false) > @Lob private byte[] *body*; > > // methods related to this class getter and creator...here... > } > ******** > > "body" is the attribute I have to work with. So, Is this correct location > to > add these life cycle methods? > > Please advice. > > Thanks, > Sai > > > On Thu, Jul 7, 2011 at 2:56 PM, Kevin Sutter <[email protected]> wrote: > > > Hi Sai, > > JIRA openjpa-763 is a new feature request. Nobody has found the time to > > dive into this request. It probably is not that difficult to architect > and > > implement -- it's just a matter of time. > > > > As the text of the JIRA indicates, you could do a poor-man's > implementation > > by using the LifeCycle callbacks [1]. During the prePersist and > preUpdate > > callbacks, you could encrypt the contents of the mail message. And, > during > > the postLoad callback, you could decrypt the contents of the mail > message. > > Would that work for your situation? > > > > Thanks, > > Kevin > > > > [1] > > > > > http://openjpa.apache.org/builds/latest/docs/manual/manual.html#jpa_overview_pc_callbacks > > > > On Thu, Jul 7, 2011 at 9:05 AM, Saibabu Vallurupalli < > > [email protected]> wrote: > > > > > Hi, > > > > > > I am using Apache James and we have a requirement to Encrypt and > Decrypt > > > the > > > email message body while storing to Database. In this process, I > started > > > exchanging emails with James development team and they have pointed me > to > > > the JIRA ticket# OPENJPA-763. > > > It will be really helpful if this issue can be fixed or please advise > me > > > with some suggestions on how to handle column level > > Encryption/Decryption. > > > > > > Thank you, > > > Sai > > > > > >
