to começando a utilizar a api criteira… no meu codigo o list resultante tem todos os campos da classe que eu criei o criteria… mas eu precisava trazer os campos das classes que eu fiz os 2 joins… como eu faço isso??
segue codigo
public ConsGlobal(Long mes){
em = (EntityManager) Conectar.getsession();
sess = (Session) em.getDelegate();
se suas classes tem os relacionamentos corretos, deveriam vir carregados, isso se o fetch não estiver lazy
A
andreReisLima
o problema é de relacionamento mesmo…mas nao to conseguindo resolver… alguem pode me ajudar?? O Campo CadConta é a chave entre as tabelas… 1 registro na TbrjCadContas pra muitos na ConsOrcamento… segue as 2 classes
publicclassTbrjCadContasimplementsSerializable{privatestaticfinallongserialVersionUID=1L;@Id@GeneratedValue(strategy=GenerationType.IDENTITY)@Basic(optional=false)@Column(name="idTBRJ_CAD_CONTAS")privateIntegeridTBRJCADCONTAS;@Column(name="COD_CONTA")privateBigIntegercodConta;@Column(name="CONTA")privateStringconta;@Column(name="NATUREZA")privateStringnatureza;publicTbrjCadContas(){}publicTbrjCadContas(IntegeridTBRJCADCONTAS){this.idTBRJCADCONTAS=idTBRJCADCONTAS;}publicIntegergetIdTBRJCADCONTAS(){returnidTBRJCADCONTAS;}publicvoidsetIdTBRJCADCONTAS(IntegeridTBRJCADCONTAS){this.idTBRJCADCONTAS=idTBRJCADCONTAS;}publicBigIntegergetCodConta(){returncodConta;}publicvoidsetCodConta(BigIntegercodConta){this.codConta=codConta;}publicStringgetConta(){returnconta;}publicvoidsetConta(Stringconta){this.conta=conta;}publicStringgetNatureza(){returnnatureza;}publicvoidsetNatureza(Stringnatureza){this.natureza=natureza;}@OverridepublicinthashCode(){inthash=0;hash+=(idTBRJCADCONTAS!=null?idTBRJCADCONTAS.hashCode():0);returnhash;}@Overridepublicbooleanequals(Objectobject){// TODO: Warning - this method won't work in the case the id fields are not setif(!(objectinstanceofTbrjCadContas)){returnfalse;}TbrjCadContasother=(TbrjCadContas)object;if((this.idTBRJCADCONTAS==null&&other.idTBRJCADCONTAS!=null)||(this.idTBRJCADCONTAS!=null&&!this.idTBRJCADCONTAS.equals(other.idTBRJCADCONTAS))){returnfalse;}returntrue;}@OverridepublicStringtoString(){return"tabelas.TbrjCadContas[idTBRJCADCONTAS="+idTBRJCADCONTAS+"]";}}
JonaTHANNM
eu tive um problema muito semelhante ao seu um tempo atras… e consegui resolver da seguinte maneira.