1 25 26 27 package org.objectweb.jonas_ejb.deployment.api; 28 29 import java.util.Iterator ; 30 31 import org.objectweb.jonas_ejb.deployment.xml.*; 32 import org.objectweb.jonas_lib.deployment.api.DeploymentDescException; 33 import org.objectweb.jonas_lib.deployment.xml.JLinkedList; 34 35 41 42 44 public class EntityJdbcCmp2Desc extends EntityCmp2Desc { 45 46 protected String dsname; 47 protected String jdbcTableName = null; 48 49 53 public EntityJdbcCmp2Desc(ClassLoader classLoader, 54 Entity ent, 55 AssemblyDescriptor asd, 56 JonasEntity jEnt, 57 DeploymentDescEjb2 dc2d, 58 JLinkedList jMDRList, 59 String fileName) 60 throws DeploymentDescException { 61 62 super(classLoader, ent, asd, jEnt, dc2d, jMDRList, fileName); 63 64 JdbcMapping jm = jEnt.getJdbcMapping(); 66 if (jm == null) { 67 throw new DeploymentDescException("jdbc-mapping missing for bean " + ent.getEjbName()); 68 } 69 70 dsname = jm.getJndiName(); 72 73 if (jm.getJdbcTableName() != null) { 75 if (jm.getJdbcTableName().length() != 0) { 76 jdbcTableName = jm.getJdbcTableName(); 77 } 78 } 79 if (jdbcTableName == null) { 80 jdbcTableName = getAbstractSchemaName().toUpperCase() + "_"; 82 } 83 84 for (Iterator i = fieldDesc.keySet().iterator();i.hasNext();) { 86 String fn = (String ) i.next(); 87 ((FieldJdbcDesc)(fieldDesc.get(fn))).setJdbcFieldName(fn + "_"); 88 } 89 90 for (Iterator i = jm.getCmpFieldJdbcMappingList().iterator();i.hasNext();) { 92 CmpFieldJdbcMapping fm = (CmpFieldJdbcMapping) i.next(); 93 String fn = fm.getFieldName(); 94 String cn = fm.getJdbcFieldName(); 95 String ct = null; 96 if (fm.getSqlType() != null) { 97 ct = fm.getSqlType(); 98 } 99 FieldJdbcDesc fdesc = (FieldJdbcDesc) fieldDesc.get(fn); 100 if (fdesc == null) { 101 throw new DeploymentDescException("field-name " + fn 102 + " listed in cmp-field-jdbc-mapping is not of cmp-field of bean " + ent.getEjbName()); 103 } 104 fdesc.setJdbcFieldName(cn); 105 if (ct != null) { 106 fdesc.setSqlType(ct); 107 } 108 } 109 if (isUndefinedPK() && this.getJdbcAutomaticPkFieldName()!= null) { 111 ((FieldJdbcDesc)(fieldDesc.get("JONASAUTOPKFIELD"))).setJdbcFieldName(this.getJdbcAutomaticPkFieldName()); 112 } 113 } 114 115 118 protected FieldDesc newFieldDescInstance() { 119 return new FieldJdbcDesc(); 120 } 121 122 126 public String getDatasourceJndiName() { 127 return dsname; 128 } 129 130 134 public String getJdbcTableName() { 135 return jdbcTableName; 136 } 137 138 142 public String toString() { 143 StringBuffer ret = new StringBuffer (); 144 ret.append(super.toString()); 145 ret.append("\ngetDatasourceJndiName()=" + getDatasourceJndiName()); 146 ret.append("\ngetJdbcTableName()=" + getJdbcTableName()); 147 return ret.toString(); 148 } 149 150 151 } 152 | Popular Tags |