Package org.hibernate.mapping

Examples of org.hibernate.mapping.OneToOne


    }

    @SuppressWarnings({"unchecked"})
    void addOneToOneNotOwning(PropertyAuditingData propertyAuditingData, Value value,
                              CompositeMapperBuilder mapper, String entityName) {
        OneToOne propertyValue = (OneToOne) value;

        String owningReferencePropertyName = propertyValue.getReferencedPropertyName(); // mappedBy

        EntityConfiguration configuration = mainGenerator.getEntitiesConfigurations().get(entityName);
        if (configuration == null) {
            throw new MappingException("An audited relation to a non-audited entity " + entityName + "!");
        }

        IdMappingData ownedIdMapping = configuration.getIdMappingData();

        if (ownedIdMapping == null) {
            throw new MappingException("An audited relation to a non-audited entity " + entityName + "!");
        }

        String lastPropertyPrefix = MappingTools.createToOneRelationPrefix(owningReferencePropertyName);
        String referencedEntityName = propertyValue.getReferencedEntityName();

        // Generating the id mapper for the relation
        IdMapper ownedIdMapper = ownedIdMapping.getIdMapper().prefixMappedProperties(lastPropertyPrefix);

        // Storing information about this relation
View Full Code Here


    new IdentifierBag( mappings, rootClass ).accept(vv);
    new List( mappings, rootClass ).accept(vv);
    new ManyToOne( mappings, tbl ).accept(vv);
    new Map( mappings, rootClass ).accept(vv);
    new OneToMany( mappings, rootClass ).accept(vv);
    new OneToOne( mappings, tbl, rootClass ).accept(vv);
    new PrimitiveArray( mappings, rootClass ).accept(vv);
    new Set( mappings, rootClass ).accept(vv);
    new SimpleValue( mappings ).accept(vv);
 
   
View Full Code Here

          relativePath = subpath.substring( component.getOwner().getEntityName().length() + 1 );
        }
        bindManyToOne( subnode, (ManyToOne) value, relativePath, isNullable, mappings );
      }
      else if ( "one-to-one".equals( name ) ) {
        value = new OneToOne( component.getTable(), component.getOwner() );
        String relativePath;
        if (isEmbedded) {
          relativePath = propertyName;
        }
        else {
View Full Code Here

      else if ( "any".equals( name ) ) {
        value = new Any( table );
        bindAny( subnode, (Any) value, nullable, mappings );
      }
      else if ( "one-to-one".equals( name ) ) {
        value = new OneToOne( table, persistentClass );
        bindOneToOne( subnode, (OneToOne) value, propertyName, true, mappings );
      }
      else if ( "property".equals( name ) ) {
        value = new SimpleValue( table );
        bindSimpleValue( subnode, (SimpleValue) value, nullable, propertyName, mappings );
View Full Code Here

    Property addressProperty = person.getProperty("addressPerson");
    assertNotNull(addressProperty);
       
    assertTrue(addressProperty.getValue() instanceof OneToOne);
   
    OneToOne oto = (OneToOne) addressProperty.getValue();
   
    assertEquals(oto.getColumnSpan(),1);
    assertEquals("Person", oto.getEntityName());
    assertEquals("AddressPerson", oto.getReferencedEntityName());
   
   
    assertEquals(2, person.getPropertyClosureSpan());   
    assertEquals("personId", person.getIdentifierProperty().getName());
    assertFalse(oto.isConstrained());
   
    PersistentClass addressPerson = localCfg.getClassMapping("AddressPerson");
   
   
    Property personProperty = addressPerson.getProperty("person");
    assertNotNull(personProperty);
   
    assertTrue(personProperty.getValue() instanceof OneToOne);
   
    oto = (OneToOne) personProperty.getValue();
   
    assertTrue(oto.isConstrained());   
    assertEquals(oto.getColumnSpan(),1);
    assertEquals("AddressPerson", oto.getEntityName());
    assertEquals("Person", oto.getReferencedEntityName());
   
    assertEquals(2, addressPerson.getPropertyClosureSpan());
    assertEquals("addressId", addressPerson.getIdentifierProperty().getName());
       
  }
View Full Code Here

    Property addressProperty = person.getProperty("addressMultiPerson");
    assertNotNull(addressProperty);
       
    assertTrue(addressProperty.getValue() instanceof OneToOne);
   
    OneToOne oto = (OneToOne) addressProperty.getValue();
   
    assertEquals(oto.getColumnSpan(),2);
    assertEquals("MultiPerson", oto.getEntityName());
    assertEquals("AddressMultiPerson", oto.getReferencedEntityName());
    assertFalse(oto.isConstrained());
   
    assertEquals(2, person.getPropertyClosureSpan());   
    assertEquals("compositeid gives generic id name", "id", person.getIdentifierProperty().getName());
   
    PersistentClass addressPerson = localCfg.getClassMapping("AddressMultiPerson");
   
   
    Property personProperty = addressPerson.getProperty("multiPerson");
    assertNotNull(personProperty);
   
    assertTrue(personProperty.getValue() instanceof OneToOne);
   
    oto = (OneToOne) personProperty.getValue();
   
    assertEquals(oto.getColumnSpan(),2);
    assertEquals("AddressMultiPerson", oto.getEntityName());
    assertEquals("MultiPerson", oto.getReferencedEntityName());
   
    assertEquals(2, addressPerson.getPropertyClosureSpan());
    assertEquals("compositeid gives generic id name","id", addressPerson.getIdentifierProperty().getName());
    assertTrue(oto.isConstrained());
  }
View Full Code Here

          relativePath = subpath.substring( component.getOwner().getEntityName().length() + 1 );
        }
        bindManyToOne( subnode, (ManyToOne) value, relativePath, isNullable, mappings );
      }
      else if ( "one-to-one".equals( name ) ) {
        value = new OneToOne( mappings, component.getTable(), component.getOwner() );
        String relativePath;
        if (isEmbedded) {
          relativePath = propertyName;
        }
        else {
View Full Code Here

      else if ( "any".equals( name ) ) {
        value = new Any( mappings, table );
        bindAny( subnode, (Any) value, nullable, mappings );
      }
      else if ( "one-to-one".equals( name ) ) {
        value = new OneToOne( mappings, table, persistentClass );
        bindOneToOne( subnode, (OneToOne) value, propertyName, true, mappings );
      }
      else if ( "property".equals( name ) ) {
        value = new SimpleValue( mappings, table );
        bindSimpleValue( subnode, (SimpleValue) value, nullable, propertyName, mappings );
View Full Code Here

          relativePath = subpath.substring( component.getOwner().getEntityName().length() + 1 );
        }
        bindManyToOne( subnode, (ManyToOne) value, relativePath, isNullable, mappings );
      }
      else if ( "one-to-one".equals( name ) ) {
        value = new OneToOne( component.getTable(), component.getOwner() );
        String relativePath;
        if (isEmbedded) {
          relativePath = propertyName;
        }
        else {
View Full Code Here

      else if ( "any".equals( name ) ) {
        value = new Any( table );
        bindAny( subnode, (Any) value, nullable, mappings );
      }
      else if ( "one-to-one".equals( name ) ) {
        value = new OneToOne( table, persistentClass );
        bindOneToOne( subnode, (OneToOne) value, propertyName, true, mappings );
      }
      else if ( "property".equals( name ) ) {
        value = new SimpleValue( table );
        bindSimpleValue( subnode, (SimpleValue) value, nullable, propertyName, mappings );
View Full Code Here

TOP

Related Classes of org.hibernate.mapping.OneToOne

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.