1 26 package org.objectweb.speedo.query.lib; 27 28 import javax.jdo.JDOUserException; 29 import javax.jdo.PersistenceManager; 30 31 import org.objectweb.medor.api.MedorException; 32 import org.objectweb.medor.tuple.api.TupleCollection; 33 import org.objectweb.speedo.api.SpeedoException; 34 import org.objectweb.util.monolog.api.Logger; 35 36 41 public class QueryResultUnique extends QueryResultCommon { 42 43 51 public QueryResultUnique(TupleCollection _tc, 52 PersistenceManager _pm, 53 Object [] _conns, 54 Class _resultClazz, 55 Class [] _selectedFieldTypes, 56 boolean staticFirstElementIndex, 57 Logger _logger) 58 throws MedorException, SpeedoException { 59 super(_tc, _pm, _conns, _resultClazz, _selectedFieldTypes, 60 staticFirstElementIndex, _logger); 61 } 62 63 public Object getResult() throws SpeedoException { 64 Object res = null; 65 try { 66 if (!tc.isEmpty()) { 67 tc.first(); 68 res = getValue(tc.getTuple()); 69 if (tc.next()) { 70 throw new JDOUserException("More than one result in the query"); 71 } 72 } 73 } catch (MedorException e) { 74 throw new SpeedoException(e); 75 } finally { 76 close(); 77 } 78 return res; 79 } 80 } 81 | Popular Tags |