本文整理了Java中org.hibernate.mapping.Property
类的一些代码示例,展示了Property
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Property
类的具体详情如下:
包路径:org.hibernate.mapping.Property
类名称:Property
[英]Represents a property as part of an entity or a component.
[中]
代码示例来源:origin: hibernate/hibernate-orm
/**
* create a property copy reusing the same value
*/
public static Property shallowCopy(Property property) {
Property clone = new Property();
clone.setCascade( property.getCascade() );
clone.setInsertable( property.isInsertable() );
clone.setLazy( property.isLazy() );
clone.setName( property.getName() );
clone.setNaturalIdentifier( property.isNaturalIdentifier() );
clone.setOptimisticLocked( property.isOptimisticLocked() );
clone.setOptional( property.isOptional() );
clone.setPersistentClass( property.getPersistentClass() );
clone.setPropertyAccessorName( property.getPropertyAccessorName() );
clone.setSelectable( property.isSelectable() );
clone.setUpdateable( property.isUpdateable() );
clone.setValue( property.getValue() );
return clone;
}
代码示例来源:origin: hibernate/hibernate-orm
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 );
}
}
}
代码示例来源:origin: hibernate/hibernate-orm
Property property,
boolean lazyAvailable) {
String mappedUnsavedValue = ( (KeyValue) property.getValue() ).getNullValue();
(VersionType) property.getType(),
getConstructor( property.getPersistentClass() )
);
boolean lazy = lazyAvailable && property.isLazy();
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
代码示例来源:origin: hibernate/hibernate-orm
protected ServiceRegistry resolveServiceRegistry() {
if ( getPersistentClass() != null ) {
return getPersistentClass().getServiceRegistry();
}
if ( getValue() != null ) {
return getValue().getServiceRegistry();
}
throw new HibernateException( "Could not resolve ServiceRegistry" );
}
代码示例来源:origin: hibernate/hibernate-orm
@SuppressWarnings("unchecked")
private void createPropertiesGroupMapping(Property property) {
final Component component = (Component) property.getValue();
final Iterator<Property> componentProperties = component.getPropertyIterator();
while ( componentProperties.hasNext() ) {
final Property componentProperty = componentProperties.next();
propertiesGroupMapping.put( componentProperty.getName(), property.getName() );
}
}
代码示例来源:origin: hibernate/hibernate-orm
referencedPropertyName = collection.getReferencedPropertyName();
referencedEntityColumns = associatedClass.getIdentifier().getColumnIterator();
Property referencedProperty = associatedClass.getRecursiveProperty( referencedPropertyName );
referencedEntityColumns = referencedProperty.getColumnIterator();
Iterator properties = component.getPropertyIterator();
Component indexComponent = new Component( getBuildingContext(), collection );
indexComponent.setComponentClassName( component.getComponentClassName() );
while ( properties.hasNext() ) {
Property current = (Property) properties.next();
Property newProperty = new Property();
newProperty.setCascade( current.getCascade() );
newProperty.setValueGenerationStrategy( current.getValueGenerationStrategy() );
newProperty.setInsertable( false );
newProperty.setUpdateable( false );
newProperty.setMetaAttributes( current.getMetaAttributes() );
newProperty.setName( current.getName() );
newProperty.setNaturalIdentifier( false );
newProperty.setOptional( false );
newProperty.setPersistentClass( current.getPersistentClass() );
newProperty.setPropertyAccessorName( current.getPropertyAccessorName() );
newProperty.setSelectable( current.isSelectable() );
newProperty.setValue(
createFormulatedValue(
current.getValue(), collection, targetPropertyName, associatedClass, associatedClass, buildingContext
代码示例来源:origin: org.hibernate/hibernate-annotations
referencedPropertyName = collection.getReferencedPropertyName();
referencedEntityColumns = associatedClass.getIdentifier().getColumnIterator();
Property referencedProperty = associatedClass.getRecursiveProperty( referencedPropertyName );
referencedEntityColumns = referencedProperty.getColumnIterator();
.append( associatedClass.getTable().getName() )
Property current = (Property) properties.next();
Property newProperty = new Property();
newProperty.setCascade( current.getCascade() );
newProperty.setGeneration( current.getGeneration() );
newProperty.setInsertable( false );
newProperty.setUpdateable( false );
newProperty.setMetaAttributes( current.getMetaAttributes() );
newProperty.setName( current.getName() );
newProperty.setNodeName( current.getNodeName() );
newProperty.setNaturalIdentifier( false );
newProperty.setOptional( false );
newProperty.setPersistentClass( current.getPersistentClass() );
newProperty.setPropertyAccessorName( current.getPropertyAccessorName() );
newProperty.setSelectable( current.isSelectable() );
newProperty.setValue( createFormulatedValue( current.getValue(), collection, targetPropertyName,
associatedClass
) );
代码示例来源:origin: hibernate/hibernate-orm
discriminatorAlias = column.getAlias( factory.getDialect(), persistentClass.getRootTable() );
discriminatorType = (DiscriminatorType) persistentClass.getDiscriminator().getType();
throw new MappingException("Illegal discriminator type: " + discriminatorType.getName() );
throw new MappingException("Could not format discriminator value to SQL string", e);
int joinIdColumnSpan = key.getColumnSpan();
while ( iter.hasNext() ) {
Property prop = (Property) iter.next();
String tabname = prop.getValue().getTable().getQualifiedName(
factory.getDialect(),
factory.getSettings().getDefaultCatalogName(),
while ( iter.hasNext() ) {
Property prop = (Property) iter.next();
Table tab = prop.getValue().getTable();
String tabname = tab.getQualifiedName(
factory.getDialect(),
propTableNumbers.add( tabnum );
Iterator citer = prop.getColumnIterator();
while ( citer.hasNext() ) {
Selectable thing = (Selectable) citer.next();
代码示例来源:origin: hibernate/hibernate-orm
versionColumnName = ( (Column) persistentClass.getVersion().getColumnIterator().next() ).getQuotedName( dialect );
int span = prop.getColumnSpan();
propertyColumnSpans[i] = span;
propertySubclassNames[i] = prop.getPersistentClass().getEntityName();
String[] colNames = new String[span];
String[] colAliases = new String[span];
String[] colWriters = new String[span];
String[] formulaTemplates = new String[span];
Iterator colIter = prop.getColumnIterator();
int k = 0;
while ( colIter.hasNext() ) {
Selectable thing = (Selectable) colIter.next();
colAliases[k] = thing.getAlias( dialect, prop.getValue().getTable() );
if ( thing.isFormula() ) {
foundFormula = true;
if ( lazyAvailable && prop.isLazy() ) {
lazyNames.add( prop.getName() );
lazyNumbers.add( i );
lazyTypes.add( prop.getValue().getType() );
lazyColAliases.add( colAliases );
propertyColumnUpdateable[i] = prop.getValue().getColumnUpdateability();
propertyColumnInsertable[i] = prop.getValue().getColumnInsertability();
propertySelectable[i] = prop.isSelectable();
代码示例来源:origin: hibernate/hibernate-orm
deleteResultCheckStyles = new ExecuteUpdateResultCheckStyle[joinSpan];
customSQLInsert[0] = persistentClass.getCustomSQLInsert();
.getJpaCompliance()
.isJpaCacheComplianceEnabled();
cascadeDeleteEnabled[j] = join.getKey().isCascadeDeleteEnabled() &&
factory.getDialect().supportsCascadeDelete();
: join.getCustomSQLDeleteCheckStyle();
throw new MappingException( "discriminator mapping required for single table polymorphic persistence" );
discriminatorFormulaTemplate = null;
discriminatorType = persistentClass.getDiscriminator().getType();
throw new MappingException( "Illegal discriminator type: " + discriminatorType.getName() );
throw new MappingException( "Could not format discriminator value to SQL string", e );
prop.getPersistentClass().getEntityName() + '.' + prop.getName(),
join
);
Iterator citer = prop.getColumnIterator();
while ( citer.hasNext() ) {
Selectable thing = (Selectable) citer.next();
代码示例来源:origin: hibernate/hibernate-orm
AtomicInteger index,
Property referencedProperty ) {
Property property = new Property();
property.setName( referencedProperty.getName() );
property.setPersistentClass( component.getOwner() );
property.setPropertyAccessorName( referencedProperty.getPropertyAccessorName() );
SimpleValue value = new SimpleValue( buildingContext, component.getTable() );
property.setValue( value );
final SimpleValue referencedValue = (SimpleValue) referencedProperty.getValue();
value.setTypeName( referencedValue.getTypeName() );
value.setTypeParameters( referencedValue.getTypeParameters() );
final Iterator<Selectable> columns = referencedValue.getColumnIterator();
final String columnName = column.getName();
logicalColumnName = buildingContext.getMetadataCollector().getLogicalColumnName(
referencedPersistentClass.getTable(),
columnName
);
代码示例来源:origin: hibernate/hibernate-orm
AtomicInteger index,
Property referencedProperty ) {
Property property = new Property();
property.setName( referencedProperty.getName() );
property.setPersistentClass( component.getOwner() );
property.setPropertyAccessorName( referencedProperty.getPropertyAccessorName() );
Component value = new Component( buildingContext, component.getOwner() );
property.setValue( value );
final Component referencedValue = (Component) referencedProperty.getValue();
value.setTypeName( referencedValue.getTypeName() );
value.setTypeParameters( referencedValue.getTypeParameters() );
Property referencedComponentProperty = propertyIterator.next();
if ( referencedComponentProperty.isComposite() ) {
Property componentProperty = createComponentProperty( referencedValue.getOwner(), isExplicitReference, columnByReferencedName, index, referencedComponentProperty );
value.addProperty( componentProperty );
代码示例来源:origin: hibernate/hibernate-orm
protected void validateZipCode(Metadata metadata) {
final PersistentClass zipCodeBinding = metadata.getEntityBinding( ZipCode.class.getName() );
assertNotNull( zipCodeBinding );
validateZipCodePrimaryTableName( zipCodeBinding.getTable().getQuotedName() );
assertEquals( 1, zipCodeBinding.getIdentifier().getColumnSpan() );
validateZipCodePrimaryKeyColumn( (Column) zipCodeBinding.getIdentifier().getColumnIterator().next() );
final Property codeBinding = zipCodeBinding.getProperty( "code" );
assertNotNull( codeBinding );
assertEquals( 1, codeBinding.getColumnSpan() );
validateZipCodeCodeColumn( (Column) codeBinding.getColumnIterator().next() );
final Property cityBinding = zipCodeBinding.getProperty( "city" );
assertNotNull( cityBinding );
assertEquals( 1, cityBinding.getColumnSpan() );
validateZipCodeCityColumn( (Column) cityBinding.getColumnIterator().next() );
final Property stateBinding = zipCodeBinding.getProperty( "state" );
assertNotNull( stateBinding );
assertEquals( 1, stateBinding.getColumnSpan() );
validateZipCodeStateColumn( (Column) stateBinding.getColumnIterator().next() );
}
代码示例来源:origin: hibernate/hibernate-orm
LOG.debugf( "Retrieving property %s.%s", associatedClass.getEntityName(), mappedByProperty );
final Property property = associatedClass.getRecursiveProperty( columns[0].getMappedBy() );
Iterator mappedByColumns;
if ( property.getValue() instanceof Collection ) {
Collection collection = ( (Collection) property.getValue() );
Value element = collection.getElement();
if ( element == null ) {
throw new AnnotationException(
"Illegal use of mappedBy on both sides of the relationship: "
+ associatedClass.getEntityName() + "." + mappedByProperty
);
mappedByColumns = element.getColumnIterator();
mappedByColumns = property.getValue().getColumnIterator();
idColumns = referencedEntity.getKey().getColumnIterator();
idColumns = referencedEntity.getIdentifier().getColumnIterator();
if ( propertyName != null ) {
Collection collection = (Collection) referencedEntity.getRecursiveProperty( propertyName )
.getValue();
referencedPropertyName = collection.getReferencedPropertyName();
referencedEntity, synthProp.getColumnIterator(), columns, value
);
代码示例来源:origin: hibernate/hibernate-orm
final String element = (String) st.nextElement();
if ( property == null ) {
Property identifierProperty = getIdentifierProperty();
if ( identifierProperty != null && identifierProperty.getName().equals( element ) ) {
else if ( identifierProperty == null && getIdentifierMapper() != null ) {
identifierProperty = getProperty( element, getIdentifierMapper().getPropertyIterator() );
if ( identifierProperty != null ) {
property = ( (Component) property.getValue() ).getProperty( element );
throw new MappingException( "property [" + propertyPath + "] not found on entity [" + getEntityName() + "]" );
代码示例来源:origin: hibernate/hibernate-orm
propertyNameBuffer.append( associatedClass.getEntityName().replace( '.', '_' ) );
propertyNameBuffer.append( "_" ).append( columns[0].getPropertyName().replace( '.', '_' ) );
String syntheticPropertyName = propertyNameBuffer.toString();
new Component( context, (PersistentClass) columnOwner ) :
new Component( context, (Join) columnOwner );
embeddedComp.setEmbedded( true );
embeddedComp.setComponentClassName( embeddedComp.getOwner().getClassName() );
for (Property property : properties) {
Property clone = BinderHelper.shallowCopy( property );
clone.setInsertable( false );
clone.setUpdateable( false );
clone.setNaturalIdentifier( false );
clone.setValueGenerationStrategy( property.getValueGenerationStrategy() );
embeddedComp.addProperty( clone );
synthProp.setName( syntheticPropertyName );
synthProp.setPersistentClass( ownerEntity );
synthProp.setUpdateable( false );
synthProp.setInsertable( false );
synthProp.setValue( embeddedComp );
synthProp.setPropertyAccessorName( "embedded" );
ownerEntity.addProperty( synthProp );
( (Collection) value ).setReferencedPropertyName( syntheticPropertyName );
代码示例来源:origin: hibernate/hibernate-orm
Property idProperty = associatedClass.getIdentifierProperty();
String idName = idProperty != null ? idProperty.getName() : null;
try {
if ( propertyName == null
String element = (String) st.nextElement();
if ( property == null ) {
property = associatedClass.getProperty( element );
if ( !property.isComposite() ) {
return null;
property = ( (Component) property.getValue() ).getProperty( element );
try {
if ( associatedClass.getIdentifierMapper() == null ) {
return null;
String element = (String) st.nextElement();
if ( property == null ) {
property = associatedClass.getIdentifierMapper().getProperty( element );
if ( !property.isComposite() ) {
return null;
property = ( (Component) property.getValue() ).getProperty( element );
代码示例来源:origin: hibernate/hibernate-orm
@Test
@FailureExpected( jiraKey = "HHH-9089" )
public void testEnumTypeInterpretation() {
StandardServiceRegistry ssr = new StandardServiceRegistryBuilder().build();
try {
final Metadata metadata = new MetadataSources( ssr )
.addAnnotatedClass( Customer.class )
.buildMetadata();
PersistentClass classMetadata = metadata.getEntityBinding( Customer.class.getName() );
Property investmentsProperty = classMetadata.getProperty( "investments" );
Collection investmentsValue = (Collection) investmentsProperty.getValue();
Component investmentMetadata = (Component) investmentsValue.getElement();
Value descriptionValue = investmentMetadata.getProperty( "description" ).getValue();
assertEquals( 1, descriptionValue.getColumnSpan() );
Column selectable = (Column) descriptionValue.getColumnIterator().next();
assertEquals( 500, selectable.getLength() );
Component amountMetadata = (Component) investmentMetadata.getProperty( "amount" ).getValue();
SimpleValue currencyMetadata = (SimpleValue) amountMetadata.getProperty( "currency" ).getValue();
CustomType currencyType = (CustomType) currencyMetadata.getType();
int[] currencySqlTypes = currencyType.sqlTypes( metadata );
assertEquals( 1, currencySqlTypes.length );
assertJdbcTypeCode( Types.VARCHAR, currencySqlTypes[0] );
}
finally {
StandardServiceRegistryBuilder.destroy( ssr );
}
}
}
代码示例来源:origin: hibernate/hibernate-orm
public void validate(Mapping mapping) throws MappingException {
Iterator iter = getPropertyIterator();
while ( iter.hasNext() ) {
Property prop = (Property) iter.next();
if ( !prop.isValid( mapping ) ) {
throw new MappingException(
"property mapping has wrong number of columns: " +
StringHelper.qualify( getEntityName(), prop.getName() ) +
" type: " +
prop.getType().getName()
);
}
}
checkPropertyDuplication();
checkColumnDuplication();
}
代码示例来源:origin: hibernate/hibernate-orm
AttributeSource propertySource,
Property property) {
property.setName( propertySource.getName() );
property.setPropertyAccessorName(
StringHelper.isNotEmpty( propertySource.getPropertyAccessorName() )
? propertySource.getPropertyAccessorName()
property.setCascade(
StringHelper.isNotEmpty( cascadeStyleSource.getCascadeStyleName() )
? cascadeStyleSource.getCascadeStyleName()
property.setOptimisticLocked( propertySource.isIncludedInOptimisticLocking() );
property.setInsertable( singularAttributeSource.isInsertable() );
property.setUpdateable( singularAttributeSource.isUpdatable() );
property.setLazy( singularAttributeSource.isBytecodeLazy() );
property.setValueGenerationStrategy( new GeneratedValueGeneration( generationTiming ) );
if ( property.isInsertable() ) {
log.debugf(
"Property [%s] specified %s generation, setting insertable to false : %s",
mappingDocument.getOrigin()
);
property.setInsertable( false );
内容来源于网络,如有侵权,请联系作者删除!