Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 package net.java.ao.schema;
 
 import static com.google.common.base.Preconditions.checkNotNull;
 import static net.java.ao.Common.convertSimpleClassName;
 import static net.java.ao.schema.UnderScoreUtils.*;

Imposes an underscore word-separation convention on table names. This will convert entity names in the following way:

Entity NameTable Name
Personperson
LicenseRegistrationlicense_registration
Volume4volume_4
Companycompany

This converter allows for both all-lowercase and all-uppercase table name conventions. For example, depending on the configuration, LicenseRegistration may convert to "LICENSE_REGISTRATION".

This converter, coupled with PluralizedTableNameConverter is all that is required to emulate the ActiveRecord table name conversion.

    private final Case tableNameCase;
    public UnderscoreTableNameConverter(Case tableNameCase)
    {
        this. = checkNotNull(tableNameCase);
    }
    @Override
    protected String getName(String entityClassCanonicalName)
    {
        return .apply(camelCaseToUnderScore(convertSimpleClassName(entityClassCanonicalName)));
    }
New to GrepCode? Check out our FAQ X