NHibernate in Action

所需积分/C币:16 2011-10-28 17:52:49 1.64MB PDF
6
收藏 收藏
举报

NHibernate in Action.PDF 一本不错的书,如果没有资源可以邮件到576402498@qq.com索取。
contents reword xvii p eface xxa acknowledgments xxiii about this book xxi PART1 DISCOⅴ ERING ORM WITH NHIBERNATE∴ Object/relational persistence in. NET 3 1.1 What is persistence Relational databases 5: Understanding SQl 6. Using SQL in. net applications 6. Persistence in object-oriented applications 6. Persistence and the layered architecture 7 12A pproaches to persistence in net 9 Choice of persistence layer 9. Implementing the entities 11 Displaying entities in the user interface 13: Implementing CRUD operations 14 1. 3 Why do we need NHibernate? 15 The paradigm mismatch 15. Units of work and conversations 16 Complex queries and the aDo. NET Entity framework 18 CONTENTS 1.4 Object/relational mapping 21 What is OrM? 21. Why orm? 21 ummary Hello nhibernate/ 24 2.1“ Hello world” with nhibernate25 Installing Nhibernate 25. Create a new visual studio project 25 Creating the Employee class 26. Setting up the database 27 Creating an Employee and saving to the database 27. Loading an Employee from the database 29a Creating a mapping file 29 Configuring your application 31. Updating an Employee 32 Running the program 33 2.2 Understanding the architecture 33 The core interfaces 35. Callback interfaces 36- Types 37 Extension interfaces 37 2.3 Basic configuration 38 Creating a SessionFactory 38.Configuring the ADO. NET database access 41 2.4 Advanced configuration settings 44 Using the application configuration file 44. Logging 47 2.5 Summary 48 PART 2 NHIBERNATE DEEP DIVE.................. 49 3 Writing and mapping classes 51 3.1 The CaveatEmptor application 52 Analyzing the business domain 52. The CaveatEmbtor domain model 53 8.2 Implementing the domain model 55 Addressing leakage of concerns 55: Transparent and automated persistence 55. Writing POCOs 56 Implementing PoCo associations 58 Adding logic toto力 erties61 8.8 Defining the mapping metadata 63 Mapping using XML 63 Attribute-oriented programming 65 CONTENTS 8.4 Basic property and class mappings 66 Property mapping overview 66. Using derived properties 68 Property access strategies 68. Taking advantage of the reflection optimizer 70. Controlling insertion and updates 71. Using quoted SQL identifiers 72. Naming conventions 72. SQL schemas 73. Declaring class names 74 Manipulating metadata at runtime 75 3.5 Understanding object identity 76 Identity versus equality 76. Database identity with NHibernate 77. Choosing primary keys 79 3.6 Fine-grained object models 81 Entity and value types &1 Using components 82 3.7 Introducing associations 86 Unidirectional associations 86. Multiplicity 86. The simplest possible association 87. Making the association bidirectional 88 A parent/child relationship 90 8.8 Mapping class inheritance 91 Table per concrete class 92 Table per class hierarchy 93. Table per subclass 95. Choosing a strategy 98 3. 9 Summary 99 Working with persistent objects 100 4.1 The persistence lifecycle 101 Transient objects 102. Persistent objects 102 . Detached objects 103. The scope of object identity 104. Outside the identity scope 105 Implementing Equals(and GetHash Codeo 106 4.2 The persistence manager 110 Making an object persistent 110. Updating the persistent state of a detached instance 111. Retrieving a persistent object 112 Updating a persistent object transparently 113 Making an object transient 113 4.9 USing transitive persistence in NHibernate 114 Persistence by reachability 115. Cascading persistence with nhibernate 116- managing auction categories 117 Distinguishing between transient and detached instances 120 CONTENTS 4.4 Retrieving objects 121 Retrieving objects by identifier 122 Introducing Hibernate Query Language 123. Query by Criteria 124. Query by Example 124. Fetching strategies 125. Selecting a fetching strategy in mappings 127. Tuning object retrieval 132 4.5 Summary 193 5 Transactions, concurrency, and caching 134 5.1 Understanding database transactions 135 ADO. NET and Enterprise Services/COM+ transactions 136 The NHibernate Transaction apl 137. Flushing the session 138. Understanding connection-release modes 139 Understanding isolation levels 140. choosing an isolation level 141. Setting an isolation level 143. using pessimistic cking 143 5.2 Working with conversations 146 An example scenario 146: Using managed versioning 147 Optimistic and pessimistic locking compared 149. granularity ofa session 150. Other ways to implement optimistic locking 151 5.3 Caching theory and practice 152 Caching strategies and scopes 153. The Nhibernate cache architecture 155. Caching in practice 159 5.4 Summary 164 6 Advanced mapping concepts 166 6.1 Understanding the NHibernate type system 167 Associations and value types 167. Bridging from objects to database168· Mapping types 168· Built -in mapping types 169. Using mapping types 172 6.2 Mapping collections of value types 181 Storing value types in sets, bags, lists, and maps 187. Collections of components 186 6.3 Mapping entity associations 189 One-to-one associations 189 Many-to-many associations 193 6.4 Mapping polymorphic associations 200 Polymorphic many-to-one associations 201. Polymorphic collections 203. Polymorphic associations and table-per-concrete- class 204 6.5 Summary 205 CONTENTS Retrieving objects efficiently 207 7.1 Executing queries 208 The query interfaces 208 Binding parameters 211. Using named queries 214. Using query substitutions 215 7.2 Basic queries for objects 215 The simplest query 215. Using aliases 216. Polymorphic queries 217- Restriction 217- Comparison operators 218 String matching 220- Logical operators 221. Ordering query results 221 7. 3 Joining associations 222 NHibernate join options 223. Fetching associations 224. Using aliases with joins 226. Using implicit joins 228. Theta-style joins 229. Comparing identifiers 230 7.4 Writing report queries 291 Projection 232. Using aggregation 234: Grouping 234 Restricting groups with having 236. Improving performance with report queries 236 Obtaining Datasets 237 7.5 Advanced query techniques 238 Dynamic queries 238 Collection filters 240. Subqueries 242 6 Native SQL 248 Using the isQlQuery API 244 Named sQl queries 246 Customizing create, retrieve, update, and delete commands 248 7.7 Optimizing object retrieval 249 Solving the n+l selects problem 249. Using Enumerable( queries 252. Caching queries 253. Using profilers and NHibernate query analyzer 255 7. 8 Summary 255 PART 3 NHIBERNATE IN THE REAL WORLD 257 8 Developing Nhibernate applications 259 8.1 Inside the layers of an NHibernate application 260 Using patterns and methodologies 261. Building and testing the The persistence layer 268. The presentation layer 26o er 266 lavers 263. The domain model 263. The business la 8.2 Solving issues related to. NET features 270 Working with web applications 271..NET remoting 271 CONTENTS 8.3 Achieving goals and solving problems 272 Design goals applied to an Nhibernate application 272 Identifying and solving problems 274. Use the right tool for the right job 276 8.4 Integrating services: the case of audit logging 277 way 278. Other ways of integrating services 28 %t Doing it the hard way 278 Doing it the nhibern 8.5 Summary 284 9 Writing real-world domain models 286 9. 1 Development processes and tools 287 Top down: generating the mapping and the database from entities 288. Middle out: generating entities from the mapping 292. Bottom up: generating the mapping and the entities from the database 293. Automatic database schema maintenance 294 9.2 Legacy schemas 296 Mapping a table with a natural key 297- Mapping a table columns 302. Working with triggers 30 Type to map legacy 9.8 Understanding persistence ignorance 305 Abstracting persistence-related code 305 Applying the observer pattern to an entity 307 9. 4 Implementing the business logic 309 Business logic in the business layer 310- Business logic in the domain model 310- rules that aren t business rules 312 9.5 Data-binding entities 312 Implementing manual data binding 313. Using data-bound controls 314 Data binding using Nhibernate 315. data binding using Object views 315 9.6 Filling a dataSet with entities data 316 Converting an entity to a Dataset 316. Using Nhibernate to assist wvith conversion 317 9. 7 Summary 317 10 Architectural patterns for persistence 319 10.1 Designing the persistence layer 320 ng a simple persistence layer 321.Implementing generic persistence layer 326 CONTENTS 10.2 Implementing conversations 335 Approving a new auction 336. Loading objects on each request 337. Using detached persistent objects 338. Using the session-ter-conversation pattern 340- Choosing an approach to conversations 344 10.8 Using NHibernate in an Enterprise Services application 845 Rethinking DTOs 345. Enabling distributed transactions for NHibernatehelper 346 10.4 Summary 348 appendix a SQL fundamentals 349 appendix b going forward 352 index 355 Somewhere in the middle of 2004.i decided that i needed to take a look at additional ways to deal with persistence, beyond store procedures and code generation using Code Smith. At the time, i was mystified by the all the noise around orm, business objects, and domain-driven design. I had data sets and stored procedures, and I had code generation to make working with them a bit easier, and the world was good. But as I began to deal with more complex applications and attempted to learn from the col lective knowledge in the community, I began to see the problems with this approach Eventually, I understood the significant problem with my previous method of work- ing with data: I was building procedural applications, where the data was king and the application behavior was, at best, a distant second. This approach doesn t scale well with the complexity of the applications we need to build. Indeed, this programmatic approach has been largely superseded by object-oriented approaches. I see no reason that this shouldnt apply to dealing with data as well I can no longer recall what made me decide to focus on NHibernate--it was proba- bly an enthusiastic blog post, come to think of it. But whatever the reason, I made that choice. Four years later, I have yet to regret this decision, and I am proud to state that exactly 100 percent of my projects since then have used NHibernate for persistence That decision has paid off in many ways Two occasions come to mind in particular. The first was a very..tense meeting with a client, where the client DBA was furious about the need to support SQL Server. That was the clients requirement, but the dba saw it as an encroachment on his terri and he didnt like it one bit. In his eyes, dB2 on AS/400 was what the client had

...展开详情
试读 127P NHibernate in Action
立即下载 低至0.43元/次 身份认证VIP会员低至7折
一个资源只可评论一次,评论内容不能少于5个字
您会向同学/朋友/同事推荐我们的CSDN下载吗?
谢谢参与!您的真实评价是我们改进的动力~
关注 私信
上传资源赚钱or赚积分
最新推荐
NHibernate in Action 16积分/C币 立即下载
1/127
NHibernate in Action第1页
NHibernate in Action第2页
NHibernate in Action第3页
NHibernate in Action第4页
NHibernate in Action第5页
NHibernate in Action第6页
NHibernate in Action第7页
NHibernate in Action第8页
NHibernate in Action第9页
NHibernate in Action第10页
NHibernate in Action第11页
NHibernate in Action第12页
NHibernate in Action第13页
NHibernate in Action第14页
NHibernate in Action第15页
NHibernate in Action第16页
NHibernate in Action第17页
NHibernate in Action第18页
NHibernate in Action第19页
NHibernate in Action第20页

试读结束, 可继续阅读

16积分/C币 立即下载 >