use of jakarta.persistence.AttributeConverter in project jOOQ by jOOQ.
the class AttributeConverterExtractor method extract.
@SuppressWarnings("unchecked")
final Map<Name, AttributeConverter<?, ?>> extract() {
Map<Name, AttributeConverter<?, ?>> result = new LinkedHashMap<>();
initEntityManagerFactory();
for (PersistentClass persistentClass : meta.getEntityBindings()) {
Table table = persistentClass.getTable();
Iterator<Property> propertyIterator = persistentClass.getPropertyIterator();
propertyLoop: while (propertyIterator.hasNext()) {
Property property = propertyIterator.next();
Type type = property.getValue().getType();
if (type instanceof AttributeConverterTypeAdapter) {
AttributeConverter<?, ?> converter = ((AttributeConverterTypeAdapter<?>) type).getAttributeConverter().getConverterBean().getBeanInstance();
Iterator<Column> columnIterator = property.getColumnIterator();
if (columnIterator.hasNext()) {
Column column = columnIterator.next();
if (columnIterator.hasNext()) {
log.info("AttributeConverter", "Cannot apply AttributeConverter of property " + property + " on several columns.");
continue propertyLoop;
}
result.put(name(table.getCatalog(), table.getSchema(), table.getName(), column.getName()), converter);
}
}
}
}
return result;
}
Aggregations