Java Code Examples for org.hibernate.persister.entity.AbstractEntityPersister#getPropertyColumnNames()

The following examples show how to use org.hibernate.persister.entity.AbstractEntityPersister#getPropertyColumnNames() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BuilderUtil.java    From database-rider with Apache License 2.0 6 votes vote down vote up
public static String getColumnNameFromMetaModel(Attribute column) {
    String columnName = null;
    try {
        if (isEclipseLinkOnClasspath()) {
            columnName = ((AttributeImpl) column).getMapping().getField().getName();
        } else if (isHibernateOnClasspath() && isEntityManagerActive()) {
            AbstractEntityPersister entityMetadata = (AbstractEntityPersister) em().getEntityManagerFactory().unwrap(SessionFactory.class).getClassMetadata(column.getJavaMember().getDeclaringClass());
            columnName = entityMetadata.getPropertyColumnNames(column.getName())[0];
        }
    } catch (Exception e) {
        LOGGER.error("Could not extract database column name from column {} and type {}", column.getName(), column.getDeclaringType().getJavaType().getName(), e);
    }
    if (columnName == null) {
        columnName = convertCase(column.getName(), config);
    }
    return columnName;
}
 
Example 2
Source File: FilterSqlService.java    From axelor-open-suite with GNU Affero General Public License v3.0 5 votes vote down vote up
public String getColumn(String model, String field) {

    SessionImpl sessionImpl = (SessionImpl) JPA.em().getDelegate();
    @SuppressWarnings("deprecation")
    AbstractEntityPersister aep =
        ((AbstractEntityPersister)
            sessionImpl.getSession().getSessionFactory().getClassMetadata(model));
    String[] columns = aep.getPropertyColumnNames(field);
    if (columns != null && columns.length > 0) {
      return columns[0];
    }

    return null;
  }
 
Example 3
Source File: QueryUtil.java    From ctsms with GNU Lesser General Public License v2.1 4 votes vote down vote up
private static String getPropertyColumnName(Class entity, String property, SessionFactory sessionFactory) {
	ClassMetadata hibernateMetadata = sessionFactory.getClassMetadata(entity);
	AbstractEntityPersister persister = (AbstractEntityPersister) hibernateMetadata;
	String[] columnNames = persister.getPropertyColumnNames(property);
	return columnNames[0];
}