use of org.hibernate.mapping.ManyToOne in project hibernate-orm by hibernate.
the class CollectionMetadataGenerator method addCollection.
void addCollection() {
final Type type = propertyValue.getType();
final Value value = propertyValue.getElement();
final boolean oneToManyAttachedType = type instanceof BagType || type instanceof SetType || type instanceof MapType || type instanceof ListType;
final boolean inverseOneToMany = (value instanceof OneToMany) && (propertyValue.isInverse());
final boolean owningManyToOneWithJoinTableBidirectional = (value instanceof ManyToOne) && (propertyAuditingData.getRelationMappedBy() != null);
final boolean fakeOneToManyBidirectional = (value instanceof OneToMany) && (propertyAuditingData.getAuditMappedBy() != null);
if (oneToManyAttachedType && (inverseOneToMany || fakeOneToManyBidirectional || owningManyToOneWithJoinTableBidirectional)) {
// A one-to-many relation mapped using @ManyToOne and @OneToMany(mappedBy="...")
addOneToManyAttached(fakeOneToManyBidirectional);
} else {
// All other kinds of relations require a middle (join) table.
addWithMiddleTable();
}
}
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, null);
valueFacade = FACADE_FACTORY.createValue(valueTarget);
Assert.assertNull(valueFacade.getReferencedEntityName());
valueTarget.setReferencedEntityName("Foo");
Assert.assertEquals("Foo", valueFacade.getReferencedEntityName());
}
use of org.hibernate.mapping.ManyToOne in project jbosstools-hibernate by jbosstools.
the class ValueFacadeTest method testSetFetchModeJoin.
@Test
public void testSetFetchModeJoin() {
SimpleValue simpleValueTarget = new SimpleValue(null);
Assert.assertNotEquals(FetchMode.JOIN, simpleValueTarget.getFetchMode());
valueFacade = FACADE_FACTORY.createValue(simpleValueTarget);
valueFacade.setFetchModeJoin();
Assert.assertNotEquals(FetchMode.JOIN, simpleValueTarget.getFetchMode());
Collection collectionTarget = new Bag(null, null);
Assert.assertNotEquals(FetchMode.JOIN, collectionTarget.getFetchMode());
valueFacade = FACADE_FACTORY.createValue(collectionTarget);
valueFacade.setFetchModeJoin();
Assert.assertEquals(FetchMode.JOIN, collectionTarget.getFetchMode());
ManyToOne manyToOneTarget = new ManyToOne(null, null);
Assert.assertNotEquals(FetchMode.JOIN, manyToOneTarget.getFetchMode());
valueFacade = FACADE_FACTORY.createValue(manyToOneTarget);
valueFacade.setFetchModeJoin();
Assert.assertEquals(FetchMode.JOIN, manyToOneTarget.getFetchMode());
}
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, 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(null);
valueFacade = FACADE_FACTORY.createValue(valueTarget);
Assert.assertFalse(valueFacade.isManyToOne());
ManyToOne manyToOne = new ManyToOne(null, null);
valueFacade = FACADE_FACTORY.createValue(manyToOne);
Assert.assertTrue(valueFacade.isManyToOne());
}
Aggregations