| 
					
						 net.sf.hibernate.QueryException: undefined alias: {E 
 [select distinct {E.*} from com.claimiq.hibernate.Entity {E} , com.claimiq.hibernate.StakeholderClaim {SC}, com.claimiq.hibernate.Claim {C}, com.claimiq.hibernate.Loss {L}, com.claimiq.hibernate.StakeholderTypeText {STT} where {SC}.StakeholderEntityID = {E}.EntityID and {C}.LossID = {L}.LossID and {SC}.ClaimID = {C}.ClaimID and {SC}.StakeholderTypeID = {STT}.StakeholderTypeID and {STT}.StakeholderTypeAbbreviation = :stakeholderAbbr and {L}.LossCode = :lossCode and {E}.ExternalID  = :externalId ]
 
 
 Any pointers regarding the error in SQL.
 
 //code
 
 
         String SQL = "select distinct {E.*} from Entity E , StakeholderClaim {SC}, Claim {C}, Loss {L}, StakeholderTypeText {STT} " +
                         "where {SC}.StakeholderEntityID = E.EntityID " + 
                         "and {C}.LossID = {L}.LossID " +
                         "and {SC}.ClaimID = {C}.ClaimID " +
                         "and {SC}.StakeholderTypeID = {STT}.StakeholderTypeID " + 
                         "and {STT}.StakeholderTypeAbbreviation = :stakeholderAbbr " + 
                         "and {L}.LossCode = :lossCode " +
                         "and E.ExternalID ";
         if(externalId != null){
         	SQL += " = :externalId ";
         } else {
         	SQL += " IS NULL ";
         }
 
         Query query = (Query)session.createQuery(SQL)
                         .setString("stakeholderAbbr", stakeholderTypeAbbr)
                         .setString("lossCode", lossCode);
         if(externalId != null){
         	query.setString("externalId", externalId);
         }
         
         Entity entity = (Entity)query.uniqueResult();
 
 
 
 Hibernate version: 
 2.1.6
 Mapping documents:
 
 Code between sessionFactory.openSession() and session.close():
 
 Full stack trace of any exception that occurs:
 
 Name and version of the database you are using:
 
 The generated SQL (show_sql=true):
 
 Debug level Hibernate log excerpt: 
					
  
						
					 |