Oracle Blob 字段的 NHibernate 架构导出问题
我在使用 NHibernate 的 schemaexport 函数创建 Oracle DB 时遇到问题。 对于定义为 byte[] 的属性,它会创建一个 RAW 类型的 DB 字段(顺便说一句,限制为 2000 字节)。 这个字段类型不足以满足我的需求,我需要 NH 来创建一个 blob 字段。 我怎样才能做到这一点? 我尝试在映射文件(我使用 xml 映射,因此 hbm 文件)中声明字段,指定 type="Binary" 和 type="BinaryBlob",但这些似乎都没有达到预期的效果:创建的字段始终是生的。 有人可以帮我吗?
I'm having an issue creating my Oracle DB with schemaexport function of NHibernate.
For a property defined as byte[], it creates a DB field of type RAW (btw limited to 2000 byte).
This field type is not enough for my needs, and I need NH to create a blob field instead.
How can I achive that?
I tried declaring the field in the mapping file (I use xml mapping, thus hbm files) specifying either type="Binary" and type="BinaryBlob", but none of those seems to have the desired effects: the created field is always a RAW.
Can anyone help me here?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
更新:也许这也可以解决问题
Update: maybe this could also do the trick
我有一个类似的问题,解决方案是长度属性:
如果你没有指定长度,那么无论你在类型属性中写入什么,它都会在oracle中以RAW(2000)结尾,因为它的最大值是2000字节,但如果你说我需要5 MB 或以字节为单位,它是 5224880 字节,然后 nhibernate 自动切换到 BLOB,因为它大于 2000 字节,
因此给定 dot net 属性,
正确的映射将是
或者您可以探索Nhibernate的codebase(源代码)中的OracleLiteDialect.cs
I had a similar problem and the solution is the length attribute:
If you specify no length then whatever you write in the type attribute it's going to end as RAW(2000) in oracle because its maximum is 2000 bytes, but if you say I need 5 MB or in bytes its 5224880 bytes then nhibernate switch's to BLOB automatically because it's bigger then 2000 bytes
so given the dot net property
the proper mapping would be
Or you can explore the OracleLiteDialect.cs in the codebase (source code) of Nhibernate
如果有人想要一种约定方式将 byte[] 类型转换为数据库中的 BLOB,我想出了这个:
If someone wants a convention way to do the byte[] type translate into BLOB in database i came up with this: