Implementing a "limit" strategy in EJB QL


EJB programming & troubleshooting: Implementing a "limit" strategy in EJB QL

  1. Implementing a "limit" strategy in EJB QL (1 messages)


    I would like for an ejb-ql query to return the first n results that match the query. Is there an ejb-ql equivalent of the LIMIT SQL keyword that can be found for example in MySql?

    If the answer to the above question is no, is there a way around? Bearing in mind that there might be an enormous quantity of ejb that match the query how can return only the first n results?

    Thanks in advance,


    P.S I know Jboss and Resin offer a limit capability but I'd rather a solution portable to all j2ee app servers.
  2. This is no portable way to do this with EJB-QL. Either

    1) Use a server-specific feature.

    2) Use JDBC and Data Transfer Objects instead of Entity beans.