开发者

SEAM ENTITYQUERY - Problems with Restriction seam-gem example

My project was originally generated by seam-gen and the action "List" bean is not working as i expected. The restriction array has all the attributes from table and is behaving as if all the parameter were mandatory. See the List Bellow:

package br.com.autenticis.comvenif_red_web.session;

import br.com.autenticis.comvenif_red_web.entity.*;
import org.jboss.seam.annotations.Name;
import org.jboss.seam.framework.EntityQuery;
import java.util.Arrays;

@Name("t233Ev01List")
public class T233Ev01List extends EntityQuery<T233Ev01> {

 private static final String EJBQL = "select t233Ev01 from T233Ev01 t233Ev01";

 private static final String[] RESTRICTIONS = {
   //"lower(t233Ev01.placaUnica) like lower(concat(#{t233Ev01List.t233Ev01.placaUnica},'%'))",}; 
   "lower(t233Ev01.placaUnica) like lower(concat(#{t233Ev01List.t233Ev01.placaUnica},'%'))",
   "lower(t233Ev01.renavam) like lower(concat(#{t233Ev01List.t233Ev01.renavam},'%'))",
   "lower(t233Ev01.numIdentProprietario) like lower(concat(#{t233Ev01List.t233Ev01.numIdentProprietario},'%'))",
   "lower(t233Ev01.nomeProprietario) like lower(concat(#{t233Ev01List.t233Ev01.nomeProprietario},'%'))",
   "lower(t233Ev01.anoFabricacao) like lower(concat(#{t233Ev01List.t233Ev01.anoFabricacao},'%'))",
   "lower(t233Ev01.anoModelo) like lower(concat(#{t233Ev01List.t233Ev01.anoModelo},'%'))",
   "lower(t233Ev01.ufByUfEmissao) like lower(concat(#{t233Ev01List.t233Ev01.ufByUfEmissao},'%'))",
   "lower(t233Ev01.numeroCrv) like lower(concat(#{t233Ev01List.t233Ev01.numeroCrv},'%'))",
   "lower(t233Ev01.dataEmissao) like lower(concat(#{t233Ev01List.t233Ev01.dataEmissao},'%'))",
   "lower(t233Ev01.numeroVia) like lower(concat(#{t233Ev01List.t233Ev01.numeroVia},'%'))",
   "lower(t233Ev01.codigoSegurancaCrv) like lower(concat(#{t233Ev01List.t233Ev01.codigoSegurancaCrv},'%'))",
   "lower(t233Ev01.tipoDocCartorio) like lower(concat(#{t233Ev01List.t233Ev01.tipoDocCartorio},'%'))",
   "lower(t233Ev01.numIdentCartorio) like lower(concat(#{t233Ev01List.t233Ev01.numIdentCartorio},'%'))",
   "lower(t233Ev01.numIdentCv) like lower(concat(#{t233Ev01List.t233Ev01.numIdentCv},'%'))",};

 private T233Ev01 t233Ev01;

 public T233Ev01List() {
  t233Ev01 = new T233Ev01();
  t233Ev01.setId(new T233Ev01Id());
  setEjbql(EJBQL);

  setRestrictionExpressionStrings(Arrays.asList(RESTRICTIONS));
  setMaxResults(25);
 }

 public T233Ev01 getT233Ev01() {
  return t233Ev01;
 }
}

When i just fill the field "Placa Unica" in form for example, a sql with all fields are generated like this:

SELECT *
  FROM (SELECT t233ev01x0_.idtransacao AS idtransa1_26_,
               t233ev01x0_.dia_juliano AS dia2_26_,
               t233ev01x0_.uf_imovel_comprador AS uf38_26_,
               t233ev01x0_.uf_imovel_cartorio AS uf37_26_,
               t233ev01x0_.uf_emissao AS uf36_26_,
               t233ev01x0_.placa_unica AS placa3_26_,
               t233ev01x0_.renavam AS renavam26_,
               t233ev01x0_.num_ident_proprietario AS num5_26_,
               t233ev01x0_.nome_proprietario AS nome6_26_,
               t233ev01x0_.ano_fabricacao AS ano7_26_,
               t233ev01x0_.ano_modelo AS ano8_26_,
               t233ev01x0_.numero_crv AS numero9_26_,
               t233ev01x0_.data_emissao AS data10_26_,
               t233ev01x0_.numero_via AS numero11_26_,
               t233ev01x0_.codigo_seguranca_crv AS codigo12_26_,
               t233ev01x0_.tipo_doc_comprador AS tipo13_26_,
               t233ev01x0_.num_ident_comprador AS num14_26_,
               t233ev01x0_.nome_comprador AS nome15_26_,
               t233ev01x0_.nome_logradouro_comprador AS nome16_26_,
               t233ev01x0_.numero_imovel_comprador AS numero17_26_,
               t233ev01x0_.complemento_imovel_comprador AS complem18_26_,
               t233ev01x0_.bairro_imovel_comprador AS bairro19_26_,
               t233ev01x0_.cod_municipio_imovel_comprador AS cod20_26_,
               t233ev01x0_.cep_imovel_comprador AS cep21_26_,
               t233ev01x0_.cod_municipio_local_venda AS cod22_26_,
               t233ev01x0_.data_venda AS data23_2开发者_运维知识库6_,
               t233ev01x0_.tipo_doc_cartorio AS tipo24_26_,
               t233ev01x0_.num_ident_cartorio AS num25_26_,
               t233ev01x0_.nome_cartorio AS nome26_26_,
               t233ev01x0_.nome_logradouro_cartorio AS nome27_26_,
               t233ev01x0_.numero_imovel_cartorio AS numero28_26_,
               t233ev01x0_.complemento_imovel_cartorio AS complem29_26_,
               t233ev01x0_.bairro_imovel_cartorio AS bairro30_26_,
               t233ev01x0_.cod_municipio_imovel_cartorio AS cod31_26_,
               t233ev01x0_.cep_imovel_cartorio AS cep32_26_,
               t233ev01x0_.ddd_tel_cartorio AS ddd33_26_,
               t233ev01x0_.num_tel_cartorio AS num34_26_,
               t233ev01x0_.num_ident_cv AS num35_26_
          FROM autenticis_comvenif.t233_ev01 t233ev01x0_
         WHERE (LOWER (t233ev01x0_.renavam) LIKE LOWER (? || '%'))
           AND (LOWER (t233ev01x0_.ano_fabricacao) LIKE LOWER (? || '%'))
           AND (LOWER (t233ev01x0_.ano_modelo) LIKE LOWER (? || '%'))
           AND (LOWER (t233ev01x0_.numero_crv) LIKE LOWER (? || '%'))
           AND (LOWER (t233ev01x0_.data_emissao) LIKE LOWER (? || '%'))
           AND (LOWER (t233ev01x0_.numero_via) LIKE LOWER (? || '%'))
           AND (LOWER (t233ev01x0_.tipo_doc_cartorio) LIKE LOWER (? || '%'))
           AND (LOWER (t233ev01x0_.num_ident_cv) LIKE LOWER (? || '%')))
 WHERE ROWNUM <= ?

I don't want to put in the query, fields that are not filled (null). I didn't find any example about "Dynamic Restriction" ou another way to do that with EntityQuery


Cateno, this looks suspiciously like something that happened to me. In my case, the entity in question was a view, not a table, and therefore seam/hibernate could not find a primary key field to use as its Id.

For this view, seam generate-entities created 2 entities, one that contained only an id and one that contained some kind of sub entity with all the other fields. I didn't really understand what it did or why. The corresponding EntityList I got looked suspiciously like the one you post here.

The way I got around this was to explicitly define the primary kid for this entity in the seam-gen.reveng.xml file. That file is in the resources folder. For an example here is what the entry in my reveng.xml file looked like:

<table name="office_view">
    <primary-key>
        <key-column name='office_id' />
    </primary-key>
</table>

If this is your problem, explicitly defining a primary key here may help you.

april26

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜