本文整理汇总了Java中org.hibernate.mapping.Property.getName方法的典型用法代码示例。如果您正苦于以下问题:Java Property.getName方法的具体用法?Java Property.getName怎么用?Java Property.getName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.hibernate.mapping.Property
的用法示例。
在下文中一共展示了Property.getName方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: internalInitSubclassPropertyAliasesMap
import org.hibernate.mapping.Property; //导入方法依赖的package包/类
private void internalInitSubclassPropertyAliasesMap(String path, Iterator propertyIterator) {
while ( propertyIterator.hasNext() ) {
Property prop = ( Property ) propertyIterator.next();
String propname = path == null ? prop.getName() : path + "." + prop.getName();
if ( prop.isComposite() ) {
Component component = ( Component ) prop.getValue();
Iterator compProps = component.getPropertyIterator();
internalInitSubclassPropertyAliasesMap( propname, compProps );
}
else {
String[] aliases = new String[prop.getColumnSpan()];
String[] cols = new String[prop.getColumnSpan()];
Iterator colIter = prop.getColumnIterator();
int l = 0;
while ( colIter.hasNext() ) {
Selectable thing = ( Selectable ) colIter.next();
aliases[l] = thing.getAlias( getFactory().getDialect(), prop.getValue().getTable() );
cols[l] = thing.getText( getFactory().getDialect() ); // TODO: skip formulas?
l++;
}
subclassPropertyAliases.put( propname, aliases );
subclassPropertyColumnNames.put( propname, cols );
}
}
}
示例2: buildIdentifierAttribute
import org.hibernate.mapping.Property; //导入方法依赖的package包/类
/**
* Generates the attribute representation of the identifier for a given entity mapping.
*
* @param mappedEntity The mapping definition of the entity.
* @param generator The identifier value generator to use for this identifier.
* @return The appropriate IdentifierProperty definition.
*/
public static IdentifierProperty buildIdentifierAttribute(
PersistentClass mappedEntity,
IdentifierGenerator generator) {
String mappedUnsavedValue = mappedEntity.getIdentifier().getNullValue();
Type type = mappedEntity.getIdentifier().getType();
Property property = mappedEntity.getIdentifierProperty();
IdentifierValue unsavedValue = UnsavedValueFactory.getUnsavedIdentifierValue(
mappedUnsavedValue,
getGetter( property ),
type,
getConstructor(mappedEntity)
);
if ( property == null ) {
// this is a virtual id property...
return new IdentifierProperty(
type,
mappedEntity.hasEmbeddedIdentifier(),
mappedEntity.hasIdentifierMapper(),
unsavedValue,
generator
);
}
else {
return new IdentifierProperty(
property.getName(),
property.getNodeName(),
type,
mappedEntity.hasEmbeddedIdentifier(),
unsavedValue,
generator
);
}
}
示例3: buildVersionProperty
import org.hibernate.mapping.Property; //导入方法依赖的package包/类
/**
* Generates a VersionProperty representation for an entity mapping given its
* version mapping Property.
*
* @param property The version mapping Property.
* @param lazyAvailable Is property lazy loading currently available.
* @return The appropriate VersionProperty definition.
*/
public static VersionProperty buildVersionProperty(
EntityPersister persister,
SessionFactoryImplementor sessionFactory,
int attributeNumber,
Property property,
boolean lazyAvailable) {
String mappedUnsavedValue = ( (KeyValue) property.getValue() ).getNullValue();
VersionValue unsavedValue = UnsavedValueFactory.getUnsavedVersionValue(
mappedUnsavedValue,
getGetter( property ),
(VersionType) property.getType(),
getConstructor( property.getPersistentClass() )
);
boolean lazy = lazyAvailable && property.isLazy();
return new VersionProperty(
persister,
sessionFactory,
attributeNumber,
property.getName(),
property.getValue().getType(),
new BaselineAttributeInformation.Builder()
.setLazy( lazy )
.setInsertable( property.isInsertable() )
.setUpdateable( property.isUpdateable() )
.setValueGenerationStrategy( property.getValueGenerationStrategy() )
.setNullable( property.isOptional() )
.setDirtyCheckable( property.isUpdateable() && !lazy )
.setVersionable( property.isOptimisticLocked() )
.setCascadeStyle( property.getCascadeStyle() )
.createInformation(),
unsavedValue
);
}
示例4: buildStandardProperty
import org.hibernate.mapping.Property; //导入方法依赖的package包/类
@Deprecated
public static StandardProperty buildStandardProperty(Property property, boolean lazyAvailable) {
final Type type = property.getValue().getType();
// we need to dirty check collections, since they can cause an owner
// version number increment
// we need to dirty check many-to-ones with not-found="ignore" in order
// to update the cache (not the database), since in this case a null
// entity reference can lose information
boolean alwaysDirtyCheck = type.isAssociationType() &&
( (AssociationType) type ).isAlwaysDirtyChecked();
return new StandardProperty(
property.getName(),
type,
lazyAvailable && property.isLazy(),
property.isInsertable(),
property.isUpdateable(),
property.getValueGenerationStrategy(),
property.isOptional(),
alwaysDirtyCheck || property.isUpdateable(),
property.isOptimisticLocked(),
property.getCascadeStyle(),
property.getValue().getFetchMode()
);
}
示例5: buildIdentifierProperty
import org.hibernate.mapping.Property; //导入方法依赖的package包/类
/**
* Generates an IdentifierProperty representation of the for a given entity mapping.
*
* @param mappedEntity The mapping definition of the entity.
* @param generator The identifier value generator to use for this identifier.
* @return The appropriate IdentifierProperty definition.
*/
public static IdentifierProperty buildIdentifierProperty(PersistentClass mappedEntity, IdentifierGenerator generator) {
String mappedUnsavedValue = mappedEntity.getIdentifier().getNullValue();
Type type = mappedEntity.getIdentifier().getType();
Property property = mappedEntity.getIdentifierProperty();
IdentifierValue unsavedValue = UnsavedValueFactory.getUnsavedIdentifierValue(
mappedUnsavedValue,
getGetter( property ),
type,
getConstructor(mappedEntity)
);
if ( property == null ) {
// this is a virtual id property...
return new IdentifierProperty(
type,
mappedEntity.hasEmbeddedIdentifier(),
mappedEntity.hasIdentifierMapper(),
unsavedValue,
generator
);
}
else {
return new IdentifierProperty(
property.getName(),
property.getNodeName(),
type,
mappedEntity.hasEmbeddedIdentifier(),
unsavedValue,
generator
);
}
}
示例6: buildVersionProperty
import org.hibernate.mapping.Property; //导入方法依赖的package包/类
/**
* Generates a VersionProperty representation for an entity mapping given its
* version mapping Property.
*
* @param property The version mapping Property.
* @param lazyAvailable Is property lazy loading currently available.
* @return The appropriate VersionProperty definition.
*/
public static VersionProperty buildVersionProperty(Property property, boolean lazyAvailable) {
String mappedUnsavedValue = ( (KeyValue) property.getValue() ).getNullValue();
VersionValue unsavedValue = UnsavedValueFactory.getUnsavedVersionValue(
mappedUnsavedValue,
getGetter( property ),
(VersionType) property.getType(),
getConstructor( property.getPersistentClass() )
);
boolean lazy = lazyAvailable && property.isLazy();
return new VersionProperty(
property.getName(),
property.getNodeName(),
property.getValue().getType(),
lazy,
property.isInsertable(),
property.isUpdateable(),
property.getGeneration() == PropertyGeneration.INSERT || property.getGeneration() == PropertyGeneration.ALWAYS,
property.getGeneration() == PropertyGeneration.ALWAYS,
property.isOptional(),
property.isUpdateable() && !lazy,
property.isOptimisticLocked(),
property.getCascadeStyle(),
unsavedValue
);
}
示例7: buildStandardProperty
import org.hibernate.mapping.Property; //导入方法依赖的package包/类
/**
* Generate a "standard" (i.e., non-identifier and non-version) based on the given
* mapped property.
*
* @param property The mapped property.
* @param lazyAvailable Is property lazy loading currently available.
* @return The appropriate StandardProperty definition.
*/
public static StandardProperty buildStandardProperty(Property property, boolean lazyAvailable) {
final Type type = property.getValue().getType();
// we need to dirty check collections, since they can cause an owner
// version number increment
// we need to dirty check many-to-ones with not-found="ignore" in order
// to update the cache (not the database), since in this case a null
// entity reference can lose information
boolean alwaysDirtyCheck = type.isAssociationType() &&
( (AssociationType) type ).isAlwaysDirtyChecked();
return new StandardProperty(
property.getName(),
property.getNodeName(),
type,
lazyAvailable && property.isLazy(),
property.isInsertable(),
property.isUpdateable(),
property.getGeneration() == PropertyGeneration.INSERT || property.getGeneration() == PropertyGeneration.ALWAYS,
property.getGeneration() == PropertyGeneration.ALWAYS,
property.isOptional(),
alwaysDirtyCheck || property.isUpdateable(),
property.isOptimisticLocked(),
property.getCascadeStyle(),
property.getValue().getFetchMode()
);
}
示例8: getAttributeForTabCol
import org.hibernate.mapping.Property; //导入方法依赖的package包/类
private String getAttributeForTabCol(String entity, String col)
{
if (entity == null || col == null)
return null;
PersistentClass cls = Registry.getInstance().getConfiguration().getClassMapping(entity);
if (cls != null)
{
Iterator it = cls.getPropertyIterator();
while (it.hasNext())
{
Property prop = (Property) it.next();
Iterator it2 = prop.getColumnIterator();
while (it2.hasNext())
{
Column col2 = (Column) it2.next();
if (col2 != null && col2.getName().equals(col))
return prop.getName();
}
}
}
// Recursively get super classes in case not found in at this level
if (cls.getSuperclass() != null)
{
return (getAttributeForTabCol(cls.getSuperclass().getClassName(), col));
}
return null;
}
示例9: getEndName
import org.hibernate.mapping.Property; //导入方法依赖的package包/类
public String getEndName(String parentClassname, String childClassname) throws TypesInformationException {
LOG.debug("Getting the association end name for " + parentClassname + " to " + childClassname);
String identifier = getAssociationIdentifier(parentClassname, childClassname);
String roleName = roleNames.get(identifier);
if (roleName == null) {
PersistentClass clazz = findPersistentClass(parentClassname);
Iterator<?> propertyIter = clazz.getPropertyIterator();
while (propertyIter.hasNext()) {
Property prop = (Property) propertyIter.next();
Value value = prop.getValue();
String referencedEntity = null;
if (value instanceof Collection) {
Value element = ((Collection) value).getElement();
if (element instanceof OneToMany) {
referencedEntity = ((OneToMany) element).getReferencedEntityName();
} else if (element instanceof ToOne) {
referencedEntity = ((ToOne) element).getReferencedEntityName();
}
} else if (value instanceof ToOne) {
referencedEntity = ((ToOne) value).getReferencedEntityName();
}
if (childClassname.equals(referencedEntity)) {
if (roleName != null) {
// already found one association, so this is ambiguous
throw new TypesInformationException("Association from " + parentClassname + " to "
+ childClassname + " is ambiguous. Please specify a valid role name");
}
roleName = prop.getName();
}
}
}
return roleName;
}
示例10: buildPair
import org.hibernate.mapping.Property; //导入方法依赖的package包/类
public GenerationStrategyPair buildPair() {
if ( hadInMemoryGeneration && hadInDatabaseGeneration ) {
throw new ValueGenerationStrategyException(
"Composite attribute [" + mappingProperty.getName() + "] contained both in-memory"
+ " and in-database value generation"
);
}
else if ( hadInMemoryGeneration ) {
throw new NotYetImplementedException( "Still need to wire in composite in-memory value generation" );
}
else if ( hadInDatabaseGeneration ) {
final Component composite = (Component) mappingProperty.getValue();
// we need the numbers to match up so we can properly handle 'referenced sql column values'
if ( inDatabaseStrategies.size() != composite.getPropertySpan() ) {
throw new ValueGenerationStrategyException(
"Internal error : mismatch between number of collected in-db generation strategies" +
" and number of attributes for composite attribute : " + mappingProperty.getName()
);
}
// the base-line values for the aggregated InDatabaseValueGenerationStrategy we will build here.
GenerationTiming timing = GenerationTiming.INSERT;
boolean referenceColumns = false;
String[] columnValues = new String[ composite.getColumnSpan() ];
// start building the aggregate values
int propertyIndex = -1;
int columnIndex = 0;
Iterator subProperties = composite.getPropertyIterator();
while ( subProperties.hasNext() ) {
propertyIndex++;
final Property subProperty = (Property) subProperties.next();
final InDatabaseValueGenerationStrategy subStrategy = inDatabaseStrategies.get( propertyIndex );
if ( subStrategy.getGenerationTiming() == GenerationTiming.ALWAYS ) {
// override the base-line to the more often "ALWAYS"...
timing = GenerationTiming.ALWAYS;
}
if ( subStrategy.referenceColumnsInSql() ) {
// override base-line value
referenceColumns = true;
}
if ( subStrategy.getReferencedColumnValues() != null ) {
if ( subStrategy.getReferencedColumnValues().length != subProperty.getColumnSpan() ) {
throw new ValueGenerationStrategyException(
"Internal error : mismatch between number of collected 'referenced column values'" +
" and number of columns for composite attribute : " + mappingProperty.getName() +
'.' + subProperty.getName()
);
}
System.arraycopy(
subStrategy.getReferencedColumnValues(),
0,
columnValues,
columnIndex,
subProperty.getColumnSpan()
);
}
}
// then use the aggregated values to build the InDatabaseValueGenerationStrategy
return new GenerationStrategyPair(
new InDatabaseValueGenerationStrategyImpl( timing, referenceColumns, columnValues )
);
}
else {
return NO_GEN_PAIR;
}
}
示例11: getRoleName
import org.hibernate.mapping.Property; //导入方法依赖的package包/类
public String getRoleName(String parentClassname, String childClassname) throws TypesInformationException {
String identifier = getAssociationIdentifier(parentClassname, childClassname);
String roleName = roleNames.get(identifier);
if (roleName == null) {
PersistentClass clazz = configuration.getClassMapping(parentClassname);
Iterator<?> propertyIter = clazz.getPropertyIterator();
while (propertyIter.hasNext()) {
Property prop = (Property) propertyIter.next();
Value value = prop.getValue();
String referencedEntity = null;
if (value instanceof Collection) {
Value element = ((Collection) value).getElement();
if (element instanceof OneToMany) {
referencedEntity = ((OneToMany) element).getReferencedEntityName();
} else if (element instanceof ToOne) {
referencedEntity = ((ToOne) element).getReferencedEntityName();
}
} else if (value instanceof ToOne) {
referencedEntity = ((ToOne) value).getReferencedEntityName();
}
if (childClassname.equals(referencedEntity)) {
if (roleName != null) {
// already found one association, so this is ambiguous
throw new TypesInformationException("Association from " + parentClassname + " to "
+ childClassname + " is ambiguous. Please specify a valid role name");
}
roleName = prop.getName();
}
}
if (roleName == null && reflectionFallback) {
LOG.debug("No role name found for " + identifier + " using hibernate configuration, trying reflection");
Class<?> parentClass = null;
try {
parentClass = Class.forName(parentClassname);
} catch (ClassNotFoundException ex) {
LOG.error("Could not load parent class: " + ex.getMessage());
throw new TypesInformationException("Could not load parent class: " + ex.getMessage());
}
Field[] fields = parentClass.getDeclaredFields();
for (Field f : fields) {
// if collection, inspect the collection for type
Class<?> fieldType = f.getType();
if (java.util.Collection.class.isAssignableFrom(fieldType)) {
Type generic = f.getGenericType();
if (generic instanceof ParameterizedType) {
Type contents = ((ParameterizedType) generic).getActualTypeArguments()[0];
if (contents instanceof Class
&& childClassname.equals(((Class<?>) contents).getName())) {
roleName = f.getName();
}
}
} else if (fieldType.getName().equals(childClassname)) {
if (roleName != null) {
// already found one association, so this is ambiguous
throw new TypesInformationException("Association from " + parentClassname + " to "
+ childClassname + " is ambiguous. Please specify a valid role name");
}
roleName = f.getName();
}
}
}
}
return roleName;
}
示例12: getRoleName
import org.hibernate.mapping.Property; //导入方法依赖的package包/类
public String getRoleName(String parentClassname, String childClassname) throws TypesInformationException {
String identifier = getAssociationIdentifier(parentClassname, childClassname);
String roleName = roleNames.get(identifier);
if (roleName == null) {
PersistentClass clazz = configuration.getClassMapping(parentClassname);
Iterator<?> propertyIter = clazz.getPropertyIterator();
while (propertyIter.hasNext()) {
Property prop = (Property) propertyIter.next();
Value value = prop.getValue();
String referencedEntity = null;
if (value instanceof Collection) {
Value element = ((Collection) value).getElement();
if (element instanceof OneToMany) {
referencedEntity = ((OneToMany) element).getReferencedEntityName();
} else if (element instanceof ToOne) {
referencedEntity = ((ToOne) element).getReferencedEntityName();
}
} else if (value instanceof ToOne) {
referencedEntity = ((ToOne) value).getReferencedEntityName();
}
if (childClassname.equals(referencedEntity)) {
if (roleName != null) {
// already found one association, so this is ambiguous
throw new TypesInformationException("Association from " + parentClassname + " to "
+ childClassname + " is ambiguous. Please specify a valid role name");
}
roleName = prop.getName();
}
}
if (roleName == null && reflectionFallback) {
LOG.debug("No role name found for " + identifier + " using hibernate configuration, trying reflection");
Class<?> parentClass = null;
try {
parentClass = Class.forName(parentClassname);
} catch (ClassNotFoundException ex) {
LOG.error("Could not load parent class: " + ex.getMessage());
throw new TypesInformationException("Could not load parent class: " + ex.getMessage());
}
Field[] fields = parentClass.getDeclaredFields();
for (Field f : fields) {
// if collection, inspect the collection for type
Class<?> fieldType = f.getType();
if (java.util.Collection.class.isAssignableFrom(fieldType)) {
Type generic = f.getGenericType();
if (generic instanceof ParameterizedType) {
Type contents = ((ParameterizedType) generic).getActualTypeArguments()[0];
if (contents instanceof Class
&& childClassname.equals(((Class) contents).getName())) {
roleName = f.getName();
}
}
} else if (fieldType.getName().equals(childClassname)) {
if (roleName != null) {
// already found one association, so this is ambiguous
throw new TypesInformationException("Association from " + parentClassname + " to "
+ childClassname + " is ambiguous. Please specify a valid role name");
}
roleName = f.getName();
}
}
}
}
return roleName;
}