problem 1 :Exception: In expected: Solution: See if the HQL statement query is an entity class and the mapping file property is correct: Copy to output directory à always copy. The build operation à embedded Resource.problem 2 :Exception: The Required property ' name ' is missing.Solution: See if the name attribute is missing from the problem 3 :Exception: The type initializer for "NHibernate.Proxy.CastleProxyFactory" throws an exception.Solution: NHibernate
1 In some cases, you might need to execute SQL statements, stored procedures, and so on, but NHibernate does not provide a way for us to execute SQL statements, but it can be done in some indirect way. 2 3 The following is a method executesql for executing SQL statements in NHibernate. 4 PublicIList ExecuteSQL (stringquery) {5IList result =NewArrayList ();6 7Isessionfactoryimplementor s =(isessionfactoryim
To write a nhibernate step
First download NHibernate (NHIBERNATE.LL, Iesi.Collections.dll)
Build a three-tier architecture
Write model, entity, entity class mapping files (customerentity, CustomerEntity.hbm.xml)
Note: Set the CustomerEntity.hbm.xml as an embedded resource4. Write the Dal (remember to refer to the first step of the DLL) and write the SessionManager class5. Writing bus
In NHibernate, Isessionfactory is thread-safe and corresponds to a database. It is the factory that generates ISession. and ISession is thread insecure.Creating a isessionfactory requires a lot more resources to consume. Therefore, we only create it once when the program is initialized, and then we use this isessionfactory.The creation of ISession consumes only a small amount of resources. So we're free to create.first, the original single-case patter
Call the stored procedure of Oracle with NHibernate, nhibernateoracleSummaryNHibernate2.1.1 can finally call the stored procedure of Oracle, but you must use nhib.pdf. driver. oracleDataClientDriver Driver (Oracle. dataAccess. dll), but this will cause hbm2ddl. keywords throws an exception, so it is not perfect.How does nhib.pdf call Oracle stored procedures?First, create a simple stored procedure in Oracle10g. Its first parameter must be of the SYS_R
We have adopted Nhibernate as the ermaping solution in the project. Currently, Nhibernate has released version 0.300. For details, see nhibernate.sourceforge.net. Currently, Nhibernate does not have an automatic configuration generation tool, it is annoying to generate configuration files one by one. through research, we have developed a configuration generation
Symptom: When a session opens a transaction, insert and update are executed first, and then icriteria is executed. list (), IQUERY. list (), or some sessions. get () method, and finally itransaction. commit (). Monitoring of the executed SQL statements, it is found that nhib.pdf has repeatedly executed a lot of update SQL operations.
Cause:
1. Flush-mode Problems
Nhibatis is executing icriteria. list (), IQUERY. list (), or session. if the get () method involves a database table A, and an object
chapter, we will explore the application configuration file and other configuration methods.
This is a typical configuration file:
The connection. provider attribute sets the database connection provider (which generally does not need to be changed unless you decide to implement the provider yourself ).
Connection. driver_class sets the driver class of the database (the driver class of sqlserver is set here ).
Connection. connection_string is the connection string of the database.
Show_ SQL se
In most cases NHibernate is configured with a configuration file, but we can also configure it using code, as follows:1. Create a ConfigurationUsing Nhibernate.cfg;var config = new Configuration (). SetProperty ( "Connection.provider", " NHibernate.Connection.DriverConnectionProvider "). SetProperty ( "Connection.driver_class", " NHibernate.Driver.SqlClientDriver "). SetProperty ( "dialect", "NHibernate.Dialect.MsSql2005Dialect ") . SetProperty ( "
The contents of this section
Introduced
Code generation Tools
Conclusion
Introduced
We spent a lot of space to introduce the relevant nhibernate knowledge, has always been with everyone to write code, first create the database schema, and then write the persistence class and mapping file, and finally write data manipulation methods, test methods. This is a typical database-driven development (Dbdd,database-driven developent) technology, but I did
Series Articles[Nhibernate] Architecture[NHibernate] Isessionfactory Configuration[NHibernate] Persistence class (persistent Classes)[NHibernate] O/R Mapping Basics[NHibernate] Collection Class (collections) mappings[NHibernate] A
Recently in the research of ORM, what kind of framework is what we wantThe significance of the development framework is
Develop more standard, more unified, not because different people write code is not the same
More efficient development, no need to reinvent the wheel, duplicate useless code, and streamline the development process
The operation efficiency is controlled, and the program stability has been improved.
The framework
On the. NET platform, there are many data persistence layer frameworks. This article briefly introduces the following types and recommends some learning resources:
1. nhib.pdf
2. nbear
3. Castle activerecord
4. ibatis. net
5. daab
Additional Introduction: dlinq
1. nhib.pdf
Speaking of nhib.pdf, I believe everyone is familiar with it. nhib.pdf comes from a very good Java-based hibernate relational persistence tool, which is persistent from the underlying database. net object to
1. Before use, you need to confirm the framework version, if it is 4.0 then use the following assembly to In the project that created Isessionfactory, reference the Nhprofiler installation directory under the HibernatingRhinos.Profiler.Appender.v4.dll2. Before creating the Isessionfactory statement (new Configuration ()). Configure (). Buildsessionfactory ();) Insert the following codeHibernatingRhinos.Profiler.Appender.NHibernate.NHibernateProfiler.Initialize ()3. Then open the Nhprofiler tool,
NHibernate level cache (tenth article)NHibernate first-level cache, the noun seems to be very cow B, difficult. is actually the ISession cache. stored in the operating cycle of the ISession. The level two cache is stored in the isessionfactory.first, ISession level cache testISession first-level cache is turned on by default, no configuration is required. The ISession cache can be used after the ISession is
In the July 2010 issue of MSDN Magazine, I began to introduce the process of building smart client applications for lending libraries. I named the project Alexandria and decided to use NHibernate for data access and to use the Rhino service bus to achieve reliable communication with the server.
NHibernate (nhforge.org) is an object-relational mapping (O/RM) framework, while the Rhino service Bus (GITHUB.CO
From today onwards, we will enter the NHibernate development study, first of all to some nhibernate add and remove changes to check the operation, these several learned, the basis of the dozen.Have the time also can study the domestic cyq. The data frame is also a fairly good framework.Below we follow the following steps:1. Entity classes and XML mappings2. The NHiberna
Some LINQ, very not easy to write, just want to raise eyebrow fart a bit, and behold with nhibernate a implementation, but the error, said is not support, I leaned.
Had to pinch his nose to write a large section of SQL, to give it. In this case of direct execution of SQL, I see that all my colleagues have written, all of which are return DataTable types.DataTable type, I used to use too much. The direct row, column this kind of processing, the feeling
brief introduction to the study of NHibernate, and the series of blogs will be updated continuously. We look forward to O (∩ _ ∩) O ~
What is the orm framework of nhib.pdf? What can we do?
Not all applications are very suitable. From this point, performance depends on hardware.Nhib.pdf is widely used
Nhib is an object/Relational Database ing tool for. NET environments. Object/relational Database ing (obje
Nhibernate requires the Model entity class for lazy= "true", field properties need to be added virtual beforeHow are the hibernate.cfg.xml of sqlserver2005 and oracle10g configured?The a:sqlserver2005 is configured as followsServer=.; Initial catalog=nhibernatetest; User Id=sa; Password=saThe oracle10g configuration is as follows:Data Source=kangshi; User Id=huobj; Password=huobjQ: An object of type ' NHibernate.Dialect.MsSqlCeDialect cannot be cast t
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.