简体   繁体   中英

Hibernate encrpytion using column transformers read/write doesn't work

I am using mysql 5.5 and hibernate 4.3.0.Final. I have tried to use the column transformers to encrypt and decrypt data on the fly. I have no errors at all when activating hibernate or using this .hbm. Here is what I have in the .hbm:

<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
    "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
    "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">

<hibernate-mapping auto-import="false"> <classname="com.someplace.someapp.dao.SomeHistory"                                          table="SOME_APP.SOME_HISTORY" lazy="false">
     <id name="id" column="id">
        <generator class="uuid"/>
    </id>
    <property name="name">
        <column 
          name="NAME" not-null="true"
          read="decrypt(NAME)"
          write="encrypt(?)"/>
    </property>
    <property name="description">
        <column 
          name="VALUE" 
          read="decrypt(VALUE)"
          write="encrypt(?)"/>
    </property>
  </class>
</hibernate-mapping>

I looked at the data in the tables and the data have not been encrypted. Any help would be greatly appreciated!

Looking at this link I think encrypt is there but no decrypt, try Aes_encrypt and decrypt. Do you have any business rule asking you to encrypt using regular encrypt function?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM