本文整理了Java中org.hibernate.type.Type.isEntityType()
方法的一些代码示例,展示了Type.isEntityType()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Type.isEntityType()
方法的具体详情如下:
包路径:org.hibernate.type.Type
类名称:Type
方法名:isEntityType
[英]Return true if the implementation is castable to EntityType. Essentially a polymorphic version of (type instanceof EntityType.class).
An EntityType is additionally an AssociationType; so if this method returns true, #isAssociationType() should also return true.
[中]如果实现可强制转换为EntityType,则返回true。本质上是(EntityType.class的类型instanceof)的多态版本。
EntityType是AssociationType;因此,如果这个方法返回true,#isAssociationType()也应该返回true。
代码示例来源:origin: hibernate/hibernate-orm
@Override
public boolean isManyToMany() {
return elementType.isEntityType(); //instanceof AssociationType;
}
代码示例来源:origin: hibernate/hibernate-orm
@Override
public boolean isAssociation() {
return mapKeyType.isEntityType();
}
代码示例来源:origin: hibernate/hibernate-orm
/**
* Check if the association is a one to one in the logical model (either a shared-pk
* or unique fk).
*
* @param type The type representing the attribute metadata
*
* @return True if the attribute represents a logical one to one association
*/
private static boolean isLogicalOneToOne(Type type) {
return type.isEntityType() && ( (EntityType) type ).isLogicalOneToOne();
}
代码示例来源:origin: hibernate/hibernate-orm
public boolean isCollectionOfValuesOrComponents() {
return persister == null
&& queryableCollection != null
&& !queryableCollection.getElementType().isEntityType();
}
代码示例来源:origin: hibernate/hibernate-orm
@Override
public EntityDefinition toEntityDefinition() {
if ( !getType().isEntityType() ) {
throw new IllegalStateException( "Cannot treat collection element type as entity" );
}
return getElementPersister();
}
代码示例来源:origin: hibernate/hibernate-orm
/**
* Returns whether we believe the map element should be included as part of the middle table's primary key.
*
* @return {@code true} if the element should be included as part of the key, otherwise {@code false}.
*/
private boolean isMapElementInPrimaryKey() {
if ( propertyValue instanceof IndexedCollection ) {
final Value index = ( (IndexedCollection) propertyValue ).getIndex();
return !index.getType().isEntityType();
}
return true;
}
}
代码示例来源:origin: hibernate/hibernate-orm
public void collectQuerySpaces(Collection<String> spaces) {
for ( EntityPersister persister : alias2Persister.values() ) {
Collections.addAll( spaces, (String[]) persister.getQuerySpaces() );
}
for ( CollectionPersister persister : alias2CollectionPersister.values() ) {
final Type elementType = persister.getElementType();
if ( elementType.isEntityType() && ! elementType.isAnyType() ) {
final Joinable joinable = ( (EntityType) elementType ).getAssociatedJoinable( factory );
Collections.addAll( spaces, (String[]) ( (EntityPersister) joinable ).getQuerySpaces() );
}
}
}
}
代码示例来源:origin: hibernate/hibernate-orm
void setCollectionToFetch(String role, String name, String ownerName, String entityName)
throws QueryException {
fetchName = name;
collectionPersister = getCollectionPersister( role );
collectionOwnerName = ownerName;
if ( collectionPersister.getElementType().isEntityType() ) {
addEntityToFetch( entityName );
}
}
代码示例来源:origin: hibernate/hibernate-orm
@Override
public EntityDefinition toEntityDefinition() {
if ( !getType().isEntityType() ) {
throw new IllegalStateException( "Cannot treat collection index type as entity" );
}
return (EntityPersister) ( (AssociationType) getIndexType() ).getAssociatedJoinable( getFactory() );
}
代码示例来源:origin: hibernate/hibernate-orm
private boolean hasAssociation(CompositeType componentType) {
for ( Type subType : componentType.getSubtypes() ) {
if ( subType.isEntityType() ) {
return true;
}
else if ( subType.isComponentType() && hasAssociation( ( (CompositeType) subType ) ) ) {
return true;
}
}
return false;
}
代码示例来源:origin: hibernate/hibernate-orm
private String getElementName(PathExpressionParser.CollectionElement element, QueryTranslatorImpl q) throws QueryException {
String name;
if ( element.isOneToMany ) {
name = element.alias;
}
else {
Type type = element.elementType;
if ( type.isEntityType() ) { //ie. a many-to-many
String entityName = ( ( EntityType ) type ).getAssociatedEntityName();
name = pathExpressionParser.continueFromManyToMany( entityName, element.elementColumns, q );
}
else {
throw new QueryException( "illegally dereferenced collection element" );
}
}
return name;
}
代码示例来源:origin: hibernate/hibernate-orm
protected MapKeyEntityFromElement findOrAddMapKeyEntityFromElement(QueryableCollection collectionPersister) {
if ( !collectionPersister.getIndexType().isEntityType() ) {
return null;
}
for ( FromElement destination : getFromElement().getDestinations() ) {
if ( destination instanceof MapKeyEntityFromElement ) {
return (MapKeyEntityFromElement) destination;
}
}
return MapKeyEntityFromElement.buildKeyJoin( getFromElement() );
}
}
代码示例来源:origin: hibernate/hibernate-orm
private EntityReferenceAliases createCollectionElementAliases(
CollectionPersister collectionPersister,
String tableAlias,
String elementQuerySpaceUid) {
if ( !collectionPersister.getElementType().isEntityType() ) {
return null;
}
else {
final EntityType entityElementType = (EntityType) collectionPersister.getElementType();
return generateEntityReferenceAliases(
elementQuerySpaceUid,
tableAlias,
(EntityPersister) entityElementType.getAssociatedJoinable( sessionFactory() )
);
}
}
代码示例来源:origin: hibernate/hibernate-orm
private void addAssociationsToTheSetForOneProperty(String name, Type type, String prefix, SessionFactoryImplementor factory) {
if ( type.isCollectionType() ) {
CollectionType collType = (CollectionType) type;
Type assocType = collType.getElementType( factory );
addAssociationsToTheSetForOneProperty(name, assocType, prefix, factory);
}
//ToOne association
else if ( type.isEntityType() || type.isAnyType() ) {
associations.add( prefix + name );
}
else if ( type.isComponentType() ) {
CompositeType componentType = (CompositeType) type;
addAssociationsToTheSetForAllProperties(
componentType.getPropertyNames(),
componentType.getSubtypes(),
(prefix.equals( "" ) ? name : prefix + name) + ".",
factory);
}
}
代码示例来源:origin: hibernate/hibernate-orm
private EntityLoader createUniqueKeyLoader(
Type uniqueKeyType,
String[] columns,
LoadQueryInfluencers loadQueryInfluencers) {
if ( uniqueKeyType.isEntityType() ) {
String className = ( (EntityType) uniqueKeyType ).getAssociatedEntityName();
uniqueKeyType = getFactory().getMetamodel().entityPersister( className ).getIdentifierType();
}
return new EntityLoader(
this,
columns,
uniqueKeyType,
1,
LockMode.NONE,
getFactory(),
loadQueryInfluencers
);
}
代码示例来源:origin: hibernate/hibernate-orm
@Override
public String getAssociatedEntityName(SessionFactoryImplementor factory)
throws MappingException {
try {
QueryableCollection collectionPersister = (QueryableCollection) factory
.getCollectionPersister( role );
if ( !collectionPersister.getElementType().isEntityType() ) {
throw new MappingException(
"collection was not an association: " +
collectionPersister.getRole()
);
}
return collectionPersister.getElementPersister().getEntityName();
}
catch (ClassCastException cce) {
throw new MappingException( "collection role is not queryable " + role );
}
}
代码示例来源:origin: hibernate/hibernate-orm
public void end(QueryTranslatorImpl q) throws QueryException {
if ( !isCollectionValued() ) {
Type type = getPropertyType();
if ( type.isEntityType() ) {
// "finish off" the join
token( ".", q );
token( null, q );
}
else if ( type.isCollectionType() ) {
// default to element set if no elements() specified
token( ".", q );
token( CollectionPropertyNames.COLLECTION_ELEMENTS, q );
}
}
super.end( q );
}
代码示例来源:origin: hibernate/hibernate-orm
private void determineKeySelectExpressions(QueryableCollection collectionPersister, List selections) {
AliasGenerator aliasGenerator = new LocalAliasGenerator( 0 );
appendSelectExpressions( collectionPersister.getIndexColumnNames(), selections, aliasGenerator );
Type keyType = collectionPersister.getIndexType();
if ( keyType.isEntityType() ) {
MapKeyEntityFromElement mapKeyEntityFromElement = findOrAddMapKeyEntityFromElement( collectionPersister );
Queryable keyEntityPersister = mapKeyEntityFromElement.getQueryable();
SelectFragment fragment = keyEntityPersister.propertySelectFragmentFragment(
mapKeyEntityFromElement.getTableAlias(),
null,
false
);
appendSelectExpressions( fragment, selections, aliasGenerator );
}
}
代码示例来源:origin: hibernate/hibernate-orm
private TypeDiscriminatorMetadata buildTypeDiscriminatorMetadata() {
final String aliasToUse = getTableAlias();
Queryable queryable = getQueryable();
if ( queryable == null ) {
QueryableCollection collection = getQueryableCollection();
if ( ! collection.getElementType().isEntityType() ) {
throw new QueryException( "type discrimination cannot be applied to value collection [" + collection.getRole() + "]" );
}
queryable = (Queryable) collection.getElementPersister();
}
handlePropertyBeingDereferenced( getDataType(), DISCRIMINATOR_PROPERTY_NAME );
return new TypeDiscriminatorMetadataImpl( queryable.getTypeDiscriminatorMetadata(), aliasToUse );
}
代码示例来源:origin: hibernate/hibernate-orm
@Override
protected void applyRootReturnSelectFragments(SelectStatementBuilder selectStatementBuilder) {
if ( getRootCollectionReturn().allowIndexJoin() && getQueryableCollection().getIndexType().isEntityType() ) {
final EntityReference indexEntityReference = getRootCollectionReturn().getIndexGraph().resolveEntityReference();
final EntityReferenceAliases indexEntityReferenceAliases = getAliasResolutionContext().resolveEntityReferenceAliases(
indexEntityReference.getQuerySpaceUid()
);
selectStatementBuilder.appendSelectClauseFragment(
( (OuterJoinLoadable) indexEntityReference.getEntityPersister() ).selectFragment(
indexEntityReferenceAliases.getTableAlias(),
indexEntityReferenceAliases.getColumnAliases().getSuffix()
)
);
}
}
内容来源于网络,如有侵权,请联系作者删除!