- r - 以节省内存的方式增长 data.frame
- ruby-on-rails - ruby/ruby on rails 内存泄漏检测
- android - 无法解析导入android.support.v7.app
- UNIX 域套接字与共享内存(映射文件)
尝试在 NHibernate 2.1.2.4000 中使用 IInterceptor,我得到了以下测试代码:
public class TestingNHibernateInterceptors
{
[Fact]
public void can_intercept_delete_for_audit_log()
{
FullyConfigureDb();
Session(s => s.Linq<Person>().Any().ShouldBe(false));
}
ISessionFactory _sessions;
void Session(Action<ISession> @do)
{
using (var s = _sessions.OpenSession())
{
@do(s);
s.Flush();
}
}
void FullyConfigureDb()
{
var cfg = CreateConfig();
_sessions = cfg.BuildSessionFactory();
BuildSchema(cfg);
}
Configuration CreateConfig()
{
return Fluently.Configure()
.Database(new SQLiteConfiguration().InMemory())
.Mappings(x => x.FluentMappings.Add<PersonMap>())
.BuildConfiguration()
.SetProperty("proxyfactory.factory_class", "NHibernate.ByteCode.Castle.ProxyFactoryFactory, NHibernate.ByteCode.Castle")
.SetProperty("show_sql", "true");
}
void BuildSchema(Configuration config)
{
var se = new NHibernate.Tool.hbm2ddl.SchemaExport(config);
se.Execute(false, true, false, _sessions.OpenSession().Connection, null);
}
public class Person
{
public virtual Guid Id { get; private set; }
public virtual string Name { get; set; }
}
public class PersonMap : ClassMap<Person>
{
public PersonMap()
{
Id(x => x.Id);
Map(x => x.Name);
}
}
public class AuditInterceptor : EmptyInterceptor, IInterceptor
{
public override void OnDelete(object entity, object id, object[] state, string[] propertyNames, NHibernate.Type.IType[] types)
{
base.OnDelete(entity, id, state, propertyNames, types);
}
}
}
但是。我不断收到消息:
failed: NHibernate.ADOException : could not execute query [ SELECT count(*) as y0_ FROM "Person" this_ ] [SQL: SELECT count(*) as y0_ FROM "Person" this_] ---- System.Data.SQLite.SQLiteException : SQLite error
模式导出似乎有效 - 为什么没有创建表?
我猜这与使用内存中的 sqllite 有关,但不确定是什么问题。有什么想法吗?
最佳答案
去过那里,做过那件事,也受过伤 ;-)
一旦session被释放,数据库基本上就掉线了。当您在构建模式和运行测试时使用不同的 session 时,模式在测试运行时不再存在。
关于.net - 为什么 hbm2ddl.SchemaExport 不在这里运行?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4740688/
有没有办法为模式差异生成 DDL,就像 TOAD 中的同步功能一样? 不确定如何使用“updateSQL”选项?我正在使用 diff 选项来比较模式。 最佳答案 您可以通过两个步骤来完成: 在两个模式
我正在向表中添加一些新列,并希望向表 DDL 添加文档以供将来的开发人员使用。如何解决这个问题? 最佳答案 通用语法: COMMENT ON {OBJECT} {OBJECTNAME} AS '{25
我有一个连接到 postgresql 数据库的 spring 项目。连接在此 application.yml 文件中定义: spring: datasource: #TODO replace ap
这个问题与Converting MySQL DDL to SQL Server DDL完全相反 . 我有一个 SQL Server 2008 DDL 文件。我想将其导入MySQL。 有什么工具或建议可
关闭。这个问题不符合Stack Overflow guidelines .它目前不接受答案。 要求我们推荐或查找书籍、工具、软件库、教程或其他场外资源的问题对于 Stack Overflow 来说是
当下拉列表值已从某些外部资源修改时,如何在下拉列表的 JQuery 中调用更改事件? 如果我更改下拉列表中的值,下面的代码可以很好地工作。 Jan Feb $('#month').ch
我们有大量不同的数据源,包括 oracle、db2、mysql。我们还需要在最后添加一些审计列。我遇到了以下 Java 类 org.apache.sqoop.hive.HiveTypes。我计划创建一
我有一个为 MySQL 5 生成的模型,但现在我需要在 SQL Server 安装上创建这些表。 年以来我一直在使用 SQL 服务器,我想确保我可以将此脚本转换为兼容。 我真的不知道要寻找什么 TBQ
我的 View 中有三个 DDL。我在第一个 DDL 的“onchange”上触发一个 JavaScript 函数来填充第二个 DDL,并在第二个 DDL 的“onchange”上触发一个 JavaS
我试图将一个事件绑定(bind)到下拉列表,因为昨天没有任何帮助去 JavaScript 聊天室,没有人能够找到解决我的问题的方法,但后来我以某种方式尝试绑定(bind)我的下拉列表,如下所示 $('
我正在尝试学习如何为给定的 Hive 数据库中的所有表自动创建 DDL。 例如,我有一个名为 abc_db 的数据库。我写了一个Hive脚本,将所有的表写入一个名为abc_db.txt的文件中。文件中
我正在尝试使用jpa-ddl-maven-plugin,如here所述但我使用 Apache Maven 3.0.3 时收到以下错误。有什么想法我哪里出错了吗? 我的 pom.xml:
我是 Spring 和 Hibernate 的新手,我已经尝试了所有我能找到的方法来解决这个问题,但没有成功。任何帮助将不胜感激。我目前正在关注一本书中的一个示例项目,并且收到一条错误消息“Gener
鉴于架构: MACHINE_TYPE { machine_type } 机器{机器,机器类型} SORT_PLAN { sort_plan, machine_type } 日程表 { day_of_w
DML、DDL、DCL区别 . 总体解释: DML(data manipulation language): 它们是SELECT、UPDATE、IN
我需要在 Oracle 数据库上执行一堆(最多约 1000000 条)sql 语句。这些语句最后应该导致引用一致的状态,如果发生错误,所有语句都应该回滚。这些语句不是按引用顺序出现的。因此,如果启用了
在这种情况下,可能具有SQLITE DDL(LineNum为AUTO INCREMENT列是TransDate列的一部分)。如果我在行中插入新的每日交易条目,则将自动使用AUTO INCREMENT
我最近开始学习 hive 。我有一个具有以下值的python列表 list=['hello:struct', 'env:string', 'element:struct','AppId:string'
我正在将表从Hive 1迁移到HDInsight Hive 2,并且在从源到目标的表上重新创建表时,DDL中的以下行未正确解析: FIELDS TERMINATED BY ' ' COLLECTION
我正在尝试在 HSQL 数据库中重新创建一个 oracle 数据库。 这是为了在本地开发人员系统上进行更好的单元测试。 我需要知道的是,是否有任何我可以在 oracle 服务器/客户端中使用的工具/命
我是一名优秀的程序员,十分优秀!