From: NHibernate J. <mik...@us...> - 2006-10-24 08:02:34
|
[ http://jira.nhibernate.org/browse/NH-628?page=comments#action_14165 ] Sergey Koshcheyev commented on NH-628: -------------------------------------- Yes, I just don't know whether Fabio intended this test to fail or not. > HQL functions mapping > --------------------- > > Key: NH-628 > URL: http://jira.nhibernate.org/browse/NH-628 > Project: NHibernate > Type: Improvement > Components: Data Providers > Versions: 1.2.0.Beta1 > Reporter: Fabio Maulo > Assignee: Fabio Maulo > Attachments: NH628CastFunction.patch, NH628First.patch, NH628Next1.patch, NH628Next2.patch > > For columns types we have RegisterColumnType in the dialect to registr the supported types for a specific dialect. > With RegisterColumnType we can map a DbType with a equivalent specific dialect type although it isn't directly supported (a DbType.Guid can be mapped to a CHAR(38)). > Functions haven't mapping so if i write "from Person p where lenght(p.Name) > 10" i can't sure that work with all, or many, dialect. If the "lenght" function is not supported by an specific dialect i don't recive a NHibernate excetion directly with the message "lenght is not supported by XYZ dialect". > I think that he would be useful to have a collection of "basic" HQL function that can be specialized for a specific > dialect. > For example NHb can have in it's HQLfunctionList: > -a function named "hblenstr" that recive a parameter type NHibernateUtil.String (or a property with type NHibernateUtil.String) and return a NHibernateUtil.Int32. > -a function named "hbNullToInt" that recive two parameter; the first is a NHibernateUtil.Int16 or NHibernateUtil.Int32 or NHibernateUtil.Int64 (or a property...); the 2th is a constant of type NHibernateUtil.Int16 .. etc. > Heach dialect can have an overload of RegisterFunction( string hbFunctionName, dialectFunctionName ). > For the two function in the example we can have: > for Oracle9Dialect > RegisterFunction("hblenstr","length"); > RegisterFunction("hbNullToInt","nvl"); > for MsSql2000Dialect > RegisterFunction("hblenstr","length"); > for FirebirdDialect (or a specific FirebirdDialect with extended UDFs ;) ) > RegisterFunction("hblenstr","strlen"); > RegisterFunction("hbNullToInt","invl"); > Now we can write an HQL like this "from Person p where hblenstr(p.Name) > 10" and NHb can substitue "hblenstr" with apropiate dialect function (before substitution can control that the hblenstr revive de apropiate param type etc.). > This posible implementation don't have problems if an hbXYZ function have the same name of specific dialect function (i think the probability is very low but there are no problems). > The actual implementation of RegisterFunction don't need any adjustment because all continue to work. > Finally: > -If a dialect use actual implementation of RegisterFunction and a developer use this function in a HQL he can't be sure that all work fine when he need to change de hibernate.cfg.xml to change the dialect. > -If a dialect was implemented with RegisterFunction( string hbFunctionName, dialectFunctionName ) mapping and a developer use the hbXYZ function in a HQL he can have an hight probability that all work fine. > Bye. > Fabio. -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://jira.nhibernate.org/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira |