use of jakarta.persistence.OrderColumn in project hibernate-orm by hibernate.
the class CollectionBinder method determineCollectionClassification.
private static CollectionClassification determineCollectionClassification(Class<?> semanticJavaType, XProperty property, MetadataBuildingContext buildingContext) {
if (semanticJavaType.isArray()) {
return CollectionClassification.ARRAY;
} else if (property.isAnnotationPresent(CollectionId.class) || property.isAnnotationPresent(CollectionIdJdbcType.class) || property.isAnnotationPresent(CollectionIdJdbcTypeCode.class) || property.isAnnotationPresent(CollectionIdJavaType.class)) {
// explicitly an ID_BAG
return CollectionClassification.ID_BAG;
} else if (java.util.List.class.isAssignableFrom(semanticJavaType)) {
if (property.isAnnotationPresent(OrderColumn.class) || property.isAnnotationPresent(org.hibernate.annotations.IndexColumn.class) || property.isAnnotationPresent(ListIndexBase.class) || property.isAnnotationPresent(ListIndexJdbcType.class) || property.isAnnotationPresent(ListIndexJdbcTypeCode.class) || property.isAnnotationPresent(ListIndexJavaType.class)) {
// it is implicitly a LIST because of presence of explicit List index config
return CollectionClassification.LIST;
}
if (property.isAnnotationPresent(jakarta.persistence.OrderBy.class) || property.isAnnotationPresent(OrderBy.class)) {
return CollectionClassification.BAG;
}
ManyToMany manyToMany = property.getAnnotation(ManyToMany.class);
if (manyToMany != null && !StringHelper.isEmpty(manyToMany.mappedBy())) {
// We don't support @OrderColumn on the non-owning side of a many-to-many association.
return CollectionClassification.BAG;
}
OneToMany oneToMany = property.getAnnotation(OneToMany.class);
if (oneToMany != null && !StringHelper.isEmpty(oneToMany.mappedBy())) {
// Unowned to-many mappings are always considered BAG by default
return CollectionClassification.BAG;
}
// otherwise, return the implicit classification for List attributes
return buildingContext.getBuildingOptions().getMappingDefaults().getImplicitListClassification();
} else if (java.util.SortedSet.class.isAssignableFrom(semanticJavaType)) {
return CollectionClassification.SORTED_SET;
} else if (java.util.Set.class.isAssignableFrom(semanticJavaType)) {
return CollectionClassification.SET;
} else if (java.util.SortedMap.class.isAssignableFrom(semanticJavaType)) {
return CollectionClassification.SORTED_MAP;
} else if (java.util.Map.class.isAssignableFrom(semanticJavaType)) {
return CollectionClassification.MAP;
} else if (java.util.Collection.class.isAssignableFrom(semanticJavaType)) {
if (property.isAnnotationPresent(CollectionId.class)) {
return CollectionClassification.ID_BAG;
} else {
return CollectionClassification.BAG;
}
} else {
return null;
}
}
use of jakarta.persistence.OrderColumn in project hibernate-orm by hibernate.
the class Ejb3XmlElementCollectionTest method testOrderColumnAllAttributes.
@Test
public void testOrderColumnAllAttributes() throws Exception {
reader = getReader(Entity2.class, "field1", "element-collection.orm4.xml");
assertAnnotationPresent(ElementCollection.class);
assertAnnotationNotPresent(OrderBy.class);
assertAnnotationPresent(OrderColumn.class);
OrderColumn orderColumnAnno = reader.getAnnotation(OrderColumn.class);
assertEquals("int", orderColumnAnno.columnDefinition());
assertEquals("col1", orderColumnAnno.name());
assertFalse(orderColumnAnno.insertable());
assertFalse(orderColumnAnno.nullable());
assertFalse(orderColumnAnno.updatable());
}
use of jakarta.persistence.OrderColumn in project hibernate-orm by hibernate.
the class Ejb3XmlOneToManyTest method testOrderColumnNoAttributes.
@Test
public void testOrderColumnNoAttributes() throws Exception {
reader = getReader(Entity2.class, "field1", "one-to-many.orm3.xml");
assertAnnotationPresent(OneToMany.class);
assertAnnotationNotPresent(OrderBy.class);
assertAnnotationPresent(OrderColumn.class);
OrderColumn orderColumnAnno = reader.getAnnotation(OrderColumn.class);
assertEquals("", orderColumnAnno.columnDefinition());
assertEquals("", orderColumnAnno.name());
assertTrue(orderColumnAnno.insertable());
assertTrue(orderColumnAnno.nullable());
assertTrue(orderColumnAnno.updatable());
}
use of jakarta.persistence.OrderColumn in project hibernate-orm by hibernate.
the class Ejb3XmlOneToManyTest method testOrderColumnAllAttributes.
@Test
public void testOrderColumnAllAttributes() throws Exception {
reader = getReader(Entity2.class, "field1", "one-to-many.orm4.xml");
assertAnnotationPresent(OneToMany.class);
assertAnnotationNotPresent(OrderBy.class);
assertAnnotationPresent(OrderColumn.class);
OrderColumn orderColumnAnno = reader.getAnnotation(OrderColumn.class);
assertEquals("int", orderColumnAnno.columnDefinition());
assertEquals("col1", orderColumnAnno.name());
assertFalse(orderColumnAnno.insertable());
assertFalse(orderColumnAnno.nullable());
assertFalse(orderColumnAnno.updatable());
}
Aggregations