[
http://opensource.atlassian.com/projects/hibernate/browse/HHH-3459?page=c...
]
Ryan Dearing updated HHH-3459:
------------------------------
Attachment: BasicFormatterImpl.patch
Patch that fixes this issue and adds unit test.
NullPointerException in Formatter.isFunctionName with certain SQL
when pretty format is used
--------------------------------------------------------------------------------------------
Key: HHH-3459
URL:
http://opensource.atlassian.com/projects/hibernate/browse/HHH-3459
Project: Hibernate Core
Issue Type: Bug
Components: query-sql
Affects Versions: 3.2.6
Reporter: Scott Feldstein
Attachments: BasicFormatterImpl.patch
A NullPointerException is thrown when hibernate.show_sql=true &&
hibernate.format_sql=true while exec'ing sql with quotes around the stmt:
(taken from an embedded groovy script)
---------
def sess = getSession()
def HQL = """
(select count(*) from TABLE)
"""
sess
.createSQLQuery(HQL)
.list()
------------
This is valid SQL and is typically used in my app as such:
(select count(*) from TABLE1) UNION ALL (select count(*) from TABLE2) ...
Here is the stack trace in hibernate:
java.lang.NullPointerException
at org.hibernate.pretty.Formatter.isFunctionName(Formatter.java:342)
at org.hibernate.pretty.Formatter.openParen(Formatter.java:323)
at org.hibernate.pretty.Formatter.format(Formatter.java:134)
at org.hibernate.jdbc.AbstractBatcher.format(AbstractBatcher.java:410)
at org.hibernate.jdbc.AbstractBatcher.log(AbstractBatcher.java:404)
at org.hibernate.jdbc.AbstractBatcher.getPreparedStatement(AbstractBatcher.java:482)
at org.hibernate.jdbc.AbstractBatcher.getPreparedStatement(AbstractBatcher.java:423)
at org.hibernate.jdbc.AbstractBatcher.prepareQueryStatement(AbstractBatcher.java:139)
at org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:1547)
at org.hibernate.loader.Loader.doQuery(Loader.java:673)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:236)
at org.hibernate.loader.Loader.doList(Loader.java:2220)
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2104)
at org.hibernate.loader.Loader.list(Loader.java:2099)
at org.hibernate.loader.custom.CustomLoader.list(CustomLoader.java:289)
at org.hibernate.impl.SessionImpl.listCustomQuery(SessionImpl.java:1695)
at org.hibernate.impl.AbstractSessionImpl.list(AbstractSessionImpl.java:142)
at org.hibernate.impl.SQLQueryImpl.list(SQLQueryImpl.java:152)
--
This message is automatically generated by JIRA.
For more information on JIRA, see:
http://www.atlassian.com/software/jira