[jboss-user] [Persistence, JBoss/CMP, Hibernate, Database] - Re: business methods and local home interface
paoletto
do-not-reply at jboss.com
Mon Jun 11 05:09:22 EDT 2007
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
More information about the jboss-user
mailing list