1 19 20 21 package org.apache.cayenne.jpa.map; 22 23 import java.util.ArrayList ; 24 import java.util.Collection ; 25 26 import javax.persistence.SqlResultSetMapping; 27 28 import org.apache.cayenne.util.TreeNodeChild; 29 30 public class JpaSqlResultSetMapping { 31 32 protected String name; 33 protected Collection <JpaEntityResult> entityResults; 34 protected Collection <JpaColumnResult> columnResults; 35 36 public JpaSqlResultSetMapping() { 37 38 } 39 40 public JpaSqlResultSetMapping(SqlResultSetMapping annotation) { 41 name = annotation.name(); 42 43 getEntityResults(); 44 for (int i = 0; i < annotation.entities().length; i++) { 45 entityResults.add(new JpaEntityResult(annotation.entities()[i])); 46 } 47 48 getColumnResults(); 49 for (int i = 0; i < annotation.columns().length; i++) { 50 columnResults.add(new JpaColumnResult(annotation.columns()[i])); 51 } 52 } 53 54 public String getName() { 55 return name; 56 } 57 58 public void setName(String name) { 59 this.name = name; 60 } 61 62 @TreeNodeChild(type=JpaColumnResult.class) 63 public Collection <JpaColumnResult> getColumnResults() { 64 if (columnResults == null) { 65 columnResults = new ArrayList <JpaColumnResult>(5); 66 } 67 return columnResults; 68 } 69 70 @TreeNodeChild(type=JpaEntityResult.class) 71 public Collection <JpaEntityResult> getEntityResults() { 72 if (entityResults == null) { 73 entityResults = new ArrayList <JpaEntityResult>(5); 74 } 75 76 return entityResults; 77 } 78 } 79 | Popular Tags |