java - Why I'm getting Javassist objects in the middle of a result set? -


i'm having strange problem when try retrieve entities database. table entities lives have 4 rows. when try select rows list first , last elements loaded correct, however, second , third has properties null. here print of debug console:

javassist problem debug

the entity simple, can see below:

@entity @table(name = "empresa") public class empresa implements serializable {      @id     @generatedvalue(strategy = generationtype.identity)     @column(name = "id_empresa")     private integer idempresa;     @basic(optional = false)     @column(name = "nome_empresa")     @ordercolumn     private string nomeempresa;     @column(name = "cnpj")     private string cnpj;     @onetomany(cascade = cascadetype.all, mappedby = "idempresa", fetch = fetchtype.lazy)     private list<cadastro> cadastrolist;  } 

if want know how retrieving entities, here code:

@override public list<t> recuperartodos() {     query query = entitymanager.createquery(criarqueryrecuperartodos());     limitarquantidadederegistros(query);     return query.getresultlist(); }  private string criarqueryrecuperartodos() {     stringbuilder builder = new stringbuilder("select e ");     builder.append(classe.getsimplename());     builder.append(" e");     builder.append(criarparametrosordenacao());     return builder.tostring(); } 

this legal , expected situation. hibernate uses dynamically generated proxies (hence javaassist objects, in past hibernate used cglib well) placeholders not fetched entities allow lazy fetching. because of this, speaking, should not attempt access attribute values directly. using getters instead allows hibernate issue appropriate db query , fill entity. can problem in situations - example, if values first requested outside hibernate session.


Comments

Popular posts from this blog

Unable to remove the www from url on https using .htaccess -