1 28 29 package com.caucho.amber.hibernate; 30 31 import com.caucho.bytecode.JMethod; 32 import com.caucho.bytecode.JClass; 33 34 import com.caucho.util.L10N; 35 36 import com.caucho.config.ConfigException; 37 38 import com.caucho.amber.type.Type; 39 import com.caucho.amber.type.EntityType; 40 41 import com.caucho.amber.field.AbstractField; 42 43 46 public class HibernateField { 47 private static final L10N L = new L10N(HibernateField.class); 48 49 private EntityType _type; 50 private AbstractField _field; 51 52 private Type _resultType; 53 54 HibernateField(EntityType type) 55 { 56 _type = type; 57 } 58 59 protected void setField(AbstractField field) 60 { 61 _field = field; 62 } 63 64 public void setName(String name) 65 throws ConfigException 66 { 67 _field.setName(name); 68 } 69 70 public void setType(String type) 71 throws ConfigException 72 { 73 _resultType = _type.getAmberManager().createType(type); 74 } 75 76 public Type getType() 77 { 78 return _resultType; 79 } 80 81 EntityType getOwnerType() 82 { 83 return _type; 84 } 85 86 public void init() 87 throws ConfigException 88 { 89 94 95 if (_resultType == null) { 96 JMethod method = _field.getGetterMethod(); 97 if (method != null) { 98 JClass resultClass = method.getReturnType(); 99 _resultType = _type.getAmberManager().createType(resultClass); 100 } 101 else { 102 _resultType = _type.getAmberManager().createType("string"); 103 } 104 } 105 } 106 } 107 | Popular Tags |