List of usage examples for org.hibernate.boot Metadata getEntityBinding
PersistentClass getEntityBinding(String entityName);
From source file:com.googlecode.hibernate.audit.extension.auditable.DefaultAuditableInformationProvider.java
License:Open Source License
public String getAuditTypeClassName(Metadata metadata, String entityName) { if (provider != null) { return provider.getAuditTypeClassName(metadata, entityName); }//from w w w.ja v a 2 s.c o m PersistentClass classMapping = metadata.getEntityBinding(entityName); Class mappedClass = classMapping.getMappedClass(); if (mappedClass == null) { mappedClass = classMapping.getProxyInterface(); } return mappedClass.getName(); }
From source file:org.teiid.spring.autoconfigure.SchemaBuilderUtility.java
License:Apache License
private static Mapping buildMapping(final Metadata metadata) { return new Mapping() { /**// w w w. j av a 2 s. com * Returns the identifier type of a mapped class */ @Override public Type getIdentifierType(String persistentClass) throws MappingException { final PersistentClass pc = metadata.getEntityBinding(persistentClass); if (pc == null) { throw new MappingException("persistent class not known: " + persistentClass); } return pc.getIdentifier().getType(); } @Override public String getIdentifierPropertyName(String persistentClass) throws MappingException { final PersistentClass pc = metadata.getEntityBinding(persistentClass); if (pc == null) { throw new MappingException("persistent class not known: " + persistentClass); } if (!pc.hasIdentifierProperty()) { return null; } return pc.getIdentifierProperty().getName(); } @Override public Type getReferencedPropertyType(String persistentClass, String propertyName) throws MappingException { final PersistentClass pc = metadata.getEntityBinding(persistentClass); if (pc == null) { throw new MappingException("persistent class not known: " + persistentClass); } Property prop = pc.getProperty(propertyName); if (prop == null) { throw new MappingException("property not known: " + persistentClass + '.' + propertyName); } return prop.getType(); } @Override public IdentifierGeneratorFactory getIdentifierGeneratorFactory() { return null; } }; }