use of org.hibernate.mapping.ManyToOne in project hibernate-orm by hibernate.
the class ValueVisitorTest method testProperCallbacks.
@Test
public void testProperCallbacks() {
final MetadataImplementor metadata = (MetadataImplementor) new MetadataSources(serviceRegistry).buildMetadata();
final Table tbl = new Table();
final RootClass rootClass = new RootClass(metadataBuildingContext);
ValueVisitor vv = new ValueVisitorValidator();
MetadataBuildingContextTestingImpl metadataBuildingContext = new MetadataBuildingContextTestingImpl();
new Any(metadataBuildingContext, tbl).accept(vv);
new Array(metadataBuildingContext, rootClass).accept(vv);
new Bag(metadataBuildingContext, rootClass).accept(vv);
new Component(metadataBuildingContext, rootClass).accept(vv);
new DependantValue(metadataBuildingContext, tbl, null).accept(vv);
new IdentifierBag(metadataBuildingContext, rootClass).accept(vv);
new List(metadataBuildingContext, rootClass).accept(vv);
new ManyToOne(metadataBuildingContext, tbl).accept(vv);
new Map(metadataBuildingContext, rootClass).accept(vv);
new OneToMany(metadataBuildingContext, rootClass).accept(vv);
new OneToOne(metadataBuildingContext, tbl, rootClass).accept(vv);
new PrimitiveArray(metadataBuildingContext, rootClass).accept(vv);
new Set(metadataBuildingContext, rootClass).accept(vv);
new SimpleValue(metadataBuildingContext).accept(vv);
}
use of org.hibernate.mapping.ManyToOne in project hibernate-orm by hibernate.
the class CollectionMetadataGenerator method getReferenceCollectionClass.
private PersistentClass getReferenceCollectionClass(Collection collectionValue) {
PersistentClass referencedClass = null;
if (collectionValue.getElement() instanceof OneToMany) {
final OneToMany oneToManyValue = (OneToMany) collectionValue.getElement();
referencedClass = oneToManyValue.getAssociatedClass();
} else if (collectionValue.getElement() instanceof ManyToOne) {
// Case for bi-directional relation with @JoinTable on the owning @ManyToOne side.
final ManyToOne manyToOneValue = (ManyToOne) collectionValue.getElement();
referencedClass = manyToOneValue.getMetadata().getEntityBinding(manyToOneValue.getReferencedEntityName());
}
return referencedClass;
}
use of org.hibernate.mapping.ManyToOne in project jbosstools-hibernate by jbosstools.
the class ValueFacadeTest method testSetReferencedEntityName.
@Test
public void testSetReferencedEntityName() {
ManyToOne valueTarget = new ManyToOne(null);
valueFacade = FACADE_FACTORY.createValue(valueTarget);
Assert.assertNull(valueTarget.getReferencedEntityName());
valueFacade.setReferencedEntityName("Foo");
Assert.assertEquals("Foo", valueTarget.getReferencedEntityName());
}
use of org.hibernate.mapping.ManyToOne in project jbosstools-hibernate by jbosstools.
the class ValueFacadeTest method testIsManyToOne.
@Test
public void testIsManyToOne() {
valueTarget = new SimpleValue();
valueFacade = FACADE_FACTORY.createValue(valueTarget);
Assert.assertFalse(valueFacade.isManyToOne());
ManyToOne manyToOne = new ManyToOne(null);
valueFacade = FACADE_FACTORY.createValue(manyToOne);
Assert.assertTrue(valueFacade.isManyToOne());
}
use of org.hibernate.mapping.ManyToOne in project jbosstools-hibernate by jbosstools.
the class ValueFacadeTest method testGetReferencedEntityName.
@Test
public void testGetReferencedEntityName() {
ManyToOne valueTarget = new ManyToOne(null);
valueFacade = FACADE_FACTORY.createValue(valueTarget);
Assert.assertNull(valueFacade.getReferencedEntityName());
valueTarget.setReferencedEntityName("Foo");
Assert.assertEquals("Foo", valueFacade.getReferencedEntityName());
}
Aggregations