Problema com JOIN (HQl) e Hibernate (relacionamento

Olá…

pessoal to com um problema aqui e não estou conseguindo resolver…

tenho duas classes ( dois Beans) que representam duas tabelas no banco… uma dessas classes possui chave(PK) composta…
mapeiei dessa forma …

@Entity
@Table(name = "ESTABELECIMENTO_PRODUTO")
public class ProdutosEstabelecimento extends GenericoBean {

	@Id
	private ProdutosEstabelecimentoPk id;
                
                @Column(name = "DT_MODIFICACAO")
	private Date dataUltimaAlteracao;

	@Column(name = "DT_CRIACAO")
	private Date dataCriacao;

	@Column(name = "P2")
	private Double p2;

	@Column(name = "P13")
	private Double p13;

	@Column(name = "P20")
	private Double p20;

	@Column(name = "P45")
	private Double p45;

	@Column(name = "P90")
	private Double p90;

	@Column(name = "FL_ATIVO")
	private int ativo;

/*get e set*/

--------------------------------------------------------------------------

@Embeddable
public class ProdutosEstabelecimentoPk extends GenericoBean {

	@Column(name = "CD_ESTABELECIMENTO")
	private Long estabelecimento;

	@Column(name = "CD_OPERADORA")
	private Long cdOperadora;

	public Long getCdOperadora() {
		return this.cdOperadora;
	}

/*get e set*/

-----------------------------------------------------------------------

@Entity
@Table(name = "VW_ESTAB_ESTADO")
public class Estabelecimento extends GenericoBean {

	@Column(name = "COD_ESTABELECIMENTO")
	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	private Long id;

	@Column(name = "NOME_FANTASIA")
	private String nomeFantasia;

	@Column(name = "CNPJ")
	private String cnpj;

	@Column(name = "RAZAO_SOCIAL")
	private String razaoSocial;

	@Column(name = "CD_ENDERECO")
	private String endereco;

	@Column(name = "CD_ESTADO")
	private String estado;

	@Column(name = "LOCALIDADE")
	private String cidade;

	@JoinColumn(name = "CD_ESTABELECIMENTO")
	private ProdutosEstabelecimento produtosEstabelecimento;

/*get e set*/

agora preciso fazr um join dessas duas classes…
eu fiz um HQL desse jeito


public List buscaEstabelecimentosInativos(String sigla) {
		
		Estabelecimento estabelecimento= new Estabelecimento();
		estabelecimento.setEstado(sigla);
		
		final String siglaFinal = sigla;
		
		List list = getHibernateTemplate().executeFind(new HibernateCallback() {
			public Object doInHibernate(Session session)
					throws HibernateException, SQLException {
				String hql = "select estb from Estabelecimento estb "
						+ "left outer join estb.produtosEstabelecimento "
						+ "prod WHERE prod.ativo= 1 "
						+ "AND estb.estado like '" + siglaFinal + "' order by "
						+ "estb.cidade, estb.nomeFantasia";
				return session.createQuery(hql).list();
			}
		});
		
		if (list != null) {
			return list;
		} else {
			System.out.println("Não possuem estabelecimentos neste estado");
			return null;
		}
	}
	

o erro q me da é o seguinte:

java.lang.NullPointerException
at org.hibernate.hql.ast.HqlSqlWalker.createFromJoinElement(HqlSqlWalker.java:315)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.joinElement(HqlSqlBaseWalker.java:3268)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.fromElement(HqlSqlBaseWalker.java:3060)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.fromElementList(HqlSqlBaseWalker.java:2938)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.fromClause(HqlSqlBaseWalker.java:688)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.query(HqlSqlBaseWalker.java:544)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.selectStatement(HqlSqlBaseWalker.java:281)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.statement(HqlSqlBaseWalker.java:229)
at org.hibernate.hql.ast.QueryTranslatorImpl.analyze(QueryTranslatorImpl.java:218)
at org.hibernate.hql.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:158)
at org.hibernate.hql.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:105)
at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:75)
at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:54)
at org.hibernate.engine.query.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:71)
at org.hibernate.impl.AbstractSessionImpl.getHQLQueryPlan(AbstractSessionImpl.java:134)
at org.hibernate.impl.AbstractSessionImpl.createQuery(AbstractSessionImpl.java:113)
at org.hibernate.impl.SessionImpl.createQuery(SessionImpl.java:1600)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.springframework.orm.hibernate3.HibernateTemplate$CloseSuppressingInvocationHandler.invoke(HibernateTemplate.java:1183)
at $Proxy38.createQuery(Unknown Source)
at br.com.getnet.valegas.model.dao.impl.EstabelecimentoDaoImpl$1.doInHibernate(EstabelecimentoDaoImpl.java:55)
at org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:366)
at org.springframework.orm.hibernate3.HibernateTemplate.executeFind(HibernateTemplate.java:338)
at br.com.getnet.valegas.model.dao.impl.EstabelecimentoDaoImpl.buscaEstabelecimentosInativos(EstabelecimentoDaoImpl.java:47)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:288)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:181)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:148)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:100)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:170)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:176)
at $Proxy32.buscaEstabelecimentosInativos(Unknown Source)
at br.com.getnet.valegas.controller.mbean.ProdutosEstabelecimentoMBean.buscaEstabelecimentosInativos(ProdutosEstabelecimentoMBean.java:478)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.apache.myfaces.el.MethodBindingImpl.invoke(MethodBindingImpl.java:129)
at org.apache.myfaces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:63)
at javax.faces.component.UICommand.broadcast(UICommand.java:106)
at javax.faces.component.UIViewRoot._broadcastForPhase(UIViewRoot.java:90)
at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:164)
at org.apache.myfaces.lifecycle.LifecycleImpl.invokeApplication(LifecycleImpl.java:316)
at org.apache.myfaces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:86)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:106)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.displaytag.filter.ResponseOverrideFilter.doFilter(ResponseOverrideFilter.java:125)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at br.com.getnet.valegas.controller.filter.AuthorizationFilter.doFilter(AuthorizationFilter.java:65)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at br.com.getnet.valegas.controller.filter.AuthenticationFilter.doFilter(AuthenticationFilter.java:55)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.springframework.orm.hibernate3.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:174)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:77)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:60)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:77)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.apache.myfaces.component.html.util.ExtensionsFilter.doFilter(ExtensionsFilter.java:122)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
at java.lang.Thread.run(Thread.java:595)

Qual pode me dar uma luz?

Thanks

Verifique com atenção ao seguinte:

Tipos de dados primitivos (Ex: int, long) não recebem valor null.
Verifique se o hibernate está tentando atribuir um valor nulo aos tipos primitivos.

Possíveis soluções:

1- Altere de int para Integer.

2- No construtor da Classe inicialize todos atributos de tipo primitivo com 0 (Zero).

Acredito que esse seja seu problema.