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

推荐订阅源

P
Palo Alto Networks Blog
大猫的无限游戏
大猫的无限游戏
Martin Fowler
Martin Fowler
GbyAI
GbyAI
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
量子位
T
The Blog of Author Tim Ferriss
Y
Y Combinator Blog
Microsoft Azure Blog
Microsoft Azure Blog
C
CERT Recently Published Vulnerability Notes
Recent Announcements
Recent Announcements
A
About on SuperTechFans
aimingoo的专栏
aimingoo的专栏
P
Privacy International News Feed
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
博客园 - 叶小钗
L
Lohrmann on Cybersecurity
G
GRAHAM CLULEY
T
The Exploit Database - CXSecurity.com
Hugging Face - Blog
Hugging Face - Blog
P
Proofpoint News Feed
NISL@THU
NISL@THU
博客园 - Franky
C
Cybersecurity and Infrastructure Security Agency CISA
The Register - Security
The Register - Security
M
MIT News - Artificial intelligence
Know Your Adversary
Know Your Adversary
A
Arctic Wolf
F
Full Disclosure
T
Threat Research - Cisco Blogs
P
Privacy & Cybersecurity Law Blog
The Hacker News
The Hacker News
博客园 - 【当耐特】
D
Docker
T
Tailwind CSS Blog
S
SegmentFault 最新的问题
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Jina AI
Jina AI
Help Net Security
Help Net Security
V
Visual Studio Blog
小众软件
小众软件
B
Blog
Vercel News
Vercel News
云风的 BLOG
云风的 BLOG
N
News and Events Feed by Topic
Forbes - Security
Forbes - Security
N
Netflix TechBlog - Medium
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
C
Cisco Blogs
Security Archives - TechRepublic
Security Archives - TechRepublic

博客园 - 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刚结束不久,好多问题呀。。