0

How can encrypt the data base fields when using the hibernate?

We have developed the product some of the clients are using that application Some clients is asking about the data base encryption Is there any possible to encrypt the data in application level with out more changes in the code.

Please give me the suggestion as soon as possible.

Chandrasekhar
  • 1,205
  • 3
  • 11
  • 17

1 Answers1

0

if you have to encrypt data through hibernate, you can listen to save & update events by extending DefaultSaveOrUpdateListener, check this out for an example http://www.java2s.com/Code/Java/Hibernate/EventYourOwnSaveOrUpdateEventListener.htm

you also need to add the config to your hibernate,cfg,xml file.

<listener class="" type="auto-flush" />

this will listen to all save & update events to listen to object creation (when you load data) use the DefaultLoadListener http://www.java2s.com/Open-Source/Java-Document/Database-ORM/hibernate/org/hibernate/event/def/DefaultLoadEventListener.java.htm

remember, these events are called only when you are using a regular session (by calling openSession() or getSession(), if you use session.openStatelessSession() then these calls do not happen)

  • Anantha Sharma
Anantha Sharma
  • 9,920
  • 4
  • 33
  • 35