Hi,
I have an encrypted column in a table mapped as follows:
Code:
<property name="GivenNames" column="GivenNames"
access="field.camelcase-underscore"
formula="DecryptByKey(GivenNames)"/>
DecryptByKey is an SQL Server 2005 function, but the key that it uses for decryption must be opened first as follows:
Code:
open symmetric key ssn_key_01 decryption by certificate test;
How do I run this statement prior to a session.load?
I tried the following without any luck
Code:
TestIdentity id1 = new TestIdentity();
ISession sess1 = NHibernateSessionManager.Instance.GetSession();
sess1.BeginTransaction();
IDbCommand cmd = sess1.Connection.CreateCommand();
sess1.Transaction.Enlist(cmd);
cmd.CommandText = "open symmetric key ssn_key_01 decryption by certificate ecstest;";
cmd.ExecuteNonQuery();
sess1.Load(id1, 7);
sess1.Transaction.Commit();
Hibernate version: 1.0.4.0