use of org.hibernate.type.ManyToOneType 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.type.ManyToOneType in project jbosstools-hibernate by jbosstools.
the class MultiplicityType method nullSafeSet.
public void nullSafeSet(PreparedStatement st, Object value, int index, SessionImplementor session) throws HibernateException, SQLException {
Multiplicity o = (Multiplicity) value;
GlarchProxy g;
Integer c;
if (o == null) {
g = null;
c = new Integer(0);
} else {
g = o.glarch;
c = new Integer(o.count);
}
IntegerType.INSTANCE.nullSafeSet(st, c, index, session);
new ManyToOneType(NoScope.INSTANCE, Glarch.class.getName()).nullSafeSet(st, g, index + 1, session);
}
use of org.hibernate.type.ManyToOneType in project jbosstools-hibernate by jbosstools.
the class TypeFacadeTest method testIsEntityType.
@Test
public void testIsEntityType() {
IType typeFacade = null;
ClassType classType = new ClassType();
typeFacade = FACADE_FACTORY.createType(classType);
Assert.assertFalse(typeFacade.isEntityType());
EntityType entityType = new ManyToOneType(null);
typeFacade = FACADE_FACTORY.createType(entityType);
Assert.assertTrue(entityType.isEntityType());
}
use of org.hibernate.type.ManyToOneType in project jbosstools-hibernate by jbosstools.
the class TypeFacadeTest method testIsOneToOne.
@Test
public void testIsOneToOne() {
IType typeFacade = null;
ClassType classType = new ClassType();
typeFacade = FACADE_FACTORY.createType(classType);
Assert.assertFalse(typeFacade.isOneToOne());
EntityType entityType = new ManyToOneType(null);
typeFacade = FACADE_FACTORY.createType(entityType);
Assert.assertFalse(entityType.isOneToOne());
OneToOneType oneToOneType = new OneToOneType(null, null, null, false, false, false, null, null);
typeFacade = FACADE_FACTORY.createType(oneToOneType);
Assert.assertTrue(oneToOneType.isOneToOne());
}
use of org.hibernate.type.ManyToOneType in project jbosstools-hibernate by jbosstools.
the class TypeFacadeTest method testGetAssociatedEntityName.
@Test
public void testGetAssociatedEntityName() {
IType typeFacade = null;
ClassType classType = new ClassType();
typeFacade = FACADE_FACTORY.createType(classType);
Assert.assertNull(typeFacade.getAssociatedEntityName());
EntityType entityType = new ManyToOneType("foo");
typeFacade = FACADE_FACTORY.createType(entityType);
Assert.assertEquals("foo", typeFacade.getAssociatedEntityName());
}
Aggregations