1 19 package org.netbeans.modules.j2ee.persistence.entitygenerator; 20 21 26 27 import org.netbeans.modules.dbschema.ColumnElement; 28 import org.netbeans.modules.dbschema.util.SQLTypeUtil; 29 30 class DbSchemaEntityMember extends EntityMember { 31 32 35 private boolean isPrimaryKey; 36 37 40 private SQLType sqlType; 41 42 45 private ColumnElement columnElement; 46 47 public DbSchemaEntityMember(ColumnElement element) { 48 columnElement = element; 49 sqlType = SQLType.getSQLType(element.getType()); 50 setMemberName(makeFieldName(element.getName().getName())); 51 isPrimaryKey = false; 52 setMemberType(sqlType.getMemberType(element)); 53 } 54 55 public boolean isNullable() { 56 return columnElement.isNullable(); 57 } 58 59 public boolean isPrimaryKey() { 60 return isPrimaryKey; 61 } 62 63 public void setPrimaryKey(boolean isPk, boolean isPkField) { 64 isPrimaryKey = isPk; 65 66 if (isPkField) { 70 setMemberType(((Class )sqlType.getValidObjects().get(0)).getName()); 71 } 72 } 73 74 private ColumnElement getColumnElement() { 75 return columnElement; 76 } 77 78 public boolean supportsFinder() { 79 return sqlType.supportsFinder(); 80 } 81 82 public String getColumnName() { 83 return getColumnElement().getName().getName(); 84 } 85 86 public String getTableName() { 87 return getColumnElement().getDeclaringTable().getName().getName(); 88 } 89 90 public boolean isLobType() { 91 return SQLTypeUtil.isLob(getColumnElement().getType()); 92 } 93 94 } 95 | Popular Tags |