Announcement Announcement Module
No announcement yet.
How can I execute a query without using dummy entity member (finder not work)? Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • How can I execute a query without using dummy entity member (finder not work)?

    Hi all,

    I'm trying to create a dynamic finder for an entity that referrers not to an entity member directly, but to a member of another entity:

    Protocollo (main entity) and Ente, an entity declared inside the Protocollo as:

    private Ente ente;

    Clearly I cannot create a dynamic finder calles as "findProtocolloesByNomeEnteLike" tht point to ente.nomeEnte because ROO cannot understand this; than I have create an escamotage, creating a sort of dummy entity member directly inside the main entity Protocollo, called nomeEnte. At this point I can write inside a member function like this:

    public static TypedQuery<Protocollo> findProtocolloesByNomeEnteLike(String nomeEnte)

    where I can put this query:

    TypedQuery<Protocollo> q = em.createQuery("SELECT o FROM Protocollo AS o WHERE LOWER(o.ente.nome) LIKE LOWER(:nomeEnte)", Protocollo.class);

    Than I see two main points:
    1) Is there a more simple and effective way to use in my case?
    2) Why not create a more useful way to obtain this kind of queries directly by ROO?

    I think that my case is very common...

    Best regards,
    Paolo Del Signore
    Last edited by padesig; Nov 2nd, 2011, 05:06 AM.

  • #2
    May be that this helps to understand my previous questions...

    For example, now I have done a custom finder called findProtocolloesByEmailImpiegato that need to have a emailImpiegato entity member to work:


    @Size(max = 255)
    private String emailImpiegato;


    public static TypedQuery<Protocollo> findProtocolloesByEmailImpiegato(String emailImpiegato) {
    if (emailImpiegato == null || emailImpiegato.length() == 0) throw new IllegalArgumentException("The emailImpiegato argument is required");
    EntityManager em = Protocollo.entityManager();
    TypedQuery<Protocollo> q = em.createQuery("SELECT pro FROM" +
    " Utente as ut, Ufficio as uf, TipologiaUfficio as tu, TipologiaPraticaHasTipologiaUfficio as tphastu, Pratica as pr, Protocollo AS pro " +
    " WHERE" +
    " AND" +
    " AND" +
    " AND uf.tipologiaUfficio=tphastu.tipologiaUfficio" +
    " AND tphastu.tipologiaPratica=pr.tipologiaPratica" +
    " AND uf.ente=pr.ente" +
    " AND pr.stato!=3" +
    " AND", Protocollo.class);
    q.setParameter("emailImpiegato", emailImpiegato);
    return q;

    Without the emailImpiegato entity member I cannot force ROO to create a finder that doesen't use the entity member at domain level (I need it only at the View and Control level of the MVC paradigm, not at the Model level).

    Has nobody my same needs? Is there another (fast) way to approach this kind of usage of finders?

    At last point: how I can hide from the View the dummy entity member?

    Best Regards,
    Paolo Del Signore