|
|
|
[
Permlink
| « Hide
]
Joshua Davis - 18/Apr/05 06:42 AM
The HQL translator should interpret that as a constant, without the quotes (unless somebody broke something ;-> ). How is that constant defined? Is that the part in square brackets?
Yes, the bit in the brackets is the definition of the constant.
As far as I can tell, it _is_ interpreting it as a comment. Hence the error about "Unexpected AST Node: 'A'". Perhaps how it is being interpreted is the problem? No, it's not interpreting it as a comment. What I meant was, in your example HQL:
from Foo foo where foo.status = foo.bar.Foo.STATUS_APPROVED [ Foo.STATUS_APPROVED = new Character('A') ] What is the second line with the square brackets around it? Is that how Foo.STATUS_APPROVED is declared in the JAVA code? The reason I ask is that the new HQL translator is attempting to resolve foo.bar.Foo.STATUS_APPROVED using the context class loader. The last symbol in the path is STATUS_APPROVED, and that is expected to be a field in foo.bar.Foo with static scope and public visibility. Is that the case here? If not, the new HQL translator will continue on trying to bind foo.bar.Foo.STATUS_APPROVED to something. It finds/resolves the static reference; note the "unexpected AST node : 'A'", as is the value of that static reference.
Robert, we'd need to see the AST for this error. Enable debug on the org.hibernate.hql.AST logger, and paste the resulting tree here. It now supports Characters fine. However, it no longer supports Strings (and this time I mean Strings! ;)
Here's the HQL: ------ select contact from SupplierWotifContact contact where contact.country.isoCountryCode = com.wotif.jaguar.domain.Country.AUSTRALIA_ISO_CODE and contact.region is null ------ [com.wotif.jaguar.domain.County.AUSTRALIA_ISO_CODE = "AU"] And here's the AST tree, as requested: 19/04/2005 10:01:59 org.hibernate.hql.ast.QueryTranslatorImpl analyze FINE: --- SQL AST --- \-[SELECT] QueryNode: 'SELECT' querySpaces (COUNTRY,SUPPLIER_WOTIF_CONTACT) +-[SELECT_CLAUSE] SelectClause: '{select clause}' | +-[ALIAS_REF] IdentNode: 'supplierwo0_.ID as ID' {alias=contact, className=com.wotif.jaguar.domain.SupplierWotifContact, tableAlias=supplierwo0_} | \-[SQL_TOKEN] SqlFragment: 'supplierwo0_.COUNTRY as COUNTRY37_, supplierwo0_.REGION as REGION37_, supplierwo0_.STAFF_MEMBER as STAFF4_37_, supplierwo0_.DESCRIPTION as DESCRIPT5_37_' +-[FROM] FromClause: 'from' FromClause{level=1, fromElementCounter=2, fromElements=2, fromElementByClassAlias=[contact], fromElementByTableAlias=[country1_, supplierwo0_], fromElementsByPath=[contact.country], collectionJoinFromElementsByPath=[], impliedElements=[]} | +-[FROM_FRAGMENT] FromElement: 'SUPPLIER_WOTIF_CONTACT supplierwo0_' FromElement{explicit,not a collection join,not a fetch join,fetch non-lazy properties,classAlias=contact,role=null,tableName=SUPPLIER_WOTIF_CONTACT,tableAlias=supplierwo0_,colums={,className=com.wotif.jaguar.domain.SupplierWotifContact}} | \-[FROM_FRAGMENT] ImpliedFromElement: 'COUNTRY country1_' ImpliedFromElement{implied,not a collection join,not a fetch join,fetch non-lazy properties,classAlias=null,role=null,tableName=COUNTRY,tableAlias=country1_,colums={supplierwo0_.COUNTRY ,className=com.wotif.jaguar.domain.Country}} \-[WHERE] SqlNode: 'where' +-[AND] SqlNode: 'and' | +-[EQ] SqlNode: '=' | | +-[DOT] DotNode: 'country1_.ISO_CountryCode' {propertyName=isoCountryCode,dereferenceType=4,propertyPath=isoCountryCode,path=contact.country.isoCountryCode,tableAlias=country1_,className=com.wotif.jaguar.domain.Country,classAlias=null} | | | +-[DOT] DotNode: 'supplierwo0_.COUNTRY' {propertyName=country,dereferenceType=1,propertyPath=country,path=contact.country,tableAlias=country1_,className=com.wotif.jaguar.domain.Country,classAlias=null} | | | | +-[ALIAS_REF] IdentNode: 'supplierwo0_.ID' {alias=contact, className=com.wotif.jaguar.domain.SupplierWotifContact, tableAlias=supplierwo0_} | | | | \-[IDENT] IdentNode: 'country' {originalText=country} | | | \-[IDENT] IdentNode: 'isoCountryCode' {originalText=isoCountryCode} | | \-[CONSTANT] DotNode: ''AU'' {propertyName=AUSTRALIA_ISO_CODE,dereferenceType=6,propertyPath=AUSTRALIA_ISO_CODE,path=com.wotif.jaguar.domain.Country.AUSTRALIA_ISO_CODE,no from element} | \-[IS_NULL] SqlNode: 'is null' | \-[DOT] DotNode: 'supplierwo0_.REGION' {propertyName=region,dereferenceType=ROOT_LEVEL,propertyPath=region,path=contact.region,tableAlias=supplierwo0_,className=com.wotif.jaguar.domain.SupplierWotifContact,classAlias=contact} | +-[ALIAS_REF] IdentNode: 'supplierwo0_.ID' {alias=contact, className=com.wotif.jaguar.domain.SupplierWotifContact, tableAlias=supplierwo0_} | \-[IDENT] IdentNode: 'region' {originalText=region} \-[THETA_JOINS] SqlNode: '{theta joins}' \-[SQL_TOKEN] SqlFragment: 'supplierwo0_.COUNTRY=country1_.CountryCode' 19/04/2005 10:01:59 org.hibernate.hql.ast.ErrorCounter reportError SEVERE: *** ERROR: <AST>:0:0: unexpected AST node: 'AU' Actually, I briefly had a bug, which I fixed, possibly you happened to update from CVS while the bug was still there. Re-update and retry. Note that you MUST run "ant antlr".
|
||||||||||||||||||||||||||||||||||||||||||||||||||||