Example usage for org.hibernate.boot.model.naming ImplicitJoinColumnNameSource getEntityNaming

List of usage examples for org.hibernate.boot.model.naming ImplicitJoinColumnNameSource getEntityNaming

Introduction

In this page you can find the example usage for org.hibernate.boot.model.naming ImplicitJoinColumnNameSource getEntityNaming.

Prototype

public EntityNaming getEntityNaming();

Source Link

Document

Access to entity naming information.

Usage

From source file:com.example.ejb3.auction.NamingStrategy.java

License:Apache License

@Override
public Identifier determineJoinColumnName(ImplicitJoinColumnNameSource source) {
    if (source.getAttributePath() != null) {
        return toIdentifier((source.getNature() == ImplicitJoinColumnNameSource.Nature.ELEMENT_COLLECTION
                ? addUnderscores(transformEntityName(source.getEntityNaming()))
                : addUnderscores(source.getAttributePath().getFullPath())) + '_'
                + source.getReferencedColumnName().getText(), source.getBuildingContext());
    }//from  w w  w .  j a  v  a 2s  . co m
    if (source.getNature() != ImplicitJoinColumnNameSource.Nature.ELEMENT_COLLECTION) {
        String name = transformEntityName(source.getEntityNaming()) + '_'
                + source.getReferencedColumnName().getText();
        return toIdentifier(addUnderscores(name), source.getBuildingContext());
    }
    return super.determineJoinColumnName(source);
}