Apanhando de uma query

2 respostas
ambrozio

Pessoal toh apanhando de uma danada de uma query, meu codigo tah certo ou melhor não tah dando nenhum erro mas o retorno nao eh o que eu esperava. Ele tah me retornando soh o id e o resthio eh um monte de codigo maluco que eu não sei o que eh.

1 - quando eu executo uma query, o retorno eh o que existe no banco de dados, certo?
2 - o que tah errado no meu codigo que ao inves de dados vem esse data.Estado@1d49247
3 - os campos da minha tabela sao: id,estado,capital,uf e pericms(percentual de icms)

try{
        String hql = "from Estado";
		
    org.hibernate.Query query = sessao.createQuery(hql);
		
   List result = query.list();
                    
   System.out.println(result);
                    
  
    }finally{
	sessao.close();
}
09:49:15,865 DEBUG Loader:1173 - result row: EntityKey[data.Estado#1]

09:49:15,870 DEBUG Loader:1355 - Initializing object from ResultSet: [data.Estado#1]

09:49:15,883 DEBUG AbstractEntityPersister:2036 - Hydrating entity: [data.Estado#1]

09:49:15,888 DEBUG Loader:699 - result set row: 1

09:49:15,890 DEBUG Loader:1173 - result row: EntityKey[data.Estado#2]

09:49:15,892 DEBUG Loader:1355 - Initializing object from ResultSet: [data.Estado#2]

09:49:15,893 DEBUG AbstractEntityPersister:2036 - Hydrating entity: [data.Estado#2]

09:49:15,894 DEBUG Loader:699 - result set row: 2

09:49:15,896 DEBUG Loader:1173 - result row: EntityKey[data.Estado#3]

09:49:15,897 DEBUG Loader:1355 - Initializing object from ResultSet: [data.Estado#3]

09:49:15,899 DEBUG AbstractEntityPersister:2036 - Hydrating entity: [data.Estado#3]

09:49:15,901 DEBUG Loader:699 - result set row: 3

09:49:15,904 DEBUG Loader:1173 - result row: EntityKey[data.Estado#4]

09:49:15,905 DEBUG Loader:1355 - Initializing object from ResultSet: [data.Estado#4]

09:49:15,908 DEBUG AbstractEntityPersister:2036 - Hydrating entity: [data.Estado#4]

09:49:15,909 DEBUG Loader:699 - result set row: 4

09:49:15,912 DEBUG Loader:1173 - result row: EntityKey[data.Estado#5]

09:49:15,914 DEBUG Loader:1355 - Initializing object from ResultSet: [data.Estado#5]

09:49:15,916 DEBUG AbstractEntityPersister:2036 - Hydrating entity: [data.Estado#5]

09:49:15,917 DEBUG Loader:699 - result set row: 5

09:49:15,919 DEBUG Loader:1173 - result row: EntityKey[data.Estado#6]

09:49:15,920 DEBUG Loader:1355 - Initializing object from ResultSet: [data.Estado#6]

09:49:15,921 DEBUG AbstractEntityPersister:2036 - Hydrating entity: [data.Estado#6]

09:49:15,923 DEBUG Loader:699 - result set row: 6

09:49:15,925 DEBUG Loader:1173 - result row: EntityKey[data.Estado#7]

09:49:15,928 DEBUG Loader:1355 - Initializing object from ResultSet: [data.Estado#7]

09:49:15,929 DEBUG AbstractEntityPersister:2036 - Hydrating entity: [data.Estado#7]

09:49:15,934 DEBUG Loader:699 - result set row: 7

09:49:15,936 DEBUG Loader:1173 - result row: EntityKey[data.Estado#8]

09:49:15,937 DEBUG Loader:1355 - Initializing object from ResultSet: [data.Estado#8]

09:49:15,939 DEBUG AbstractEntityPersister:2036 - Hydrating entity: [data.Estado#8]

09:49:15,941 DEBUG Loader:699 - result set row: 8

09:49:15,942 DEBUG Loader:1173 - result row: EntityKey[data.Estado#9]

09:49:15,943 DEBUG Loader:1355 - Initializing object from ResultSet: [data.Estado#9]

09:49:15,946 DEBUG AbstractEntityPersister:2036 - Hydrating entity: [data.Estado#9]

09:49:15,948 DEBUG Loader:699 - result set row: 9

09:49:15,949 DEBUG Loader:1173 - result row: EntityKey[data.Estado#10]

09:49:15,952 DEBUG Loader:1355 - Initializing object from ResultSet: [data.Estado#10]

09:49:15,953 DEBUG AbstractEntityPersister:2036 - Hydrating entity: [data.Estado#10]

09:49:15,956 DEBUG Loader:699 - result set row: 10

09:49:15,957 DEBUG Loader:1173 - result row: EntityKey[data.Estado#11]

09:49:15,958 DEBUG Loader:1355 - Initializing object from ResultSet: [data.Estado#11]

09:49:15,960 DEBUG AbstractEntityPersister:2036 - Hydrating entity: [data.Estado#11]

09:49:15,961 DEBUG Loader:699 - result set row: 11

09:49:15,963 DEBUG Loader:1173 - result row: EntityKey[data.Estado#12]

09:49:15,964 DEBUG Loader:1355 - Initializing object from ResultSet: [data.Estado#12]

09:49:15,966 DEBUG AbstractEntityPersister:2036 - Hydrating entity: [data.Estado#12]

09:49:15,967 DEBUG Loader:699 - result set row: 12

09:49:15,969 DEBUG Loader:1173 - result row: EntityKey[data.Estado#13]

09:49:15,971 DEBUG Loader:1355 - Initializing object from ResultSet: [data.Estado#13]

09:49:15,974 DEBUG AbstractEntityPersister:2036 - Hydrating entity: [data.Estado#13]

09:49:15,975 DEBUG Loader:699 - result set row: 13

09:49:15,976 DEBUG Loader:1173 - result row: EntityKey[data.Estado#14]

09:49:15,979 DEBUG Loader:1355 - Initializing object from ResultSet: [data.Estado#14]

09:49:15,980 DEBUG AbstractEntityPersister:2036 - Hydrating entity: [data.Estado#14]

09:49:15,982 DEBUG Loader:699 - result set row: 14

09:49:15,983 DEBUG Loader:1173 - result row: EntityKey[data.Estado#15]

09:49:15,985 DEBUG Loader:1355 - Initializing object from ResultSet: [data.Estado#15]

09:49:15,987 DEBUG AbstractEntityPersister:2036 - Hydrating entity: [data.Estado#15]

09:49:15,988 DEBUG Loader:699 - result set row: 15

09:49:15,990 DEBUG Loader:1173 - result row: EntityKey[data.Estado#16]

09:49:15,991 DEBUG Loader:1355 - Initializing object from ResultSet: [data.Estado#16]

09:49:15,994 DEBUG AbstractEntityPersister:2036 - Hydrating entity: [data.Estado#16]

09:49:15,997 DEBUG Loader:699 - result set row: 16

09:49:15,998 DEBUG Loader:1173 - result row: EntityKey[data.Estado#17]

09:49:16,000 DEBUG Loader:1355 - Initializing object from ResultSet: [data.Estado#17]

09:49:16,001 DEBUG AbstractEntityPersister:2036 - Hydrating entity: [data.Estado#17]

09:49:16,003 DEBUG Loader:699 - result set row: 17

09:49:16,004 DEBUG Loader:1173 - result row: EntityKey[data.Estado#18]

09:49:16,006 DEBUG Loader:1355 - Initializing object from ResultSet: [data.Estado#18]

09:49:16,008 DEBUG AbstractEntityPersister:2036 - Hydrating entity: [data.Estado#18]

09:49:16,012 DEBUG Loader:699 - result set row: 18

09:49:16,013 DEBUG Loader:1173 - result row: EntityKey[data.Estado#19]

09:49:16,014 DEBUG Loader:1355 - Initializing object from ResultSet: [data.Estado#19]

09:49:16,016 DEBUG AbstractEntityPersister:2036 - Hydrating entity: [data.Estado#19]

09:49:16,019 DEBUG Loader:699 - result set row: 19

09:49:16,020 DEBUG Loader:1173 - result row: EntityKey[data.Estado#20]

09:49:16,022 DEBUG Loader:1355 - Initializing object from ResultSet: [data.Estado#20]

09:49:16,023 DEBUG AbstractEntityPersister:2036 - Hydrating entity: [data.Estado#20]

09:49:16,025 DEBUG Loader:699 - result set row: 20

09:49:16,026 DEBUG Loader:1173 - result row: EntityKey[data.Estado#21]

09:49:16,028 DEBUG Loader:1355 - Initializing object from ResultSet: [data.Estado#21]

09:49:16,029 DEBUG AbstractEntityPersister:2036 - Hydrating entity: [data.Estado#21]

09:49:16,034 DEBUG Loader:699 - result set row: 21

09:49:16,036 DEBUG Loader:1173 - result row: EntityKey[data.Estado#22]

09:49:16,037 DEBUG Loader:1355 - Initializing object from ResultSet: [data.Estado#22]

09:49:16,047 DEBUG AbstractEntityPersister:2036 - Hydrating entity: [data.Estado#22]

09:49:16,049 DEBUG Loader:699 - result set row: 22

09:49:16,052 DEBUG Loader:1173 - result row: EntityKey[data.Estado#23]

09:49:16,053 DEBUG Loader:1355 - Initializing object from ResultSet: [data.Estado#23]

09:49:16,055 DEBUG AbstractEntityPersister:2036 - Hydrating entity: [data.Estado#23]

09:49:16,056 DEBUG Loader:699 - result set row: 23

09:49:16,058 DEBUG Loader:1173 - result row: EntityKey[data.Estado#24]

09:49:16,060 DEBUG Loader:1355 - Initializing object from ResultSet: [data.Estado#24]

09:49:16,062 DEBUG AbstractEntityPersister:2036 - Hydrating entity: [data.Estado#24]

09:49:16,064 DEBUG Loader:699 - result set row: 24

09:49:16,065 DEBUG Loader:1173 - result row: EntityKey[data.Estado#25]

09:49:16,066 DEBUG Loader:1355 - Initializing object from ResultSet: [data.Estado#25]

09:49:16,067 DEBUG AbstractEntityPersister:2036 - Hydrating entity: [data.Estado#25]

09:49:16,069 DEBUG Loader:699 - result set row: 25

09:49:16,072 DEBUG Loader:1173 - result row: EntityKey[data.Estado#26]

09:49:16,073 DEBUG Loader:1355 - Initializing object from ResultSet: [data.Estado#26]

09:49:16,074 DEBUG AbstractEntityPersister:2036 - Hydrating entity: [data.Estado#26]

09:49:16,076 DEBUG Loader:721 - done processing result set (26 rows)

09:49:16,077 DEBUG AbstractBatcher:389 - about to close ResultSet (open ResultSets: 1, globally: 1)

09:49:16,078 DEBUG AbstractBatcher:374 - about to close PreparedStatement (open PreparedStatements: 1, globally: 1)

09:49:16,080 DEBUG AbstractBatcher:533 - closing statement

09:49:16,084 DEBUG Loader:851 - total objects hydrated: 26

09:49:16,088 DEBUG TwoPhaseLoad:111 - resolving associations for [data.Estado#1]

09:49:16,094 DEBUG TwoPhaseLoad:209 - done materializing entity [data.Estado#1]

09:49:16,096 DEBUG TwoPhaseLoad:111 - resolving associations for [data.Estado#2]

09:49:16,098 DEBUG TwoPhaseLoad:209 - done materializing entity [data.Estado#2]

09:49:16,102 DEBUG TwoPhaseLoad:111 - resolving associations for [data.Estado#3]

09:49:16,103 DEBUG TwoPhaseLoad:209 - done materializing entity [data.Estado#3]

09:49:16,104 DEBUG TwoPhaseLoad:111 - resolving associations for [data.Estado#4]

09:49:16,106 DEBUG TwoPhaseLoad:209 - done materializing entity [data.Estado#4]

09:49:16,107 DEBUG TwoPhaseLoad:111 - resolving associations for [data.Estado#5]

09:49:16,109 DEBUG TwoPhaseLoad:209 - done materializing entity [data.Estado#5]

09:49:16,112 DEBUG TwoPhaseLoad:111 - resolving associations for [data.Estado#6]

09:49:16,114 DEBUG TwoPhaseLoad:209 - done materializing entity [data.Estado#6]

09:49:16,115 DEBUG TwoPhaseLoad:111 - resolving associations for [data.Estado#7]

09:49:16,116 DEBUG TwoPhaseLoad:209 - done materializing entity [data.Estado#7]

09:49:16,120 DEBUG TwoPhaseLoad:111 - resolving associations for [data.Estado#8]

09:49:16,122 DEBUG TwoPhaseLoad:209 - done materializing entity [data.Estado#8]

09:49:16,124 DEBUG TwoPhaseLoad:111 - resolving associations for [data.Estado#9]

09:49:16,126 DEBUG TwoPhaseLoad:209 - done materializing entity [data.Estado#9]

09:49:16,128 DEBUG TwoPhaseLoad:111 - resolving associations for [data.Estado#10]

09:49:16,129 DEBUG TwoPhaseLoad:209 - done materializing entity [data.Estado#10]

09:49:16,132 DEBUG TwoPhaseLoad:111 - resolving associations for [data.Estado#11]

09:49:16,133 DEBUG TwoPhaseLoad:209 - done materializing entity [data.Estado#11]

09:49:16,135 DEBUG TwoPhaseLoad:111 - resolving associations for [data.Estado#12]

09:49:16,136 DEBUG TwoPhaseLoad:209 - done materializing entity [data.Estado#12]

09:49:16,138 DEBUG TwoPhaseLoad:111 - resolving associations for [data.Estado#13]

09:49:16,140 DEBUG TwoPhaseLoad:209 - done materializing entity [data.Estado#13]

09:49:16,141 DEBUG TwoPhaseLoad:111 - resolving associations for [data.Estado#14]

09:49:16,143 DEBUG TwoPhaseLoad:209 - done materializing entity [data.Estado#14]

09:49:16,145 DEBUG TwoPhaseLoad:111 - resolving associations for [data.Estado#15]

09:49:16,151 DEBUG TwoPhaseLoad:209 - done materializing entity [data.Estado#15]

09:49:16,154 DEBUG TwoPhaseLoad:111 - resolving associations for [data.Estado#16]

09:49:16,156 DEBUG TwoPhaseLoad:209 - done materializing entity [data.Estado#16]

09:49:16,157 DEBUG TwoPhaseLoad:111 - resolving associations for [data.Estado#17]

09:49:16,159 DEBUG TwoPhaseLoad:209 - done materializing entity [data.Estado#17]

09:49:16,160 DEBUG TwoPhaseLoad:111 - resolving associations for [data.Estado#18]

09:49:16,163 DEBUG TwoPhaseLoad:209 - done materializing entity [data.Estado#18]

09:49:16,192 DEBUG TwoPhaseLoad:111 - resolving associations for [data.Estado#19]

09:49:16,195 DEBUG TwoPhaseLoad:209 - done materializing entity [data.Estado#19]

09:49:16,196 DEBUG TwoPhaseLoad:111 - resolving associations for [data.Estado#20]

09:49:16,198 DEBUG TwoPhaseLoad:209 - done materializing entity [data.Estado#20]

09:49:16,199 DEBUG TwoPhaseLoad:111 - resolving associations for [data.Estado#21]

09:49:16,200 DEBUG TwoPhaseLoad:209 - done materializing entity [data.Estado#21]

09:49:16,203 DEBUG TwoPhaseLoad:111 - resolving associations for [data.Estado#22]

09:49:16,206 DEBUG TwoPhaseLoad:209 - done materializing entity [data.Estado#22]

09:49:16,207 DEBUG TwoPhaseLoad:111 - resolving associations for [data.Estado#23]

09:49:16,209 DEBUG TwoPhaseLoad:209 - done materializing entity [data.Estado#23]

09:49:16,211 DEBUG TwoPhaseLoad:111 - resolving associations for [data.Estado#24]

09:49:16,213 DEBUG TwoPhaseLoad:209 - done materializing entity [data.Estado#24]

09:49:16,214 DEBUG TwoPhaseLoad:111 - resolving associations for [data.Estado#25]

09:49:16,216 DEBUG TwoPhaseLoad:209 - done materializing entity [data.Estado#25]

09:49:16,217 DEBUG TwoPhaseLoad:111 - resolving associations for [data.Estado#26]

09:49:16,220 DEBUG TwoPhaseLoad:209 - done materializing entity [data.Estado#26]

09:49:16,221 DEBUG StatefulPersistenceContext:837 - initializing non-lazy collections

09:49:16,223 DEBUG JDBCContext:237 - after autocommit

09:49:16,224 DEBUG ConnectionManager:404 - aggressively releasing JDBC connection

09:49:16,226 DEBUG ConnectionManager:441 - releasing JDBC connection [ (open PreparedStatements: 0, globally: 0) (open ResultSets: 0, globally: 0)]

09:49:16,231 DEBUG DriverManagerConnectionProvider:129 - returning connection to pool, pool size: 1

[data.Estado@1d49247, data.Estado@1884a40, data.Estado@c2ee15, data.Estado@1fe8ce8, data.Estado@d4d66b, data.Estado@149105b, data.Estado@125d06e, data.Estado@196f4b5, data.Estado@19ba640, data.Estado@11db6bb, data.Estado@1c7e2da, data.Estado@1fe571f, data.Estado@83b1b, data.Estado@608760, data.Estado@d3c65d, data.Estado@1a1399, data.Estado@1fcc0a2, data.Estado@caf6c1, data.Estado@1f03691, data.Estado@1ce85c4, data.Estado@1b03c1a, data.Estado@139e351, data.Estado@1578aab, data.Estado@51127a, data.Estado@94257f, data.Estado@691dee]

09:49:16,235 DEBUG SessionImpl:273 - closing session

obrigado.

2 Respostas

Rafael_Steil

Retornou o que deveria retornar, ou seja, instâncias da classe “Estado”, a qual estão no pacote “data”.

Itere pela lista e você terá os dados. Não utilize as informações de Debug do Hibernate para considerar se algo funcionou ou não (pelo menos nao apenas isso)

Rafael

Raff

vc tem criado um Objeto do tipo ESTADO ? TIPO DIGO UM POJO ESTADO ? Pq no seu codigo vc chama o list.toString() (implicito) sendo que o mesmo retornará o nome da classe, neste caso a INTERFACE list o seu numero de Hash.

Criado 18 de agosto de 2008
Ultima resposta 18 de ago. de 2008
Respostas 2
Participantes 3