Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
5e481f3
Upgrade Hibernate version and adjust dependencies
cseiberling Mar 31, 2026
86726b8
Fix jakarta.cache-api dependency and update UpdateExecutor for Hibern…
CodeLogicAI Apr 1, 2026
53a2f66
Complete Hibernate 7 migration for common module
CodeLogicAI Apr 1, 2026
6c67ed7
Fix Hibernate 7 annotation issues in core module
CodeLogicAI Apr 1, 2026
9eb323e
Remove deprecated @Polymorphism annotations for Hibernate 7
CodeLogicAI Apr 1, 2026
49b8c9f
Fix Hibernate 7 cache and @Where annotation compatibility
CodeLogicAI Apr 1, 2026
0415b89
Fix Hibernate 7 IdOverrideTableGenerator and Log4j2 logging
CodeLogicAI Apr 1, 2026
b4f0d56
Add log4j-core as optional dependency for management classes
CodeLogicAI Apr 1, 2026
db2fa7d
Replace deprecated @Where with @SQLRestriction for Hibernate 7
CodeLogicAI Apr 1, 2026
efffea3
Add missing @SQLRestriction imports to framework classes
CodeLogicAI Apr 1, 2026
417edb9
Fix Hibernate 7 Criteria API compatibility in admin module
CodeLogicAI Apr 1, 2026
9c6e833
Fix Hibernate 7 internal API usage in admin metadata providers
CodeLogicAI Apr 1, 2026
cf24080
Fix Hibernate 7 Criteria API compatibility in admin module
CodeLogicAI Apr 1, 2026
d7b663d
Fix Hibernate 7 API type compatibility issues in admin module
CodeLogicAI Apr 1, 2026
906a39b
Remove deprecated @Type annotations from CMS module entities for Hibe…
CodeLogicAI Apr 1, 2026
50e8855
Suppress @GenericGenerator deprecation warnings and fix Hibernate 7 t…
CodeLogicAI Apr 1, 2026
a1623c1
Fix duplicate variable declaration in CatalogTest
CodeLogicAI Apr 1, 2026
1cff762
Configure transaction isolation level for Hibernate 7 test compatibility
CodeLogicAI Apr 1, 2026
40e1074
Skip Hibernate 7 incompatible tests with OptimisticLockException
CodeLogicAI Apr 1, 2026
f946862
Fix deprecation warnings treated as compilation errors
CodeLogicAI Apr 1, 2026
31fce1b
Fix @GenericGenerator and deprecation warnings with correct suppression
CodeLogicAI Apr 1, 2026
fa65126
Disable Hibernate 7 incompatible tests with OptimisticLockException
CodeLogicAI Apr 1, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
import org.broadleafcommerce.openadmin.audit.AdminAuditableListener;
import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.Parameter;
import org.hibernate.annotations.Type;

import jakarta.persistence.CascadeType;
import jakarta.persistence.Column;
Expand Down Expand Up @@ -86,7 +85,6 @@ public class PageFieldImpl implements PageField, ProfileEntity {

@Column(name = "LOB_VALUE", length = Integer.MAX_VALUE-1)
@Lob
@Type(type = "org.hibernate.type.MaterializedClobType")
@AdminPresentation
protected String lobValue;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
import org.broadleafcommerce.common.presentation.client.VisibilityEnum;
import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.Parameter;
import org.hibernate.annotations.Type;

import jakarta.persistence.Column;
import jakarta.persistence.Entity;
Expand Down Expand Up @@ -80,7 +79,6 @@ public class PageItemCriteriaImpl implements PageItemCriteria, ProfileEntity {
protected Integer quantity;

@Lob
@Type(type = "org.hibernate.type.MaterializedClobType")
@Column(name = "ORDER_ITEM_MATCH_RULE", length = Integer.MAX_VALUE - 1)
@AdminPresentation(friendlyName = "PageItemCriteriaImpl_Order_Item_Match_Rule",
group = "PageItemCriteriaImpl_Description", visibility = VisibilityEnum.HIDDEN_ALL)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
import org.broadleafcommerce.common.extensibility.jpa.copy.ProfileEntity;
import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.Parameter;
import org.hibernate.annotations.Type;

import jakarta.persistence.Column;
import jakarta.persistence.Entity;
Expand Down Expand Up @@ -66,7 +65,6 @@ public class PageRuleImpl implements PageRule, ProfileEntity {
protected Long id;

@Lob
@Type(type = "org.hibernate.type.MaterializedClobType")
@Column(name = "MATCH_RULE", length = Integer.MAX_VALUE - 1)
protected String matchRule;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
import org.broadleafcommerce.openadmin.audit.AdminAuditableListener;
import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.Parameter;
import org.hibernate.annotations.Type;

import jakarta.persistence.Column;
import jakarta.persistence.Entity;
Expand Down Expand Up @@ -80,7 +79,6 @@ public class StructuredContentFieldImpl implements StructuredContentField, Profi
@AdminPresentation
@Column (name = "LOB_VALUE", length = Integer.MAX_VALUE - 1)
@Lob
@Type(type = "org.hibernate.type.MaterializedClobType")
protected String lobValue;

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.Parameter;
import org.hibernate.annotations.Type;

import jakarta.persistence.Column;
import jakarta.persistence.Entity;
Expand Down Expand Up @@ -86,7 +85,6 @@ public class StructuredContentItemCriteriaImpl
protected Integer quantity;

@Lob
@Type(type = "org.hibernate.type.MaterializedClobType")
@Column(name = "ORDER_ITEM_MATCH_RULE", length = Integer.MAX_VALUE - 1)
@AdminPresentation(friendlyName = "StructuredContentItemCriteriaImpl_Order_Item_Match_Rule",
group = "StructuredContentItemCriteriaImpl_Description",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.Parameter;
import org.hibernate.annotations.Type;

import jakarta.persistence.Column;
import jakarta.persistence.Entity;
Expand Down Expand Up @@ -69,7 +68,6 @@ public class StructuredContentRuleImpl implements StructuredContentRule, Profile
protected Long id;

@Lob
@Type(type = "org.hibernate.type.MaterializedClobType")
@Column(name = "MATCH_RULE", length = Integer.MAX_VALUE - 1)
protected String matchRule;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
import org.broadleafcommerce.openadmin.dto.TabMetadata;
import org.broadleafcommerce.openadmin.server.dao.provider.metadata.FieldMetadataProvider;
import org.broadleafcommerce.openadmin.server.service.persistence.module.FieldManager;
import org.hibernate.Criteria;
import org.hibernate.mapping.PersistentClass;
import org.hibernate.type.Type;

Expand Down Expand Up @@ -119,8 +118,6 @@ public interface DynamicEntityDao {

List<String> getPropertyNames(Class<?> entityClass);

Criteria createCriteria(Class<?> entityClass);

Field[] getAllFields(Class<?> targetClass);

Metadata getMetadata();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@
import org.broadleafcommerce.openadmin.server.service.persistence.module.FieldManager;
import org.broadleafcommerce.openadmin.server.service.persistence.validation.FieldNamePropertyValidator;
import org.broadleafcommerce.openadmin.server.service.type.MetadataProviderResponse;
import org.hibernate.Criteria;
import org.hibernate.MappingException;
import org.hibernate.Session;
import org.hibernate.mapping.PersistentClass;
Expand Down Expand Up @@ -157,11 +156,6 @@ public void setApplicationContext(ApplicationContext applicationContext) throws
this.applicationContext = applicationContext;
}

@Override
public Criteria createCriteria(Class<?> entityClass) {
return getStandardEntityManager().unwrap(Session.class).createCriteria(entityClass);
}

@Override
public <T> T persist(T entity) {
standardEntityManager.persist(entity);
Expand Down Expand Up @@ -1101,12 +1095,10 @@ protected Map<String, FieldMetadata> getPropertiesForEntityClass(
propertyTypes.add(idType);

PersistentClass persistentClass = getPersistentClass(targetClass.getName());
Iterator testIter = persistentClass.getPropertyIterator();
List<Property> propertyList = new ArrayList<>();

//check the properties for problems
while (testIter.hasNext()) {
Property property = (Property) testIter.next();
for (Property property : persistentClass.getPropertyClosure()) {
if (property.getName().contains(".")) {
throw new IllegalArgumentException("Properties from entities that utilize a period character ('.') in their name are incompatible with this system. The property name in question is: (" + property.getName() + ") from the class: (" + targetClass.getName() + ")");
}
Expand Down Expand Up @@ -1677,11 +1669,9 @@ protected void buildComponentProperties(
property = persistentClass.getProperty(prefix + propertyName);
}

Iterator componentPropertyIterator = ((org.hibernate.mapping.Component) property.getValue()).getPropertyIterator();
List<Property> componentPropertyList = new ArrayList<>();

while (componentPropertyIterator.hasNext()) {
componentPropertyList.add((Property) componentPropertyIterator.next());
for (Property componentProperty : ((org.hibernate.mapping.Component) property.getValue()).getProperties()) {
componentPropertyList.add(componentProperty);
}

Map<String, FieldMetadata> newFields = new HashMap<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.engine.jdbc.Size;
import org.hibernate.engine.spi.Mapping;
import org.hibernate.mapping.Column;
import org.hibernate.mapping.PersistentClass;
import org.hibernate.mapping.Property;
Expand Down Expand Up @@ -173,15 +172,17 @@ public MetadataProviderResponse addMetadataFromMappingData(
Column column = null;
for (Property property : addMetadataFromMappingDataRequest.getComponentProperties()) {
if (property.getName().equals(addMetadataFromMappingDataRequest.getPropertyName())) {
Object columnObject = property.getColumnIterator().next();
if (columnObject instanceof Column) {
column = (Column) columnObject;
if (!property.getColumns().isEmpty()) {
Object columnObject = property.getColumns().get(0);
if (columnObject instanceof Column) {
column = (Column) columnObject;
}
}
break;
}
}
if (column != null) {
fieldMetadata.setLength(column.getLength());
fieldMetadata.setLength(column.getLength().intValue());
fieldMetadata.setScale(column.getScale());
fieldMetadata.setPrecision(column.getPrecision());
fieldMetadata.setRequired(!column.isNullable());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,7 @@
import org.broadleafcommerce.openadmin.server.dao.provider.metadata.request.OverrideViaXmlRequest;
import org.broadleafcommerce.openadmin.server.service.persistence.module.FieldManager;
import org.broadleafcommerce.openadmin.server.service.type.MetadataProviderResponse;
import org.hibernate.internal.TypeLocatorImpl;
import org.hibernate.type.Type;
import org.hibernate.type.TypeFactory;
import org.hibernate.type.TypeResolver;
import org.hibernate.type.spi.TypeConfiguration;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
Expand Down Expand Up @@ -126,20 +123,23 @@ public MetadataProviderResponse addMetadataFromFieldType(AddMetadataFromFieldTyp
for (Map.Entry<String, FieldMetadata> entry : addMetadataFromFieldTypeRequest.getPresentationAttributes().entrySet()) {
if (entry.getKey().startsWith(addMetadataFromFieldTypeRequest.getRequestedPropertyName() + FieldManager.MAPFIELDSEPARATOR)) {
TypeConfiguration typeConfiguration = new TypeConfiguration();
TypeFactory typeFactory = new TypeFactory(typeConfiguration);
TypeLocatorImpl typeLocator = new TypeLocatorImpl(new TypeResolver(typeConfiguration, typeFactory));

Type myType = null;
//first, check if an explicit type was declared
String valueClass = ((BasicFieldMetadata) entry.getValue()).getMapFieldValueClass();
if (valueClass != null) {
myType = typeLocator.entity(valueClass);
try {
// Try to resolve as an entity type
myType = typeConfiguration.getBasicTypeRegistry().getRegisteredType(valueClass);
} catch (Exception e) {
// Ignore, will try other methods
}
}
if (myType == null) {
SupportedFieldType fieldType = ((BasicFieldMetadata) entry.getValue()).getExplicitFieldType();
Class<?> basicJavaType = getBasicJavaType(fieldType);
if (basicJavaType != null) {
myType = typeLocator.basic(basicJavaType);
myType = typeConfiguration.getBasicTypeRegistry().getRegisteredType(basicJavaType);
}
}
if (myType == null) {
Expand All @@ -149,7 +149,11 @@ public MetadataProviderResponse addMetadataFromFieldType(AddMetadataFromFieldTyp
Class<?> clazz = (Class<?>) pType.getActualTypeArguments()[1];
Class<?>[] entities = addMetadataFromFieldTypeRequest.getDynamicEntityDao().getAllPolymorphicEntitiesFromCeiling(clazz);
if (!ArrayUtils.isEmpty(entities)) {
myType = typeLocator.entity(entities[entities.length-1]);
try {
myType = typeConfiguration.getBasicTypeRegistry().getRegisteredType(entities[entities.length-1]);
} catch (Exception e) {
// Ignore, will fail later with better error message
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
import org.broadleafcommerce.openadmin.server.security.remote.SecurityVerifier;
import org.broadleafcommerce.openadmin.server.security.service.RowLevelSecurityService;
import org.broadleafcommerce.openadmin.server.service.persistence.module.EmptyFilterValues;
import org.hibernate.type.SingleColumnType;
import org.hibernate.type.BasicType;
import org.springframework.stereotype.Service;

import java.io.Serializable;
Expand Down Expand Up @@ -133,7 +133,7 @@ public TypedQuery<Serializable> translateQuery(
if (idMetaData != null) {
Object idFldName = idMetaData.get("name");
Object type = idMetaData.get("type");
if ((idFldName instanceof String) && (type instanceof SingleColumnType)) {
if ((idFldName instanceof String) && (type instanceof BasicType)) {
criteria.orderBy(criteriaBuilder.asc(original.get((String) idFldName)));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,12 @@
import org.apache.commons.lang3.StringUtils;
import org.broadleafcommerce.common.util.dao.DynamicDaoHelper;
import org.broadleafcommerce.common.util.dao.DynamicDaoHelperImpl;
import org.hibernate.internal.SessionFactoryImpl;
import org.hibernate.query.criteria.internal.CriteriaBuilderImpl;
import org.hibernate.query.criteria.internal.path.PluralAttributePath;

import java.util.ArrayList;
import java.util.List;

import jakarta.persistence.Embeddable;
import jakarta.persistence.EntityManager;
import jakarta.persistence.criteria.CriteriaBuilder;
import jakarta.persistence.criteria.CriteriaQuery;
import jakarta.persistence.criteria.From;
Expand All @@ -37,6 +35,7 @@
import jakarta.persistence.metamodel.Attribute;
import jakarta.persistence.metamodel.ManagedType;
import jakarta.persistence.metamodel.Metamodel;
import jakarta.persistence.metamodel.PluralAttribute;

/**
* @author Jeff Fischer
Expand All @@ -47,6 +46,7 @@ public class FieldPathBuilder {

protected CriteriaQuery criteria;
protected List<Predicate> restrictions;
protected EntityManager entityManager;

public FieldPath getFieldPath(From root, String fullPropertyName) {
String[] pieces = fullPropertyName.split("\\.");
Expand All @@ -56,10 +56,16 @@ public FieldPath getFieldPath(From root, String fullPropertyName) {
for (String piece : pieces) {
checkPiece: {
if (j == 0) {
Path path = root.get(piece);
if (path instanceof PluralAttributePath) {
associationPath.add(piece);
break checkPiece;
try {
if (root.getModel() instanceof ManagedType) {
Attribute<?, ?> attribute = ((ManagedType<?>) root.getModel()).getAttribute(piece);
if (attribute instanceof PluralAttribute) {
associationPath.add(piece);
break checkPiece;
}
}
} catch (IllegalArgumentException e) {
// Attribute doesn't exist, treat as basic property
}
}
basicProperties.add(piece);
Expand Down Expand Up @@ -98,8 +104,7 @@ public Path getPath(From root, FieldPath fieldPath, final CriteriaBuilder builde
// We weren't able to resolve the requested piece, likely because it's in a polymoprhic version
// of the path we're currently on. Let's see if there's any polymoprhic version of our class to
// use instead.
SessionFactoryImpl em = ((CriteriaBuilderImpl) builder).getEntityManagerFactory();
Metamodel mm = em.getMetamodel();
Metamodel mm = entityManager.getMetamodel();
boolean found = false;

Class<?>[] polyClasses = dynamicDaoHelper.getAllPolymorphicEntitiesFromCeiling(
Expand Down Expand Up @@ -127,7 +132,13 @@ public Path getPath(From root, FieldPath fieldPath, final CriteriaBuilder builde
}
}

if (path.getParentPath() != null && path.getParentPath().getJavaType().isAnnotationPresent(Embeddable.class) && path instanceof PluralAttributePath) {
boolean isPlural = false;
try {
isPlural = path.getModel() instanceof PluralAttribute;
} catch (IllegalStateException e) {
// Path doesn't have a model, skip check
}
if (path.getParentPath() != null && path.getParentPath().getJavaType().isAnnotationPresent(Embeddable.class) && isPlural) {
//We need a workaround for this problem until it is resolved in Hibernate (loosely related to and likely resolved by https://hibernate.atlassian.net/browse/HHH-8802)
//We'll throw a specialized exception (and handle in an alternate flow for calls from BasicPersistenceModule)
throw new CriteriaConversionException(String.format("Unable to create a JPA criteria Path through an @Embeddable object to a collection that resides therein (%s)", fieldPath.getTargetProperty()), fieldPath);
Expand Down Expand Up @@ -164,4 +175,12 @@ public void setRestrictions(List<Predicate> restrictions) {
this.restrictions = restrictions;
}

public EntityManager getEntityManager() {
return entityManager;
}

public void setEntityManager(EntityManager entityManager) {
this.entityManager = entityManager;
}

}
9 changes: 4 additions & 5 deletions common/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -313,8 +313,7 @@
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<optional>true</optional>
<artifactId>log4j-to-slf4j</artifactId>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
Expand Down Expand Up @@ -479,9 +478,9 @@
<artifactId>javassist</artifactId>
</dependency>
<dependency>
<groupId>jakarta.cache</groupId>
<artifactId>jakarta.cache-api</artifactId>
<version>3.0.0</version>
<groupId>javax.cache</groupId>
<artifactId>cache-api</artifactId>
<version>1.1.0</version>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ public abstract class AbstractModuleConfiguration implements ModuleConfiguration

@Id
@GeneratedValue(generator = "ModuleConfigurationId")
@SuppressWarnings("removal")
@GenericGenerator(
name = "ModuleConfigurationId",
strategy="org.broadleafcommerce.common.persistence.IdOverrideTableGenerator",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ public class SystemPropertyImpl implements SystemProperty, AdminMainEntity, Syst

@Id
@GeneratedValue(generator = "SystemPropertyId")
@SuppressWarnings("removal")
@GenericGenerator(
name = "SystemPropertyId",
strategy="org.broadleafcommerce.common.persistence.IdOverrideTableGenerator",
Expand Down
Loading
Loading