001package io.ebean.config; 002 003/** 004 * The JPA naming convention where column names match property names and table 005 * names match entity names. 006 * <p> 007 * The JPA specification states that the in the case of no annotations the name 008 * of the class will be take as the table name and the name of a property will 009 * be taken as the name of the column. 010 * </p> 011 * 012 * @author emcgreal 013 */ 014public class MatchingNamingConvention extends AbstractNamingConvention { 015 016 /** 017 * Create with a sequence format of "{table}_seq". 018 */ 019 public MatchingNamingConvention() { 020 super(); 021 } 022 023 /** 024 * Instantiates with a specific format for DB sequences. 025 * 026 * @param sequenceFormat the sequence format 027 */ 028 public MatchingNamingConvention(String sequenceFormat) { 029 super(sequenceFormat); 030 } 031 032 @Override 033 public String getColumnFromProperty(Class<?> beanClass, String propertyName) { 034 return quoteIdentifiers(propertyName); 035 } 036 037 @Override 038 public TableName getTableNameByConvention(Class<?> beanClass) { 039 return new TableName(quoteIdentifiers(getCatalog()), quoteIdentifiers(getSchema()), quoteIdentifiers(beanClass.getSimpleName())); 040 } 041 042 @Override 043 public String getForeignKey(String prefix, String fkProperty) { 044 prefix = databasePlatform.unQuote(prefix); 045 fkProperty = databasePlatform.unQuote(fkProperty); 046 // add fkProperty as init caps 047 String fullName = prefix + fkProperty.substring(0, 1).toUpperCase() + fkProperty.substring(1); 048 return quoteIdentifiers(fullName); 049 } 050 051}