org.hibernate.mapping.Property.getValue()方法的使用及代码示例

x33g5p2x  于2022-01-26 转载在 其他  
字(8.7k)|赞(0)|评价(0)|浏览(101)

本文整理了Java中org.hibernate.mapping.Property.getValue()方法的一些代码示例,展示了Property.getValue()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Property.getValue()方法的具体详情如下:
包路径:org.hibernate.mapping.Property
类名称:Property
方法名:getValue

Property.getValue介绍

暂无

代码示例

代码示例来源:origin: hibernate/hibernate-orm

public Value getHibernateValue() {
  return getPropertyMapping().getValue();
}

代码示例来源:origin: hibernate/hibernate-orm

public boolean isValid(Mapping mapping) throws MappingException {
  return getValue().isValid(mapping);
}

代码示例来源:origin: hibernate/hibernate-orm

private void mapPropertyToIndex(Property prop, int i) {
  propertyIndexes.put( prop.getName(), i );
  if ( prop.getValue() instanceof Component ) {
    Iterator iter = ( (Component) prop.getValue() ).getPropertyIterator();
    while ( iter.hasNext() ) {
      Property subprop = (Property) iter.next();
      propertyIndexes.put(
          prop.getName() + '.' + subprop.getName(),
          i
        );
    }
  }
}

代码示例来源: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

public Value getHibernateValue() {
  return ( (Map) getPropertyMapping().getValue() ).getIndex();
}

代码示例来源:origin: hibernate/hibernate-orm

public Value getHibernateValue() {
  return ( (Collection) getPropertyMapping().getValue() ).getElement();
}

代码示例来源:origin: hibernate/hibernate-orm

@Override
public boolean[] getColumnUpdateability() {
  boolean[] result = new boolean[ getColumnSpan() ];
  Iterator iter = getPropertyIterator();
  int i=0;
  while ( iter.hasNext() ) {
    Property prop = (Property) iter.next();
    boolean[] chunk = prop.getValue().getColumnUpdateability();
    if ( prop.isUpdateable() ) {
      System.arraycopy(chunk, 0, result, i, chunk.length);
    }
    i+=chunk.length;
  }
  return result;
}

代码示例来源: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

protected void checkPropertyColumnDuplication(Set distinctColumns, Iterator properties)
    throws MappingException {
  while ( properties.hasNext() ) {
    Property prop = (Property) properties.next();
    if ( prop.getValue() instanceof Component ) { //TODO: remove use of instanceof!
      Component component = (Component) prop.getValue();
      checkPropertyColumnDuplication( distinctColumns, component.getPropertyIterator() );
    }
    else {
      if ( prop.isUpdateable() || prop.isInsertable() ) {
        checkColumnDuplication( distinctColumns, prop.getColumnIterator() );
      }
    }
  }
}

代码示例来源:origin: hibernate/hibernate-orm

public void addProperty(Property prop, XClass declaringClass) {
  if ( prop.getValue() instanceof Component ) {
    //TODO handle quote and non quote table comparison
    String tableName = prop.getValue().getTable().getName();
    if ( getJoinsPerRealTableName().containsKey( tableName ) ) {
      final Join join = getJoinsPerRealTableName().get( tableName );
      addPropertyToJoin( prop, declaringClass, join );
    }
    else {
      addPropertyToPersistentClass( prop, declaringClass );
    }
  }
  else {
    addPropertyToPersistentClass( prop, declaringClass );
  }
}

代码示例来源:origin: hibernate/hibernate-orm

@Override
  public void process(InFlightMetadataCollector metadataCollector) {
    final PersistentClass clazz = metadataCollector.getEntityBinding( referencedClass );
    if ( clazz == null ) {
      throw new MappingException( "property-ref to unmapped class: " + referencedClass );
    }
    final Property prop = clazz.getReferencedProperty( propertyName );
    if ( unique ) {
      ( (SimpleValue) prop.getValue() ).setAlternateUniqueKey( true );
    }
  }
}

代码示例来源:origin: hibernate/hibernate-orm

private void checkComposite(Component composite) throws Exception {
  // check `eyeColor`
  final Property eyeColorProperty = composite.getProperty( "eyeColor" );
  final SimpleValue eyeColorValueMapping = (SimpleValue) eyeColorProperty.getValue();
  assertThat( simpleValueAttributeConverterDescriptorField.get( eyeColorValueMapping ), CoreMatchers.notNullValue() );
  // check `hairColor`
  final Property hairColorProperty = composite.getProperty( "hairColor" );
  final SimpleValue hairColorValueMapping = (SimpleValue) hairColorProperty.getValue();
  assertThat( simpleValueAttributeConverterDescriptorField.get( hairColorValueMapping ), CoreMatchers.notNullValue() );
}

代码示例来源:origin: hibernate/hibernate-orm

public void generateSecondPass(String entityName, PersistentClass persistentClass) {
  final Component identifierMapper = persistentClass.getIdentifierMapper();
  final Property identifierProperty = persistentClass.getIdentifierProperty();
  if ( identifierMapper != null ) {
    generateSecondPass( entityName, identifierMapper );
  }
  else if ( identifierProperty != null && identifierProperty.isComposite() ) {
    final Component component = (Component) identifierProperty.getValue();
    generateSecondPass( entityName, component );
  }
}

代码示例来源:origin: hibernate/hibernate-orm

private Type getMapKeyType(Property prop) {
  Value value = prop.getValue();
  assertEquals( Map.class, value.getClass() );
  Map map = (Map) value;
  return map.getIndex().getType();
}

代码示例来源:origin: hibernate/hibernate-orm

@Test
public void testColumnDefinition() {
  Column idCol = ( Column ) metadata().getEntityBinding( Ball.class.getName() )
      .getIdentifierProperty().getValue().getColumnIterator().next();
  assertEquals( "ball_id", idCol.getName() );
}

代码示例来源:origin: hibernate/hibernate-orm

@Override
protected void afterMetadataBuilt(Metadata metadata) {
  Collection children = metadata.getCollectionBinding( Parent.class.getName() + ".children" );
  Component childComponents = ( Component ) children.getElement();
  Formula f = ( Formula ) childComponents.getProperty( "bioLength" ).getValue().getColumnIterator().next();
  SQLFunction lengthFunction = metadata.getDatabase().getJdbcEnvironment().getDialect().getFunctions().get( "length" );
  if ( lengthFunction != null ) {
    ArrayList args = new ArrayList();
    args.add( "bio" );
    f.setFormula( lengthFunction.render( StandardBasicTypes.INTEGER, args, null ) );
  }
}

代码示例来源:origin: hibernate/hibernate-orm

@Test
@TestForIssue( jiraKey = "HHH-8630" )
public void testIt() {
  final PersistentClass entityBinding = metadata().getEntityBinding( AggregatedTypeValue.class.getName() );
  final Property attributesBinding = entityBinding.getProperty( "attributes" );
  final org.hibernate.mapping.Map attributesMap = (org.hibernate.mapping.Map) attributesBinding.getValue();
  final SimpleValue mapKey = assertTyping( SimpleValue.class, attributesMap.getIndex() );
  final BasicType mapKeyType = assertTyping( BasicType.class, mapKey.getType() );
  assertTrue( String.class.equals( mapKeyType.getReturnedClass() ) );
  // let's also make sure the @MapKeyColumn got applied
  assertThat( mapKey.getColumnSpan(), is(1) );
  final org.hibernate.mapping.Column mapKeyColumn = assertTyping( org.hibernate.mapping.Column .class, mapKey.getColumnIterator().next() );
  assertThat( mapKeyColumn.getName(), equalTo( "attribute_name" ) );
}

代码示例来源:origin: hibernate/hibernate-orm

@Test
public void testSortedSetDefinitionInHbmXml() {
  final PersistentClass entityMapping = metadata().getEntityBinding( Search.class.getName() );
  final Property sortedSetProperty = entityMapping.getProperty( "searchResults" );
  final Collection sortedSetMapping = assertTyping( Collection.class, sortedSetProperty.getValue()  );
  assertTrue( "SortedSet mapping not interpreted as sortable", sortedSetMapping.isSorted() );
  final Property sortedMapProperty = entityMapping.getProperty( "tokens" );
  final Collection sortedMapMapping = assertTyping( Collection.class, sortedMapProperty.getValue()  );
  assertTrue( "SortedMap mapping not interpreted as sortable", sortedMapMapping.isSorted() );
}

代码示例来源:origin: hibernate/hibernate-orm

@Test
  public void testComparator() {
    PersistentClass cm = metadata.getEntityBinding( "org.hibernate.test.legacy.Wicked" );
    
    Property property = cm.getProperty("sortedEmployee");
    Collection col = (Collection) property.getValue();
    assertEquals(col.getComparatorClassName(),"org.hibernate.test.legacy.NonExistingComparator");
  }
}

代码示例来源:origin: hibernate/hibernate-orm

@Test
public void testJoinTableIndex(){
  PersistentClass entity = metadata().getEntityBinding( Importer.class.getName() );
  Property property = entity.getProperty( "cars" );
  Bag set = (Bag)property.getValue();
  Table collectionTable = set.getCollectionTable();
  Iterator<Index> itr = collectionTable.getIndexIterator();
  assertTrue( itr.hasNext() );
  Index index = itr.next();
  assertFalse( itr.hasNext() );
  assertTrue( "index name is not generated", StringHelper.isNotEmpty( index.getName() ) );
  assertEquals( 1, index.getColumnSpan() );
  Iterator<Column> columnIterator = index.getColumnIterator();
  Column column = columnIterator.next();
  assertEquals( "importers_id", column.getName() );
  assertSame( collectionTable, index.getTable() );
}

相关文章

微信公众号

最新文章

更多