use of org.hibernate.mapping.OneToOne in project hibernate-orm by hibernate.
the class AuditMetadataGenerator method addValueInSecondPass.
private void addValueInSecondPass(Element parent, Value value, CompositeMapperBuilder currentMapper, String entityName, EntityXmlMappingData xmlMappingData, PropertyAuditingData propertyAuditingData, boolean insertable, boolean processModifiedFlag) {
final Type type = value.getType();
if (type instanceof ComponentType) {
componentMetadataGenerator.addComponent(parent, propertyAuditingData, value, currentMapper, entityName, xmlMappingData, false);
// mod flag field has been already generated in first pass
return;
} else if (type instanceof ManyToOneType) {
toOneRelationMetadataGenerator.addToOne(parent, propertyAuditingData, value, currentMapper, entityName, insertable);
} else if (type instanceof OneToOneType) {
final OneToOne oneToOne = (OneToOne) value;
if (oneToOne.getReferencedPropertyName() != null) {
toOneRelationMetadataGenerator.addOneToOneNotOwning(propertyAuditingData, value, currentMapper, entityName);
} else {
// @OneToOne relation marked with @PrimaryKeyJoinColumn
toOneRelationMetadataGenerator.addOneToOnePrimaryKeyJoinColumn(propertyAuditingData, value, currentMapper, entityName, insertable);
}
} else if (type instanceof CollectionType) {
final CollectionMetadataGenerator collectionMetadataGenerator = new CollectionMetadataGenerator(this, (Collection) value, currentMapper, entityName, xmlMappingData, propertyAuditingData);
collectionMetadataGenerator.addCollection();
} else {
return;
}
addModifiedFlagIfNeeded(parent, propertyAuditingData, processModifiedFlag);
}
use of org.hibernate.mapping.OneToOne in project jbosstools-hibernate by jbosstools.
the class ValueFacadeTest method testIsOneToOne.
@Test
public void testIsOneToOne() {
valueTarget = new SimpleValue(null);
valueFacade = FACADE_FACTORY.createValue(valueTarget);
Assert.assertFalse(valueFacade.isOneToOne());
OneToOne oneToOne = new OneToOne(null, null, new RootClass());
valueFacade = FACADE_FACTORY.createValue(oneToOne);
Assert.assertTrue(valueFacade.isOneToOne());
}
use of org.hibernate.mapping.OneToOne in project jbosstools-hibernate by jbosstools.
the class ValueFacadeTest method testIsToOne.
@Test
public void testIsToOne() {
valueTarget = new SimpleValue();
valueFacade = FACADE_FACTORY.createValue(valueTarget);
Assert.assertFalse(valueFacade.isToOne());
ToOne toOne = new OneToOne(null, new RootClass());
valueFacade = FACADE_FACTORY.createValue(toOne);
Assert.assertTrue(valueFacade.isToOne());
}
use of org.hibernate.mapping.OneToOne in project jbosstools-hibernate by jbosstools.
the class ValueFacadeTest method testIsToOne.
@Test
public void testIsToOne() {
valueTarget = new SimpleValue(null);
valueFacade = FACADE_FACTORY.createValue(valueTarget);
Assert.assertFalse(valueFacade.isToOne());
ToOne toOne = new OneToOne(null, null, new RootClass());
valueFacade = FACADE_FACTORY.createValue(toOne);
Assert.assertTrue(valueFacade.isToOne());
}
use of org.hibernate.mapping.OneToOne in project jbosstools-hibernate by jbosstools.
the class ValueFacadeTest method testGetEntityName.
@Test
public void testGetEntityName() {
SimpleValue simpleValueTarget = new SimpleValue(null);
valueFacade = FACADE_FACTORY.createValue(simpleValueTarget);
Assert.assertNull(valueFacade.getEntityName());
RootClass pc = new RootClass();
pc.setEntityName("foobar");
OneToOne oneToOneTarget = new OneToOne(null, null, pc);
valueFacade = FACADE_FACTORY.createValue(oneToOneTarget);
Assert.assertEquals("foobar", valueFacade.getEntityName());
}
Aggregations