Java Mailing List Archive

http://www.junlu.com/

Home » Home (12/2007) » JBoss User Help »

[jboss-user] [Persistence, JBoss/CMP, Hibernate,
 Database] - Re: business methods and local home interface

scott.stark@jboss.org

2007-06-11


stub in the DocumentoLocalHome.java:

|    public java.util.Collection selectByMetadato(Integer num, String metadati);
|     // throws javax.ejb.FinderException;      
|

implementation as it appears in DocumentoBean.java:

|  public java.util.Collection selectByMetadato(Integer num, String metadati) {
|    DocumentoLocalHome documentoHome;
|    
|    java.util.Collection result = null;
|    
|    String sql = "SELECT DISTINCT documento.iddocumento" +
|          "FROM documento join documento_metadatas_metadato_documents" +
|          "on documento.idDocumento = documento_metadatas_metadato_documents.documento" +
|          "join metadato on documento_metadatas_metadato_documents.metadato = " +
|          "metadato.metadato" +
|          "WHERE metadato.metadato IN (" + metadati + ")" +
|          "GROUP BY documento.iddocumento, documento.titolo, documento.anno, "+
|          "documento.tipo, documento.risorsa, documento.descrizione" +
|          "HAVING count(*) = "+ num +";";
|    
|    
|    ResultSet rset;
|    rset = ServizioJdbc.ExecuteSql(sql);
|    
|    try {
|      documentoHome = (DocumentoLocalHome) PortableRemoteObject.narrow(
|          (new InitialContext()).lookup("DocumentoLocal"),DocumentoLocalHome.class);
|    } catch (Exception e) {
|      return null;
|    }
|    
|    try {
|      rset.first();
|    
|      while (! rset.isAfterLast() ) {
|        result.add(documentoHome.findByPrimaryKey(Integer.valueOf(rset.getInt(1))));
|        rset.next();
|      }
|    } catch (Exception e) { System.out.println(e.toString()); return null; }
|    
|    return result;
|  }
|


View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4053012#4053012

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4053012
_______________________________________________
jboss-user mailing list
jboss-user@(protected)
https://lists.jboss.org/mailman/listinfo/jboss-user
©2008 junlu.com - Jax Systems, LLC, U.S.A.