惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

GbyAI
GbyAI
Simon Willison's Weblog
Simon Willison's Weblog
Microsoft Security Blog
Microsoft Security Blog
Y
Y Combinator Blog
The GitHub Blog
The GitHub Blog
Engineering at Meta
Engineering at Meta
F
Fortinet All Blogs
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
A
About on SuperTechFans
Last Week in AI
Last Week in AI
月光博客
月光博客
有赞技术团队
有赞技术团队
P
Proofpoint News Feed
MyScale Blog
MyScale Blog
Martin Fowler
Martin Fowler
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
C
Check Point Blog
U
Unit 42
The Register - Security
The Register - Security
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Hugging Face - Blog
Hugging Face - Blog
阮一峰的网络日志
阮一峰的网络日志
V
Visual Studio Blog
酷 壳 – CoolShell
酷 壳 – CoolShell
D
DataBreaches.Net
WordPress大学
WordPress大学
aimingoo的专栏
aimingoo的专栏
H
Hacker News: Front Page
Recent Announcements
Recent Announcements
C
CXSECURITY Database RSS Feed - CXSecurity.com
Latest news
Latest news
小众软件
小众软件
P
Palo Alto Networks Blog
PCI Perspectives
PCI Perspectives
Security Latest
Security Latest
S
Secure Thoughts
Scott Helme
Scott Helme
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
T
Threat Research - Cisco Blogs
P
Proofpoint News Feed
M
MIT News - Artificial intelligence
Application and Cybersecurity Blog
Application and Cybersecurity Blog
Google DeepMind News
Google DeepMind News
Recorded Future
Recorded Future
O
OpenAI News
S
Securelist
云风的 BLOG
云风的 BLOG
H
Help Net Security
T
Troy Hunt's Blog

博客园 - db's jim

NuGet 无法连接到远程服务器-解决方法(转) 未能解析此远程名称:’nuget.org’ 解决方法(转) [转]jquery对事件冒泡的处理方法 Asp.net中的认证与授权 JS的事件监听机制 用映射的方法获取当前方法的名称 log4net的各种Appender配置示例(转) System.Diagnostics命名空间里的Debug类和Trace类的用途(收藏) Newtonsoft.Json处理日期问题 Failed to execute request because the App-Domain could not be created C#Windows服务程序安装 VS2010快捷键 生成方法存根 (Stub) Nhibernate.hbm2ddl.auto配置详解 NHibernate.Tool.hbm2ddl SchemaExport SQL2005 开窗函数 通过WEB方式修改windows帐号的秘密 将EXCEL文档导入SQL server 2005错误 castle ActiveRecord 初始化
NHibernate 事务查询的更新事件
db's jim · 2011-11-09 · via 博客园 - db's jim

一个简单的Nhibernate查询,居然有Update事件。

ISessionFactory sessionFactory = cfg.BuildSessionFactory();

using (ISession session = sessionFactory.OpenSession())
{
ITransaction tran = session.BeginTransaction();
Artist a = session.CreateQuery("from Artist")
.SetMaxResults(1)
.List<Artist>()[0];

tran.Commit();

session.Close();
}

Artist类

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace CopyRightSys.Domain
{
public enum ArtistType
{
其他=0,
歌手=1,
作词=2,
作曲=3

}

public class Artist
{
public virtual int ID { get; set; }
public virtual ArtistType ArtType { get; set; }
public virtual int ArtID { get; set; }

public virtual string Name { get; set; }
public virtual string ShowName { get; set; }
public virtual string ShortName { get; set; }
public virtual string Sex { get; set; }
public virtual string Company { get; set; }
public virtual int SongCount { get; set; }
public virtual DateTime UpTime { get; set; }
public virtual int UpUserID { get; set; }
public virtual string Memo { get; set; }

}
}

查询的SQL:

NHibernate: select TOP (@p0) artist0_.Artor_id as Artor1_0_, artist0_.Artor_type as Artor2_0_, artist0_.Art_ID as Art3_0_, artist0_.Art_Name as Art4_0_, artist0_.Art_ShowName as Art5_0_, artist0_.Art_ShortName as Art6_0_, artist0_.Art_Sex as Art7_0_, artist0_.Art_Company as Art8_0_, artist0_.Art_SongCount as Art9_0_, artist0_.UpTime as UpTime0_, artist0_.UpUser as UpUser0_, artist0_.abstract as abstract0_ from T_artor artist0_;@p0 = 1 [Type: Int32 (0)]

NHibernate: Batch commands:
command 0:UPDATE T_artor SET Artor_type = @p0, Art_ID = @p1, Art_Name = @p2, Art_ShowName = @p3, Art_ShortName = @p4, Art_Sex = @p5, Art_Company = @p6, Art_SongCount = @p7, UpTime = @p8, UpUser = @p9, abstract = @p10 WHERE Artor_id = @p11;@p0 = 歌手 [Type: Int32 (0)], @p1 = 1187 [Type: Int32 (0)], @p2 = '锋崽' [Type: String (100)], @p3 = '锋崽' [Type: String (100)], @p4 = NULL [Type: String (50)], @p5 = NULL [Type: String (50)], @p6 = NULL [Type: String (100)], @p7 = 0 [Type: Int32 (0)], @p8 = 2007-09-30 11:03:23 [Type: DateTime (0)], @p9 = 0 [Type: Int32 (0)], @p10 = NULL [Type: String (200)], @p11 = 1 [Type: Int32 (0)]


1 passed, 0 failed, 0 skipped, took 2.89 seconds (Ad hoc).

很是郁闷呀,查询居然有更新的操作,逐一排查,最后落在了ArtType属性上了,他是枚举类型,再看hbm配置文件

<property name="ArtType" column="Artor_type" type="int" not-null="1"></property>

最后把type="int"去掉,运行,不会在自行update了,估计是数据类型的转换的问题。

NHibernate刚结束不久,好多问题呀。。