//for SQL queries session.CreateSQLQuery("SELECT * FROM [Order] WHERE Id = :id").SetParameter("id", 1).List(); //for HQL queries session.CreateQuery("from Order where id = :id").SetParameter("id", 1).List();
Thursday, June 7, 2012
NHibernate Pitfalls: SQL Queries and Parameter Prefix
When you execute an SQL query with NHibernate with named parameters, you would perhaps expect them to be prefixed with a symbol specific to the current DB you are accessing, for example, @ for SQL Server and : for Oracle; that is not the case. NHibernate requires that you always use it’s DB-neutral parameter prefix, :, the same that you use for HQL queries:
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment