hibernate.default_schema是什么意思? [英] What does hibernate.default_schema mean?

查看:788
本文介绍了hibernate.default_schema是什么意思?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在阅读Ben Scheirman的博客文章一些NHibernate的调整,他为了提高性能。



在文章的最后是:


第7课:总是确保你设置了hibernate.default_schema

他是什么意思? code> hibernate.default_schema ?

解决方案

我不是dba,所以我可以'给你一个好的schema定义......(对我来说,它只是SQL Server中的'数据库')。

在NHibernate中,你可以指定模式的两个地方:映射文件中,配置文件中。



映射文件允许您为每个类指定模式。当你在同一个服务器上有不同模式的类时,这很好。

SessionFactory配置允许你指定一个默认模式(default_schema选项),它应该适用于所有类映射不明确地设置它们的模式。所以它是一个全部。



从阅读你的链接看来,这对性能是有益的,因为当你查询表Bar而没有指定模式时(比如说数据库是Foo 因此在SQL Server中架构Foo.dbo)查询计划没有被缓存。这可能是由于SQL Server必须尝试并解析连接字符串(初始目录,数据库等)所使用的模式,而不是在查询中显式使用它(Bar隐含 - 未缓存,Foo.dbo .Barexplicit - cached)。

同样,我不是一个dba,所以这些定义很糟糕:)

编辑:



这是一个链接到配置的东西(对于NH 1.2 ...这是旧的...但default_schema选项在那里):

p>

https://www.hibernate.org/hib_docs/nhibernate/1.2/reference/en/html/session-configuration.html


I was reading a blog-post of Ben Scheirman about some NHibernate tweaks he made in order to increase the performance.

In the end of article there is:

Lesson #7: Always make sure you’ve set hibernate.default_schema

What does he mean by hibernate.default_schema?

解决方案

I'm not a dba so I can't give you a good definition of schema... (to me it is just 'database' in SQL Server).

In NHibernate you can specify the schema two places: in the mapping files, in the configuration.

The Mapping File lets you specify schema per class. This is good when you have classes coming from different schema in the same server.

The SessionFactory configuration lets you specify a default schema (default_schema option) that should be applied to all class mappings that don't explicitly set their schema. So its a catch all.

From reading your link it seems this is beneficial in performance because when you query table "Bar" without specifying the schema (say database is "Foo" so schema "Foo.dbo" in SQL Server) the query plan isn't cached. This is probably due to the SQL Server having to try and resolve which schema to use by your connection string (Initial Catalog, Database, etc) instead of having it explicit in the query ("Bar" implicit - not cached, "Foo.dbo.Bar" explicit - cached).

Again, I'm not a dba so these definitions suck :)

edit:

Here is a link to the configuration stuff (for NH 1.2 ... which is old ... but the default_schema option is there):

https://www.hibernate.org/hib_docs/nhibernate/1.2/reference/en/html/session-configuration.html

这篇关于hibernate.default_schema是什么意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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