Package org.hibernate.mapping

Examples of org.hibernate.mapping.MetaAttribute


    /**
     * @param property
     */
    private void markAsUseInEquals(Property property) {
        Map m = new HashMap();
        MetaAttribute ma = new MetaAttribute("use-in-equals");
        ma.addValue("true");
        m.put(ma.getName(),ma);
        property.setMetaAttributes(m);
    }
View Full Code Here


 
  // called by subclasses
  protected void init() {
    importContext = new ImportContextImpl(getPackageName());
   
    MetaAttribute metaAttribute = meta.getMetaAttribute("extra-import");
    if(metaAttribute!=null) {
      Iterator values = metaAttribute.getValues().iterator();
      while ( values.hasNext() ) {
        String element = (String) values.next();
        importContext.importType(element);       
      }
    } 
View Full Code Here

  }
 
  protected abstract String getMappedClassName();

  public String getMetaAsString(String attribute) {
    MetaAttribute c = meta.getMetaAttribute( attribute );
    return MetaAttributeHelper.getMetaAsString( c );
  }
View Full Code Here

  public boolean getMetaAsBool(String attribute, boolean defaultValue) {
    return MetaAttributeHelper.getMetaAsBool( meta.getMetaAttribute( attribute ), defaultValue );
  }

  public String getClassJavaDoc(String fallback, int indent) {
    MetaAttribute c = meta.getMetaAttribute( CLASS_DESCRIPTION );
    if ( c == null ) {
      return c2j.toJavaDoc( fallback, indent );
    }
    else {
      return c2j.toJavaDoc( getMetaAsString( CLASS_DESCRIPTION ), indent );
View Full Code Here

  public boolean hasFieldJavaDoc(Property property) {
    return property.getMetaAttribute("field-description")!=null;
  }
 
  public String getFieldJavaDoc(Property property, int indent) {
    MetaAttribute c = property.getMetaAttribute( "field-description" );
    if ( c == null ) {
      return c2j.toJavaDoc( "", indent );
    }
    else {
      return c2j.toJavaDoc( c2j.getMetaAsString( property, "field-description" ), indent );
View Full Code Here

      return c2j.toJavaDoc( c2j.getMetaAsString( property, "field-description" ), indent );
    }
  }
 
  public String getFieldDescription(Property property){
    MetaAttribute c = property.getMetaAttribute( "field-description" );
    if ( c == null ) {
      return "";
    }
    else {
      return c2j.getMetaAsString( property, "field-description" );
View Full Code Here

    return getModifiers( property, "scope-set", "public" );
  }

  //TODO defaultModifiers
  private String getModifiers(Property property, String modifiername, String defaultModifiers) {
    MetaAttribute override = property.getMetaAttribute( modifiername );
    if ( override != null ) {
      return MetaAttributeHelper.getMetaAsString( override );
    }
    else {
      return defaultModifiers;
View Full Code Here

    Map m = cm.getMetaAttributes();
    assertNotNull(m);
    assertNotNull(cm.getMetaAttribute("global"));
    assertNull(cm.getMetaAttribute("globalnoinherit"));
   
    MetaAttribute metaAttribute = cm.getMetaAttribute("implements");
    assertNotNull(metaAttribute);
    assertEquals("implements", metaAttribute.getName());
    assertTrue(metaAttribute.isMultiValued());
    assertEquals(3, metaAttribute.getValues().size());
    assertEquals("java.lang.Observer",metaAttribute.getValues().get(0));
    assertEquals("java.lang.Observer",metaAttribute.getValues().get(1));
    assertEquals("org.foo.BogusVisitor",metaAttribute.getValues().get(2));
       
    /*Property property = cm.getIdentifierProperty();
    property.getMetaAttribute(null);*/
   
    Iterator propertyIterator = cm.getPropertyIterator();
    while (propertyIterator.hasNext()) {
      Property element = (Property) propertyIterator.next();
      System.out.println(element);
      Map ma = element.getMetaAttributes();
      assertNotNull(ma);
      assertNotNull(element.getMetaAttribute("global"));
      MetaAttribute metaAttribute2 = element.getMetaAttribute("implements");
      assertNotNull(metaAttribute2);
      assertNull(element.getMetaAttribute("globalnoinherit"));
           
    }
   
    Property element = cm.getProperty("component");
    Map ma = element.getMetaAttributes();
    assertNotNull(ma);
    assertNotNull(element.getMetaAttribute("global"));
    assertNotNull(element.getMetaAttribute("componentonly"));
    assertNotNull(element.getMetaAttribute("allcomponent"));
    assertNull(element.getMetaAttribute("globalnoinherit"));             
   
    MetaAttribute compimplements = element.getMetaAttribute("implements");
    assertNotNull(compimplements);
    assertEquals(compimplements.getValue(), "AnotherInterface");
   
    Property xp = ((Component)element.getValue()).getProperty( "x" );
    MetaAttribute propximplements = xp.getMetaAttribute( "implements" );
    assertNotNull(propximplements);
    assertEquals(propximplements.getValue(), "AnotherInterface");
   
   
  }
View Full Code Here

  }

  // HBX-718
  public void testNonMutatedInheritance() {
    PersistentClass cm = cfg.getClassMapping("org.hibernate.test.legacy.Wicked");
    MetaAttribute metaAttribute = cm.getMetaAttribute( "globalmutated" );
   
    assertNotNull(metaAttribute);
    /*assertEquals( metaAttribute.getValues().size(), 2 );   
    assertEquals( "top level", metaAttribute.getValues().get(0) );*/
    assertEquals( "wicked level", metaAttribute.getValue() );
   
    Property property = cm.getProperty( "component" );
    MetaAttribute propertyAttribute = property.getMetaAttribute( "globalmutated" );
   
    assertNotNull(propertyAttribute);
    /*assertEquals( propertyAttribute.getValues().size(), 3 );
    assertEquals( "top level", propertyAttribute.getValues().get(0) );
    assertEquals( "wicked level", propertyAttribute.getValues().get(1) );*/
    assertEquals( "monetaryamount level", propertyAttribute.getValue() );
   
    org.hibernate.mapping.Component component = (Component)property.getValue();
    property = component.getProperty( "x" );
    propertyAttribute = property.getMetaAttribute( "globalmutated" );
   
    assertNotNull(propertyAttribute);
    /*assertEquals( propertyAttribute.getValues().size(), 4 );
    assertEquals( "top level", propertyAttribute.getValues().get(0) );
    assertEquals( "wicked level", propertyAttribute.getValues().get(1) );
    assertEquals( "monetaryamount level", propertyAttribute.getValues().get(2) );*/
    assertEquals( "monetaryamount x level", propertyAttribute.getValue() );
   
    property = cm.getProperty( "sortedEmployee" );
    propertyAttribute = property.getMetaAttribute( "globalmutated" );
   
    assertNotNull(propertyAttribute);
    /*assertEquals( propertyAttribute.getValues().size(), 3 );
    assertEquals( "top level", propertyAttribute.getValues().get(0) );
    assertEquals( "wicked level", propertyAttribute.getValues().get(1) );*/
    assertEquals( "sortedemployee level", propertyAttribute.getValue() );
   
    property = cm.getProperty( "anotherSet" );
    propertyAttribute = property.getMetaAttribute( "globalmutated" );
   
    assertNotNull(propertyAttribute);
    /*assertEquals( propertyAttribute.getValues().size(), 2 );
    assertEquals( "top level", propertyAttribute.getValues().get(0) );*/
    assertEquals( "wicked level", propertyAttribute.getValue() );
       
    Bag bag = (Bag) property.getValue();
    component = (Component)bag.getElement();
   
    assertEquals(4,component.getMetaAttributes().size());
   
    metaAttribute = component.getMetaAttribute( "globalmutated" );
    /*assertEquals( metaAttribute.getValues().size(), 3 );
    assertEquals( "top level", metaAttribute.getValues().get(0) );
    assertEquals( "wicked level", metaAttribute.getValues().get(1) );*/
    assertEquals( "monetaryamount anotherSet composite level", metaAttribute.getValue() );   
   
    property = component.getProperty( "emp" );
    propertyAttribute = property.getMetaAttribute( "globalmutated" );
   
    assertNotNull(propertyAttribute);
    /*assertEquals( propertyAttribute.getValues().size(), 4 );
    assertEquals( "top level", propertyAttribute.getValues().get(0) );
    assertEquals( "wicked level", propertyAttribute.getValues().get(1) );
    assertEquals( "monetaryamount anotherSet composite level", propertyAttribute.getValues().get(2) );*/
    assertEquals( "monetaryamount anotherSet composite property emp level", propertyAttribute.getValue() );
   
   
    property = component.getProperty( "empinone" );
    propertyAttribute = property.getMetaAttribute( "globalmutated" );
   
    assertNotNull(propertyAttribute);
    /*assertEquals( propertyAttribute.getValues().size(), 4 );
    assertEquals( "top level", propertyAttribute.getValues().get(0) );
    assertEquals( "wicked level", propertyAttribute.getValues().get(1) );
    assertEquals( "monetaryamount anotherSet composite level", propertyAttribute.getValues().get(2) );*/
    assertEquals( "monetaryamount anotherSet composite property empinone level", propertyAttribute.getValue() );
   
   
  }
View Full Code Here

      if ( onlyInheritable & !inheritable ) {
        continue;
      }
      String name = metaNode.attributeValue( "attribute" );

      MetaAttribute meta = (MetaAttribute) map.get( name );
      MetaAttribute inheritedAttribute = (MetaAttribute) inheritedMeta.get( name );
      if ( meta == null  ) {
        meta = new MetaAttribute( name );
        map.put( name, meta );
      } else if (meta == inheritedAttribute) { // overriding inherited meta attribute. HBX-621 & HBX-793
        meta = new MetaAttribute( name );
        map.put( name, meta );
      }
      meta.addValue( metaNode.getText() );
    }
    return map;
View Full Code Here

TOP

Related Classes of org.hibernate.mapping.MetaAttribute

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.