Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to encrypt a database entry when using javax.persistence package?

 
deirdre lee
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I was wondering is there any way of encrypting a data entry that you persist to a database using the javax.persistence package.

For example the following SQL statement would be used to enter the data directly into the database using JDBC:



But using javax.persistence package, how is it possible to persist an object with an encrypted data element?

Extract from persistenceService:


Extract from myObject:



 
Luciano A. Pozzo
Ranch Hand
Posts: 112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Maybe you could use Entity Listeners:

  • @java.persistence.PrePersist
  • @java.persistence.PostPersist
  • @java.persistence.PostLoad
  • @java.persistence.PreUpdate
  • @java.persistence.PostUpdate
  • @java.persistence.PreRemove
  • @java.persistence.PostRemove

  •  
    • Post Reply
    • Bookmark Topic Watch Topic
    • New Topic