From: <leg...@at...> - 2003-10-30 16:09:13
|
The following comment has been added to this issue: Author: Michail Jekimov Created: Thu, 30 Oct 2003 10:08 AM Body: I would wish something similar, but on the HQL level. We are using Hibernate with the Oracle DBMS and I would like to be able to use my own PL/SQL function in my HQL queries (I would pass some scalar value to this function and it would return another scalar value, just like a built-in TO_CHAR function). Another way to do that is to use session.createSQLQuery(), but I don't want to depend on SQL just for this need. --------------------------------------------------------------------- View the issue: http://opensource.atlassian.com/projects/hibernate/secure/ViewIssue.jspa?key=HB-158 Here is an overview of the issue: --------------------------------------------------------------------- Key: HB-158 Summary: Customizable SQL Type: New Feature Status: Unassigned Priority: Major Project: Hibernate2 Components: core Versions: 2.0.1 Assignee: Reporter: TURIN ACCOUNT Created: Tue, 8 Jul 2003 3:38 PM Updated: Tue, 8 Jul 2003 3:38 PM Description: Ability to be able to get the SQL Hibernate would send to the database for a given query, be able to look at it and possibly tweak it (as a String) and then allow Hibernate to continue - sending the SQL on its way to the database. This allows for subtle hints and other database tricks one is often forced to do when you don't "own" the datamodel. --------------------------------------------------------------------- JIRA INFORMATION: This message is automatically generated by JIRA. If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa If you want more information on JIRA, or have a bug to report see: http://www.atlassian.com/software/jira |
From: <leg...@at...> - 2003-10-30 16:32:14
|
The following comment has been added to this issue: Author: Max Rydahl Andersen Created: Thu, 30 Oct 2003 10:31 AM Body: Michail - this should already be possible in HQL...everything it does not recognize is sent further down to the database.. Secondly, if you look at the OracleDialect you should be able to register your own functions ...just do what OracleDialect do in your own dialect ;) --------------------------------------------------------------------- View the issue: http://opensource.atlassian.com/projects/hibernate/secure/ViewIssue.jspa?key=HB-158 Here is an overview of the issue: --------------------------------------------------------------------- Key: HB-158 Summary: Customizable SQL Type: New Feature Status: Unassigned Priority: Major Project: Hibernate2 Components: core Versions: 2.0.1 Assignee: Reporter: TURIN ACCOUNT Created: Tue, 8 Jul 2003 3:38 PM Updated: Tue, 8 Jul 2003 3:38 PM Description: Ability to be able to get the SQL Hibernate would send to the database for a given query, be able to look at it and possibly tweak it (as a String) and then allow Hibernate to continue - sending the SQL on its way to the database. This allows for subtle hints and other database tricks one is often forced to do when you don't "own" the datamodel. --------------------------------------------------------------------- JIRA INFORMATION: This message is automatically generated by JIRA. If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa If you want more information on JIRA, or have a bug to report see: http://www.atlassian.com/software/jira |
From: <leg...@at...> - 2003-10-31 14:36:17
|
The following comment has been added to this issue: Author: Michail Jekimov Created: Fri, 31 Oct 2003 8:35 AM Body: Hi Max, thanks a lot for the tip - the subclassing of a particular dialect is a really cool idea! --------------------------------------------------------------------- View the issue: http://opensource.atlassian.com/projects/hibernate/secure/ViewIssue.jspa?key=HB-158 Here is an overview of the issue: --------------------------------------------------------------------- Key: HB-158 Summary: Customizable SQL Type: New Feature Status: Unassigned Priority: Major Project: Hibernate2 Components: core Versions: 2.0.1 Assignee: Reporter: TURIN ACCOUNT Created: Tue, 8 Jul 2003 3:38 PM Updated: Tue, 8 Jul 2003 3:38 PM Description: Ability to be able to get the SQL Hibernate would send to the database for a given query, be able to look at it and possibly tweak it (as a String) and then allow Hibernate to continue - sending the SQL on its way to the database. This allows for subtle hints and other database tricks one is often forced to do when you don't "own" the datamodel. --------------------------------------------------------------------- JIRA INFORMATION: This message is automatically generated by JIRA. If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa If you want more information on JIRA, or have a bug to report see: http://www.atlassian.com/software/jira |
From: <leg...@at...> - 2003-11-02 16:09:14
|
The following comment has been added to this issue: Author: Michail Jekimov Created: Sun, 2 Nov 2003 10:08 AM Body: Hello again, the dialect approach works fine, but unfortunately only for functions which accept not more than one parameter. With other functions Hibernate throws a QueryException with 'undefined alias' as a message. May be there could be a more general solution with something like SQLToken that would be passed unchanged to the database? Michail --------------------------------------------------------------------- View the issue: http://opensource.atlassian.com/projects/hibernate/secure/ViewIssue.jspa?key=HB-158 Here is an overview of the issue: --------------------------------------------------------------------- Key: HB-158 Summary: Customizable SQL Type: New Feature Status: Unassigned Priority: Major Project: Hibernate2 Components: core Versions: 2.0.1 Assignee: Reporter: TURIN ACCOUNT Created: Tue, 8 Jul 2003 3:38 PM Updated: Tue, 8 Jul 2003 3:38 PM Description: Ability to be able to get the SQL Hibernate would send to the database for a given query, be able to look at it and possibly tweak it (as a String) and then allow Hibernate to continue - sending the SQL on its way to the database. This allows for subtle hints and other database tricks one is often forced to do when you don't "own" the datamodel. --------------------------------------------------------------------- JIRA INFORMATION: This message is automatically generated by JIRA. If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa If you want more information on JIRA, or have a bug to report see: http://www.atlassian.com/software/jira |
From: <leg...@at...> - 2003-11-03 09:20:13
|
The following comment has been added to this issue: Author: Michail Jekimov Created: Mon, 3 Nov 2003 3:19 AM Body: An addition: it seems that I can use proprietary SQL functions in the where clause of my HQL statements but not in the select clause. Is that a known issue, and if yes, is it planned to allow using SQL functions in the select clause? Michail. --------------------------------------------------------------------- View the issue: http://opensource.atlassian.com/projects/hibernate/secure/ViewIssue.jspa?key=HB-158 Here is an overview of the issue: --------------------------------------------------------------------- Key: HB-158 Summary: Customizable SQL Type: New Feature Status: Unassigned Priority: Major Project: Hibernate2 Components: core Versions: 2.0.1 Assignee: Reporter: TURIN ACCOUNT Created: Tue, 8 Jul 2003 3:38 PM Updated: Tue, 8 Jul 2003 3:38 PM Description: Ability to be able to get the SQL Hibernate would send to the database for a given query, be able to look at it and possibly tweak it (as a String) and then allow Hibernate to continue - sending the SQL on its way to the database. This allows for subtle hints and other database tricks one is often forced to do when you don't "own" the datamodel. --------------------------------------------------------------------- JIRA INFORMATION: This message is automatically generated by JIRA. If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa If you want more information on JIRA, or have a bug to report see: http://www.atlassian.com/software/jira |
From: <leg...@at...> - 2003-11-03 09:35:14
|
The following comment has been added to this issue: Author: Gavin King Created: Mon, 3 Nov 2003 3:34 AM Body: Yes, it is very well-known and has a very good reason :) Hibernate 2.1 allows you to specify Dialect-specific SQL functions, which may then be used in the SELECT clause. --------------------------------------------------------------------- View the issue: http://opensource.atlassian.com/projects/hibernate/secure/ViewIssue.jspa?key=HB-158 Here is an overview of the issue: --------------------------------------------------------------------- Key: HB-158 Summary: Customizable SQL Type: New Feature Status: Unassigned Priority: Major Project: Hibernate2 Components: core Versions: 2.0.1 Assignee: Reporter: TURIN ACCOUNT Created: Tue, 8 Jul 2003 3:38 PM Updated: Tue, 8 Jul 2003 3:38 PM Description: Ability to be able to get the SQL Hibernate would send to the database for a given query, be able to look at it and possibly tweak it (as a String) and then allow Hibernate to continue - sending the SQL on its way to the database. This allows for subtle hints and other database tricks one is often forced to do when you don't "own" the datamodel. --------------------------------------------------------------------- JIRA INFORMATION: This message is automatically generated by JIRA. If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa If you want more information on JIRA, or have a bug to report see: http://www.atlassian.com/software/jira |
From: <leg...@at...> - 2003-11-03 10:13:14
|
The following comment has been added to this issue: Author: Michail Jekimov Created: Mon, 3 Nov 2003 4:12 AM Body: Hello Gavin, I tried to register my PL/SQL function by subclassing the OracleDialect in the following way: public class MyDatabaseDialect extends OracleDialect { public MyDatabaseDialect() { super(); registerFunction("get_price", new SQLFunction() { public Type getReturnType(Type columnType, Mapping mapping) { return Hibernate.INTEGER; } public boolean hasArguments() { return true; } public boolean hasParenthesesIfNoArguments() { return true; } }); } } When I try to execute a query with this function, Hibernate throws the following: net.sf.hibernate.QueryException: alias or expression expected in SELECT [ select min( get_price(stockItem.id, 1.0)) from StockItem stockItem where stockItem.stock.id = ?] at net.sf.hibernate.hql.SelectParser.token(SelectParser.java:74) at net.sf.hibernate.hql.ClauseParser.token(ClauseParser.java:87) at net.sf.hibernate.hql.ClauseParser.end(ClauseParser.java:114) at net.sf.hibernate.hql.PreprocessingParser.end(PreprocessingParser.java:143) at net.sf.hibernate.hql.ParserHelper.parse(ParserHelper.java:30) When I register a function that needs only one parameter everything works fine. But I really need to pass more than one parameter to it. Is it a wrong way to define my own SQL functions? --------------------------------------------------------------------- View the issue: http://opensource.atlassian.com/projects/hibernate/secure/ViewIssue.jspa?key=HB-158 Here is an overview of the issue: --------------------------------------------------------------------- Key: HB-158 Summary: Customizable SQL Type: New Feature Status: Unassigned Priority: Major Project: Hibernate2 Components: core Versions: 2.0.1 Assignee: Reporter: TURIN ACCOUNT Created: Tue, 8 Jul 2003 3:38 PM Updated: Tue, 8 Jul 2003 3:38 PM Description: Ability to be able to get the SQL Hibernate would send to the database for a given query, be able to look at it and possibly tweak it (as a String) and then allow Hibernate to continue - sending the SQL on its way to the database. This allows for subtle hints and other database tricks one is often forced to do when you don't "own" the datamodel. --------------------------------------------------------------------- JIRA INFORMATION: This message is automatically generated by JIRA. If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa If you want more information on JIRA, or have a bug to report see: http://www.atlassian.com/software/jira |
From: <leg...@at...> - 2003-11-03 10:20:14
|
The following comment has been added to this issue: Author: Gavin King Created: Mon, 3 Nov 2003 4:19 AM Body: It does not yet support multiple arguments. --------------------------------------------------------------------- View the issue: http://opensource.atlassian.com/projects/hibernate/secure/ViewIssue.jspa?key=HB-158 Here is an overview of the issue: --------------------------------------------------------------------- Key: HB-158 Summary: Customizable SQL Type: New Feature Status: Unassigned Priority: Major Project: Hibernate2 Components: core Versions: 2.0.1 Assignee: Reporter: TURIN ACCOUNT Created: Tue, 8 Jul 2003 3:38 PM Updated: Tue, 8 Jul 2003 3:38 PM Description: Ability to be able to get the SQL Hibernate would send to the database for a given query, be able to look at it and possibly tweak it (as a String) and then allow Hibernate to continue - sending the SQL on its way to the database. This allows for subtle hints and other database tricks one is often forced to do when you don't "own" the datamodel. --------------------------------------------------------------------- JIRA INFORMATION: This message is automatically generated by JIRA. If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa If you want more information on JIRA, or have a bug to report see: http://www.atlassian.com/software/jira |
From: <leg...@at...> - 2003-11-03 10:25:13
|
The following comment has been added to this issue: Author: Max Rydahl Andersen Created: Mon, 3 Nov 2003 4:23 AM Body: so - should we throw this at David ? (he talked about doing this in Aarhus) --------------------------------------------------------------------- View the issue: http://opensource.atlassian.com/projects/hibernate/secure/ViewIssue.jspa?key=HB-158 Here is an overview of the issue: --------------------------------------------------------------------- Key: HB-158 Summary: Customizable SQL Type: New Feature Status: Unassigned Priority: Major Project: Hibernate2 Components: core Versions: 2.0.1 Assignee: Reporter: TURIN ACCOUNT Created: Tue, 8 Jul 2003 3:38 PM Updated: Tue, 8 Jul 2003 3:38 PM Description: Ability to be able to get the SQL Hibernate would send to the database for a given query, be able to look at it and possibly tweak it (as a String) and then allow Hibernate to continue - sending the SQL on its way to the database. This allows for subtle hints and other database tricks one is often forced to do when you don't "own" the datamodel. --------------------------------------------------------------------- JIRA INFORMATION: This message is automatically generated by JIRA. If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa If you want more information on JIRA, or have a bug to report see: http://www.atlassian.com/software/jira |
From: <leg...@at...> - 2003-11-03 15:09:14
|
The following comment has been added to this issue: Author: Michail Jekimov Created: Mon, 3 Nov 2003 9:08 AM Body: Hello, I tried to implement the discussed functionality. Here is the result as a patch. Unfortunately I had problems with cvs connection to the sourceforge host. So, this is the diff patch for Hibernate 2.1 beta 4. Surely I cannot guarantee that these changes won't produce any side effects, but I hope it will help you if you decide to implement this feature. --- SelectParser_old.java Mon Nov 3 15:59:06 2003 +++ SelectParser.java Mon Nov 3 15:59:06 2003 @@ -35,6 +35,7 @@ private boolean first; private boolean afterNew; private boolean insideNew; + private boolean aggregateAddSelectScalar; private Class holderClass; private final SelectPathExpressionParser pathExpressionParser; @@ -71,7 +72,7 @@ insideNew = true; } else if ( token.equals(StringHelper.COMMA) ) { - if (ready) throw new QueryException("alias or expression expected in SELECT"); + if (!aggregate && ready) throw new QueryException("alias or expression expected in SELECT"); q.appendScalarSelectToken(StringHelper.COMMA_SPACE); ready=true; } @@ -118,6 +119,7 @@ // the name of an SQL function if (!ready) throw new QueryException(", expected before aggregate function in SELECT: " + token); aggregate = true; + aggregateAddSelectScalar = true; aggregateFuncTokenList.add(lctoken); ready = false; q.appendScalarSelectToken(token); @@ -136,18 +138,31 @@ } } else if (aggregate) { + boolean constantToken = false; if (!ready) throw new QueryException("( expected after aggregate function in SELECT"); + try { ParserHelper.parse(aggregatePathExpressionParser, q.unalias(token), ParserHelper.PATH_SEPARATORS, q); + } catch (QueryException qex) { + constantToken = true; + } - if ( aggregatePathExpressionParser.isCollectionValued() ) { - q.addCollection( - aggregatePathExpressionParser.getCollectionName(), - aggregatePathExpressionParser.getCollectionRole() - ); - } - q.appendScalarSelectToken( aggregatePathExpressionParser.getWhereColumn() ); - q.addSelectScalar( aggregateType(aggregateFuncTokenList, aggregatePathExpressionParser.getWhereColumnType(), q ) ); - aggregatePathExpressionParser.addAssociation(q); + if (constantToken) { + q.appendScalarSelectToken(token); + } + else { + if ( aggregatePathExpressionParser.isCollectionValued() ) { + q.addCollection( + aggregatePathExpressionParser.getCollectionName(), + aggregatePathExpressionParser.getCollectionRole() + ); + } + q.appendScalarSelectToken( aggregatePathExpressionParser.getWhereColumn() ); + if (aggregateAddSelectScalar) { + q.addSelectScalar( aggregateType(aggregateFuncTokenList, aggregatePathExpressionParser.getWhereColumnType(), q ) ); + aggregateAddSelectScalar = false; + } + aggregatePathExpressionParser.addAssociation(q); + } } else { if (!ready) throw new QueryException(", expected in SELECT"); ===================================================================== --- QueryTranslator_old.java Mon Nov 3 15:59:06 2003 +++ QueryTranslator.java Mon Nov 3 15:59:06 2003 @@ -654,6 +654,12 @@ Object next = iter.next(); if (next instanceof String) { String token = (String) next; + if (StringHelper.OPEN_PAREN.equals(token)) { + isSubselect = true; + } + else if (StringHelper.CLOSE_PAREN.equals(token)) { + isSubselect = superQuery!=null; + } String lc = token.toLowerCase(); if ( lc.equals(StringHelper.COMMA_SPACE) ) { if (nolast) { --------------------------------------------------------------------- View the issue: http://opensource.atlassian.com/projects/hibernate/secure/ViewIssue.jspa?key=HB-158 Here is an overview of the issue: --------------------------------------------------------------------- Key: HB-158 Summary: Customizable SQL Type: New Feature Status: Unassigned Priority: Major Project: Hibernate2 Components: core Versions: 2.0.1 Assignee: Reporter: TURIN ACCOUNT Created: Tue, 8 Jul 2003 3:38 PM Updated: Tue, 8 Jul 2003 3:38 PM Description: Ability to be able to get the SQL Hibernate would send to the database for a given query, be able to look at it and possibly tweak it (as a String) and then allow Hibernate to continue - sending the SQL on its way to the database. This allows for subtle hints and other database tricks one is often forced to do when you don't "own" the datamodel. --------------------------------------------------------------------- JIRA INFORMATION: This message is automatically generated by JIRA. If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa If you want more information on JIRA, or have a bug to report see: http://www.atlassian.com/software/jira |