本文整理匯總了Java中org.hibernate.mapping.PersistentClass類的典型用法代碼示例。如果您正苦於以下問題:Java PersistentClass類的具體用法?Java PersistentClass怎麽用?Java PersistentClass使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
PersistentClass類屬於org.hibernate.mapping包,在下文中一共展示了PersistentClass類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: init
import org.hibernate.mapping.PersistentClass; //導入依賴的package包/類
@PostConstruct
public void init() throws ClassNotFoundException
{
final Configuration configuration = annotationSessionFactory
.getConfiguration();
final ReflectionManager reflectionManager = configuration
.getReflectionManager();
final Iterator<PersistentClass> classMappings = configuration
.getClassMappings();
while (classMappings.hasNext())
{
entityCallbackHandler.add(reflectionManager.classForName(
classMappings.next().getClassName(), this.getClass()),
reflectionManager);
}
}
示例2: bindPojoRepresentation
import org.hibernate.mapping.PersistentClass; //導入依賴的package包/類
private static void bindPojoRepresentation(Element node, PersistentClass entity,
Mappings mappings, java.util.Map metaTags) {
String className = getClassName( node.attribute( "name" ), mappings );
String proxyName = getClassName( node.attribute( "proxy" ), mappings );
entity.setClassName( className );
if ( proxyName != null ) {
entity.setProxyInterfaceName( proxyName );
entity.setLazy( true );
}
else if ( entity.isLazy() ) {
entity.setProxyInterfaceName( className );
}
Element tuplizer = locateTuplizerDefinition( node, EntityMode.POJO );
if ( tuplizer != null ) {
entity.addTuplizer( EntityMode.POJO, tuplizer.attributeValue( "class" ) );
}
}
示例3: getClassTableName
import org.hibernate.mapping.PersistentClass; //導入依賴的package包/類
private static String getClassTableName(
PersistentClass model,
Element node,
String schema,
String catalog,
Table denormalizedSuperTable,
Mappings mappings) {
Attribute tableNameNode = node.attribute( "table" );
String logicalTableName;
String physicalTableName;
if ( tableNameNode == null ) {
logicalTableName = StringHelper.unqualify( model.getEntityName() );
physicalTableName = getNamingStrategyDelegate( mappings ).determineImplicitPrimaryTableName(
model.getEntityName(),
model.getJpaEntityName()
);
}
else {
logicalTableName = tableNameNode.getValue();
physicalTableName = getNamingStrategyDelegate( mappings ).toPhysicalTableName( logicalTableName );
}
mappings.addTableBinding( schema, catalog, logicalTableName, physicalTableName, denormalizedSuperTable );
return physicalTableName;
}
示例4: doSecondPass
import org.hibernate.mapping.PersistentClass; //導入依賴的package包/類
public void doSecondPass(java.util.Map persistentClasses) throws MappingException {
if ( value instanceof ManyToOne ) {
ManyToOne manyToOne = (ManyToOne) value;
PersistentClass ref = (PersistentClass) persistentClasses.get( manyToOne.getReferencedEntityName() );
if ( ref == null ) {
throw new AnnotationException(
"@OneToOne or @ManyToOne on "
+ StringHelper.qualify( entityClassName, path )
+ " references an unknown entity: "
+ manyToOne.getReferencedEntityName()
);
}
BinderHelper.createSyntheticPropertyReference( columns, ref, null, manyToOne, false, mappings );
TableBinder.bindFk( ref, null, columns, manyToOne, unique, mappings );
/*
* HbmMetadataSourceProcessorImpl does this only when property-ref != null, but IMO, it makes sense event if it is null
*/
if ( !manyToOne.isIgnoreNotFound() ) manyToOne.createPropertyRefConstraints( persistentClasses );
}
else if ( value instanceof OneToOne ) {
value.createForeignKey();
}
else {
throw new AssertionFailure( "FkSecondPass for a wrong value type: " + value.getClass().getName() );
}
}
示例5: doSecondPass
import org.hibernate.mapping.PersistentClass; //導入依賴的package包/類
public void doSecondPass(Map persistentClasses) throws MappingException {
org.hibernate.mapping.FetchProfile profile = mappings.findOrCreateFetchProfile(
fetchProfileName,
MetadataSource.ANNOTATIONS
);
if ( MetadataSource.ANNOTATIONS != profile.getSource() ) {
return;
}
PersistentClass clazz = mappings.getClass( fetch.entity().getName() );
// throws MappingException in case the property does not exist
clazz.getProperty( fetch.association() );
profile.addFetch(
fetch.entity().getName(), fetch.association(), fetch.mode().toString().toLowerCase()
);
}
示例6: bindReturn
import org.hibernate.mapping.PersistentClass; //導入依賴的package包/類
private static NativeSQLQueryRootReturn bindReturn(Element returnElem, Mappings mappings, int elementCount) {
String alias = returnElem.attributeValue( "alias" );
if( StringHelper.isEmpty( alias )) {
alias = "alias_" + elementCount; // hack/workaround as sqlquery impl depend on having a key.
}
String entityName = HbmBinder.getEntityName(returnElem, mappings);
if(entityName==null) {
throw new MappingException( "<return alias='" + alias + "'> must specify either a class or entity-name");
}
LockMode lockMode = getLockMode( returnElem.attributeValue( "lock-mode" ) );
PersistentClass pc = mappings.getClass( entityName );
java.util.Map propertyResults = bindPropertyResults(alias, returnElem, pc, mappings );
return new NativeSQLQueryRootReturn(
alias,
entityName,
propertyResults,
lockMode
);
}
示例7: processIdPropertiesIfNotAlready
import org.hibernate.mapping.PersistentClass; //導入依賴的package包/類
private static void processIdPropertiesIfNotAlready(
Map<XClass, InheritanceState> inheritanceStatePerClass,
Mappings mappings,
PersistentClass persistentClass,
EntityBinder entityBinder,
PropertyHolder propertyHolder,
HashMap<String, IdGenerator> classGenerators,
InheritanceState.ElementsToProcess elementsToProcess,
boolean subclassAndSingleTableStrategy,
Set<String> idPropertiesIfIdClass) {
Set<String> missingIdProperties = new HashSet<String>( idPropertiesIfIdClass );
for ( PropertyData propertyAnnotatedElement : elementsToProcess.getElements() ) {
String propertyName = propertyAnnotatedElement.getPropertyName();
if ( !idPropertiesIfIdClass.contains( propertyName ) ) {
processElementAnnotations(
propertyHolder,
subclassAndSingleTableStrategy ?
Nullability.FORCED_NULL :
Nullability.NO_CONSTRAINT,
propertyAnnotatedElement, classGenerators, entityBinder,
false, false, false, mappings, inheritanceStatePerClass
);
}
else {
missingIdProperties.remove( propertyName );
}
}
if ( missingIdProperties.size() != 0 ) {
StringBuilder missings = new StringBuilder();
for ( String property : missingIdProperties ) {
missings.append( property ).append( ", " );
}
throw new AnnotationException(
"Unable to find properties ("
+ missings.substring( 0, missings.length() - 2 )
+ ") in entity annotated with @IdClass:" + persistentClass.getEntityName()
);
}
}
示例8: getSuperEntity
import org.hibernate.mapping.PersistentClass; //導入依賴的package包/類
private static PersistentClass getSuperEntity(XClass clazzToProcess, Map<XClass, InheritanceState> inheritanceStatePerClass, Mappings mappings, InheritanceState inheritanceState) {
InheritanceState superEntityState = InheritanceState.getInheritanceStateOfSuperEntity(
clazzToProcess, inheritanceStatePerClass
);
PersistentClass superEntity = superEntityState != null ?
mappings.getClass(
superEntityState.getClazz().getName()
) :
null;
if ( superEntity == null ) {
//check if superclass is not a potential persistent class
if ( inheritanceState.hasParents() ) {
throw new AssertionFailure(
"Subclass has to be binded after it's mother class: "
+ superEntityState.getClazz().getName()
);
}
}
return superEntity;
}
示例9: linkValueUsingDefaultColumnNaming
import org.hibernate.mapping.PersistentClass; //導入依賴的package包/類
public void linkValueUsingDefaultColumnNaming(
Column referencedColumn,
PersistentClass referencedEntity,
SimpleValue value) {
String columnName;
String logicalReferencedColumn = getMappings().getLogicalColumnName(
referencedColumn.getQuotedName(), referencedEntity.getTable()
);
columnName = buildDefaultColumnName( referencedEntity, logicalReferencedColumn );
//yuk side effect on an implicit column
setLogicalColumnName( columnName );
setReferencedColumn( logicalReferencedColumn );
initMappingColumn(
columnName,
null, referencedColumn.getLength(),
referencedColumn.getPrecision(),
referencedColumn.getScale(),
getMappingColumn() != null ? getMappingColumn().isNullable() : false,
referencedColumn.getSqlType(),
getMappingColumn() != null ? getMappingColumn().isUnique() : false,
false
);
linkWithValue( value );
}
示例10: linkJoinColumnWithValueOverridingNameIfImplicit
import org.hibernate.mapping.PersistentClass; //導入依賴的package包/類
public static void linkJoinColumnWithValueOverridingNameIfImplicit(
PersistentClass referencedEntity,
Iterator columnIterator,
Ejb3JoinColumn[] columns,
SimpleValue value) {
for (Ejb3JoinColumn joinCol : columns) {
Column synthCol = (Column) columnIterator.next();
if ( joinCol.isNameDeferred() ) {
//this has to be the default value
joinCol.linkValueUsingDefaultColumnNaming( synthCol, referencedEntity, value );
}
else {
joinCol.linkWithValue( value );
joinCol.overrideFromReferencedColumnIfNecessary( synthCol );
}
}
}
示例11: processPersistentClassHierarchy
import org.hibernate.mapping.PersistentClass; //導入依賴的package包/類
private Set<String> processPersistentClassHierarchy(
PersistentClass persistentClass,
boolean isBase,
SessionFactoryImplementor factory,
String[][] mapping) {
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// collect all the class names that indicate that the "main table" of the given PersistentClass should be
// included when one of the collected class names is used in TREAT
final Set<String> classNames = new HashSet<String>();
final Iterator itr = persistentClass.getDirectSubclasses();
while ( itr.hasNext() ) {
final Subclass subclass = (Subclass) itr.next();
final Set<String> subclassSubclassNames = processPersistentClassHierarchy(
subclass,
false,
factory,
mapping
);
classNames.addAll( subclassSubclassNames );
}
classNames.add( persistentClass.getEntityName() );
if ( ! isBase ) {
MappedSuperclass msc = persistentClass.getSuperMappedSuperclass();
while ( msc != null ) {
classNames.add( msc.getMappedClass().getName() );
msc = msc.getSuperMappedSuperclass();
}
associateSubclassNamesToSubclassTableIndexes( persistentClass, classNames, mapping, factory );
}
return classNames;
}
示例12: associateSubclassNamesToSubclassTableIndexes
import org.hibernate.mapping.PersistentClass; //導入依賴的package包/類
private void associateSubclassNamesToSubclassTableIndexes(
PersistentClass persistentClass,
Set<String> classNames,
String[][] mapping,
SessionFactoryImplementor factory) {
final String tableName = persistentClass.getTable().getQualifiedName(
factory.getDialect(),
factory.getSettings().getDefaultCatalogName(),
factory.getSettings().getDefaultSchemaName()
);
associateSubclassNamesToSubclassTableIndex( tableName, classNames, mapping );
Iterator itr = persistentClass.getJoinIterator();
while ( itr.hasNext() ) {
final Join join = (Join) itr.next();
final String secondaryTableName = join.getTable().getQualifiedName(
factory.getDialect(),
factory.getSettings().getDefaultCatalogName(),
factory.getSettings().getDefaultSchemaName()
);
associateSubclassNamesToSubclassTableIndex( secondaryTableName, classNames, mapping );
}
}
示例13: buildProxyFactory
import org.hibernate.mapping.PersistentClass; //導入依賴的package包/類
@Override
protected ProxyFactory buildProxyFactory(PersistentClass mappingInfo, Getter idGetter, Setter idSetter) {
ProxyFactory pf = new MapProxyFactory();
try {
//TODO: design new lifecycle for ProxyFactory
pf.postInstantiate(
getEntityName(),
null,
null,
null,
null,
null
);
}
catch ( HibernateException he ) {
LOG.unableToCreateProxyFactory( getEntityName(), he );
pf = null;
}
return pf;
}
示例14: bindClass
import org.hibernate.mapping.PersistentClass; //導入依賴的package包/類
public static void bindClass(Element node, PersistentClass persistentClass, Mappings mappings,
java.util.Map inheritedMetas) throws MappingException {
// transfer an explicitly defined entity name
// handle the lazy attribute
Attribute lazyNode = node.attribute( "lazy" );
boolean lazy = lazyNode == null ?
mappings.isDefaultLazy() :
"true".equals( lazyNode.getValue() );
// go ahead and set the lazy here, since pojo.proxy can override it.
persistentClass.setLazy( lazy );
String entityName = node.attributeValue( "entity-name" );
if ( entityName == null ) entityName = getClassName( node.attribute("name"), mappings );
if ( entityName==null ) {
throw new MappingException( "Unable to determine entity name" );
}
persistentClass.setEntityName( entityName );
persistentClass.setJpaEntityName( StringHelper.unqualify( entityName ) );
bindPojoRepresentation( node, persistentClass, mappings, inheritedMetas );
bindDom4jRepresentation( node, persistentClass, mappings, inheritedMetas );
bindMapRepresentation( node, persistentClass, mappings, inheritedMetas );
Iterator itr = node.elementIterator( "fetch-profile" );
while ( itr.hasNext() ) {
final Element profileElement = ( Element ) itr.next();
parseFetchProfile( profileElement, mappings, entityName );
}
bindPersistentClassCommonValues( node, persistentClass, mappings, inheritedMetas );
}
示例15: bindDom4jRepresentation
import org.hibernate.mapping.PersistentClass; //導入依賴的package包/類
private static void bindDom4jRepresentation(Element node, PersistentClass entity,
Mappings mappings, java.util.Map inheritedMetas) {
String nodeName = node.attributeValue( "node" );
if (nodeName==null) nodeName = StringHelper.unqualify( entity.getEntityName() );
entity.setNodeName(nodeName);
// Element tuplizer = locateTuplizerDefinition( node, EntityMode.DOM4J );
// if ( tuplizer != null ) {
// entity.addTuplizer( EntityMode.DOM4J, tuplizer.attributeValue( "class" ) );
// }
}