Skip to content

NH-3620 Fix ORA-01483 when inserting two blobs and a date using the OracleManagedDataClientDriver #269

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 26, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions src/NHibernate.Test/NHSpecificTest/NH3620/Fixture.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
using System;
using NHibernate.Driver;
using NUnit.Framework;

namespace NHibernate.Test.NHSpecificTest.NH3620 {
[TestFixture]
public class Fixture : BugTestCase {
protected override bool AppliesTo(Engine.ISessionFactoryImplementor factory) {
return (factory.ConnectionProvider.Driver is OracleManagedDataClientDriver);
}

protected override void OnTearDown() {
CleanupData();
}

[Test]
public void Should_insert_two_blobs_and_a_date() {
using (ISession s = OpenSession()) {
var blob = new Byte[1024*24];
for (int i = 0; i < blob.Length; i++) {
blob[i] = 65;
}

using (ITransaction tx = s.BeginTransaction()) {
var tb = new TwoBlobs {
Blob1 = blob, Blob2 = blob, Id = 1, TheDate = DateTime.Now
};
s.Save(tb);
tx.Commit();
}
}
}

private void CleanupData() {
using (ISession session = OpenSession()) {
using (ITransaction tx = session.BeginTransaction()) {
session.Delete("from TwoBlobs");
tx.Commit();
}
}
}
}
}
12 changes: 12 additions & 0 deletions src/NHibernate.Test/NHSpecificTest/NH3620/Mappings.hbm.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
assembly="NHibernate.Test"
namespace="NHibernate.Test.NHSpecificTest.NH3620">
<class name="TwoBlobs">
<id name="Id" type="Int32" />
<property name="TheDate" />
<property name="Blob1" length="5224880" />
<property name="Blob2" length="5224880" />

</class>
</hibernate-mapping>
11 changes: 11 additions & 0 deletions src/NHibernate.Test/NHSpecificTest/NH3620/TwoBlobs.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
using System;

namespace NHibernate.Test.NHSpecificTest.NH3620 {
public class TwoBlobs {
public virtual int Id { get; set; }
public virtual byte[] Blob1 { get; set; }
public virtual byte[] Blob2 { get; set; }
public virtual DateTime TheDate { get; set; }

}
}
3 changes: 3 additions & 0 deletions src/NHibernate.Test/NHibernate.Test.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -686,6 +686,8 @@
<Compile Include="NHSpecificTest\BagWithLazyExtraAndFilter\Fixture.cs" />
<Compile Include="Linq\ByMethod\DistinctTests.cs" />
<Compile Include="Component\Basic\ComponentWithUniqueConstraintTests.cs" />
<Compile Include="NHSpecificTest\NH3620\Fixture.cs" />
<Compile Include="NHSpecificTest\NH3620\TwoBlobs.cs" />
<Compile Include="NHSpecificTest\NH1082\SynchronizationThatThrowsExceptionAtBeforeTransactionCompletion.cs" />
<Compile Include="NHSpecificTest\NH2756\Fixture.cs" />
<Compile Include="NHSpecificTest\NH2756\Model.cs" />
Expand Down Expand Up @@ -3371,6 +3373,7 @@
<EmbeddedResource Include="NHSpecificTest\NH1810\Mappings.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\NH1092\Mappings.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\NH1507\Mappings.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\NH3620\Mappings.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\NH1044\Mappings.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\NH1427\Mappings.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\NH1531\Mappings.hbm.xml" />
Expand Down
5 changes: 5 additions & 0 deletions src/NHibernate/Driver/OracleManagedDataClientDriver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ public class OracleManagedDataClientDriver : ReflectionBasedDriver, IEmbeddedBat
private readonly PropertyInfo oracleDbType;
private readonly object oracleDbTypeRefCursor;
private readonly object oracleDbTypeXmlType;
private readonly object oracleDbTypeBlob;

/// <summary>
/// Initializes a new instance of <see cref="OracleDataClientDriver"/>.
Expand All @@ -44,6 +45,7 @@ public OracleManagedDataClientDriver()
var oracleDbTypeEnum = ReflectHelper.TypeFromAssembly("Oracle.ManagedDataAccess.Client.OracleDbType", driverAssemblyName, false);
oracleDbTypeRefCursor = Enum.Parse(oracleDbTypeEnum, "RefCursor");
oracleDbTypeXmlType = Enum.Parse(oracleDbTypeEnum, "XmlType");
oracleDbTypeBlob = Enum.Parse(oracleDbTypeEnum, "Blob");
}

/// <summary></summary>
Expand Down Expand Up @@ -83,6 +85,9 @@ protected override void InitializeParameter(IDbDataParameter dbParam, string nam
case DbType.Xml:
this.InitializeParameter(dbParam, name, oracleDbTypeXmlType);
break;
case DbType.Binary:
this.InitializeParameter(dbParam, name, oracleDbTypeBlob);
break;
default:
base.InitializeParameter(dbParam, name, sqlType);
break;
Expand Down