1 2 12 package com.versant.core.jdbc.fetch; 13 14 import com.versant.core.metadata.FetchGroup; 15 import com.versant.core.metadata.FetchGroupField; 16 import com.versant.core.jdbc.sql.exp.SqlExp; 17 import com.versant.core.jdbc.sql.exp.SelectExp; 18 import com.versant.core.jdbc.JdbcState; 19 import com.versant.core.jdbc.metadata.*; 20 21 import java.sql.ResultSet ; 22 import java.sql.SQLException ; 23 24 27 public class FopGetFetchGroup extends FetchOp { 28 29 private final FetchOpData src; 30 private final FetchGroup fg; 31 32 private int firstColIndex; 34 37 public FopGetFetchGroup(FetchSpec spec, FetchOpData src, FetchGroup fg) { 38 super(spec); 39 this.src = src; 40 this.fg = fg; 41 } 42 43 public FetchOpData getOutputData() { 44 return src; 45 } 46 47 public SqlExp init(SelectExp root, int firstColIndex) { 48 this.firstColIndex = firstColIndex; 49 SqlExp list = null, pos = null; 51 FetchGroupField[] fields = fg.fields; 52 int n = fields.length; 53 for (int i = 0; i < n; i++) { 54 FetchGroupField field = fields[i]; 55 JdbcField jdbcField = (JdbcField)field.fmd.storeField; 56 SqlExp ce = jdbcField.createOwningTableColumnExpList(root); 57 if (ce != null) { 58 if (list == null) { 59 pos = list = ce; 60 } else { 61 pos.next = ce; 62 for (; pos.next != null; pos = pos.next); 63 } 64 } 65 if (!field.doNotFetchObject) { 66 jdbcField.prepareFetch(spec, spec.getOptions()); 67 } 68 } 69 return list; 70 } 71 72 public void fetch(FetchResultImp fetchResult) throws SQLException { 73 JdbcState state = (JdbcState)src.getState(fetchResult); 74 if (state == null) { 75 return; } 77 ResultSet rs = src.getResultSet(fetchResult); 78 state.copyPass1Fields(rs, fg, firstColIndex); 79 } 80 81 public String getDescription() { 82 return fg.name + src.getDescription(); 83 } 84 85 } 86 87 | Popular Tags |