1 28 29 package com.caucho.amber.type; 30 31 import com.caucho.amber.field.Id; 32 import com.caucho.amber.manager.AmberPersistenceUnit; 33 import com.caucho.amber.table.Column; 34 import com.caucho.util.L10N; 35 36 39 public class SubEntityType extends EntityType { 40 private static final L10N L = new L10N(SubEntityType.class); 41 42 private RelatedType _root; 43 private RelatedType _parent; 44 45 private Id _id; 46 47 public SubEntityType(AmberPersistenceUnit amberPersistenceUnit, 48 RelatedType parent) 49 { 50 super(amberPersistenceUnit); 51 52 _parent = parent; 53 _root = parent.getRootType(); 54 55 _loadGroupIndex = -1; 56 _defaultLoadGroupIndex = -1; 57 _dirtyIndex = -1; 58 } 59 60 63 public Id getId() 64 { 65 if (_id != null) 66 return _id; 67 else 68 return _parent.getId(); 69 } 70 71 74 public void setId(Id id) 75 { 76 _id = id; 77 } 78 79 82 public RelatedType getRootType() 83 { 84 return _root; 85 } 86 87 90 public RelatedType getParentType() 91 { 92 return _parent; 93 } 94 95 98 public Column getDiscriminator() 99 { 100 return getRootType().getDiscriminator(); 101 } 102 103 106 public int getLoadGroupIndex() 107 { 108 if (_loadGroupIndex < 0) { 109 _loadGroupIndex = _parent.getLoadGroupIndex() + 1; 110 _defaultLoadGroupIndex = _loadGroupIndex; 111 } 112 113 return _loadGroupIndex; 114 } 115 116 119 public int getDefaultLoadGroupIndex() 120 { 121 if (_defaultLoadGroupIndex < 0) { 122 getLoadGroupIndex(); 124 } 125 126 return _defaultLoadGroupIndex; 127 } 128 129 132 public int getDirtyIndex() 133 { 134 if (_dirtyIndex < 0) { 135 _dirtyIndex = _parent.getDirtyIndex(); 136 _minDirtyIndex = _dirtyIndex; 137 } 138 139 return _dirtyIndex; 140 } 141 142 143 146 public String toString() 147 { 148 return "SubEntityType[" + getBeanClass().getName() + "]"; 149 } 150 } 151 | Popular Tags |