use of jakarta.persistence.ManyToOne in project hibernate-orm by hibernate.
the class Ejb3XmlManyToOneTest method testNoJoins.
@Test
public void testNoJoins() throws Exception {
reader = getReader(Entity1.class, "field1", "many-to-one.orm1.xml");
assertAnnotationPresent(ManyToOne.class);
assertAnnotationNotPresent(JoinColumn.class);
assertAnnotationNotPresent(JoinColumns.class);
assertAnnotationNotPresent(JoinTable.class);
assertAnnotationNotPresent(Id.class);
assertAnnotationNotPresent(MapsId.class);
assertAnnotationNotPresent(Access.class);
ManyToOne relAnno = reader.getAnnotation(ManyToOne.class);
assertEquals(0, relAnno.cascade().length);
assertEquals(FetchType.EAGER, relAnno.fetch());
assertTrue(relAnno.optional());
assertEquals(void.class, relAnno.targetEntity());
}
use of jakarta.persistence.ManyToOne in project eclipselink by eclipse-ee4j.
the class AbstractFieldMapping method getMemberType.
@Override
protected Class<?> getMemberType() {
Field field = getMember();
// One to One
OneToOne oneToOne = field.getAnnotation(OneToOne.class);
if (oneToOne != null) {
Class<?> targetEntity = oneToOne.targetEntity();
if (targetEntity != void.class) {
return targetEntity;
}
}
// Many to One
ManyToOne manyToOne = field.getAnnotation(ManyToOne.class);
if (manyToOne != null) {
Class<?> targetEntity = manyToOne.targetEntity();
if (targetEntity != void.class) {
return targetEntity;
}
}
// Many to Many
ManyToMany manyToMany = field.getAnnotation(ManyToMany.class);
if (manyToMany != null) {
Class<?> targetEntity = manyToMany.targetEntity();
if (targetEntity != void.class) {
return targetEntity;
}
}
// One to Many
OneToMany oneToMany = field.getAnnotation(OneToMany.class);
if (oneToMany != null) {
Class<?> targetEntity = oneToMany.targetEntity();
if (targetEntity != void.class) {
return targetEntity;
}
}
return field.getType();
}
use of jakarta.persistence.ManyToOne in project eclipselink by eclipse-ee4j.
the class AbstractMethodMapping method getMemberType.
@Override
protected Class<?> getMemberType() {
Method method = getMember();
Class<?> type = method.getReturnType();
if (type == Void.class) {
return method.getParameterTypes()[0];
} else {
// One to One
OneToOne oneToOne = method.getAnnotation(OneToOne.class);
if (oneToOne != null) {
Class<?> targetEntity = oneToOne.targetEntity();
if (targetEntity != void.class) {
return targetEntity;
}
}
// Many to One
ManyToOne manyToOne = method.getAnnotation(ManyToOne.class);
if (manyToOne != null) {
Class<?> targetEntity = manyToOne.targetEntity();
if (targetEntity != void.class) {
return targetEntity;
}
}
// Many to Many
ManyToMany manyToMany = method.getAnnotation(ManyToMany.class);
if (manyToMany != null) {
Class<?> targetEntity = manyToMany.targetEntity();
if (targetEntity != void.class) {
return targetEntity;
}
}
// One to Many
OneToMany oneToMany = method.getAnnotation(OneToMany.class);
if (oneToMany != null) {
Class<?> targetEntity = oneToMany.targetEntity();
if (targetEntity != void.class) {
return targetEntity;
}
}
return type;
}
}
Aggregations