Hibernate中的DataBase加密 [英] DataBase encryption in Hibernate

查看:256
本文介绍了Hibernate中的DataBase加密的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在使用hibernate时加密数据库字段?

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.

请尽快给我建议。

推荐答案

如果你必须通过hibernate加密数据,你可以监听save&通过扩展DefaultSaveOrUpdateListener来更新事件,查看示例
http:/ /www.java2s.com/Code/Java/Hibernate/EventYourOwnSaveOrUpdateEventListener.htm

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

您还需要将配置添加到您的hibernate,cfg,xml文件。

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

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

这将听所有保存&更新事件
以侦听对象创建(当您加载数据时)使用DefaultLoadListener
http://www.java2s.com/Open-Source/Java-Document/Database-ORM/hibernate/org/hibernate /event/def/DefaultLoadEventListener.java.htm

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

请记住,这些事件仅在您使用常规会话时调用(通过调用<$ c $如果使用 session.openStatelessSession(),则c> openSession()或 getSession >然后这些电话不会发生)

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

这篇关于Hibernate中的DataBase加密的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆