Skip to content

Commit

Permalink
removal of deprecated unused code for H7 (#8485)
Browse files Browse the repository at this point in the history
* remove unused stuff already marked forRemoval
* remove old NamingStrategy stuff which does not actually work anymore
* some cleanups to the mapping package
  - make a couple of deprecated methods private
  - delete some unnecessary code
  - remove all obsolete "iterator" methods
  • Loading branch information
gavinking authored and sebersole committed Jul 24, 2024
1 parent e570640 commit 01ceadf
Show file tree
Hide file tree
Showing 128 changed files with 185 additions and 3,923 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,6 @@ Hibernate looks at this as 2-stage process:
* Second is the resolving of this logical name to a physical name which is defined
by the <<PhysicalNamingStrategy>> contract.


[NOTE]
.Historical NamingStrategy contract
====
Historically Hibernate defined just a single `org.hibernate.cfg.NamingStrategy`. That singular
NamingStrategy contract actually combined the separate concerns that are now modeled individually
as ImplicitNamingStrategy and PhysicalNamingStrategy.
Also, the NamingStrategy contract was often not flexible enough to properly apply a given naming
"rule", either because the API lacked the information to decide or because the API was honestly
not well defined as it grew.
Due to these limitations, `org.hibernate.cfg.NamingStrategy` has been deprecated
in favor of ImplicitNamingStrategy and PhysicalNamingStrategy.
====

At the core, the idea behind each naming strategy is to minimize the amount of
repetitive information a developer must provide for mapping a domain model.

Expand Down
39 changes: 0 additions & 39 deletions hibernate-core/src/main/java/org/hibernate/QueryException.java
Original file line number Diff line number Diff line change
Expand Up @@ -111,43 +111,4 @@ public String getMessage() {
protected final String getOriginalMessage() {
return super.getMessage();
}

/**
* Wraps this exception with another, of same kind, with the specified query string.
* If this exception already has a query string defined, the same exception ({@code this})
* is returned. Otherwise, the protected {@link #generateQueryException(String)} is called,
* to allow subclasses to properly create the correct subclass for return.
*
* @param queryString The query string that led to the QueryException
*
* @return {@code this}, if {@code this} has {@code null} for {@link #getQueryString()};
* otherwise a new {@code QueryException} (or subclass) is returned.
*
* @deprecated This method is no longer used
*/
@Deprecated(since = "6.2", forRemoval = true)
public final QueryException wrapWithQueryString(String queryString) {
if ( this.getQueryString() != null ) {
return this;
}

return generateQueryException( queryString );
}

/**
* Called from {@link #wrapWithQueryString(String)} when we really need to
* generate a new {@code QueryException} (or subclass).
*
* @implNote implementors should take care to use {@link #getOriginalMessage()}
* for the message, not {@link #getMessage()}
*
* @param queryString The query string
*
* @return The generated {@code QueryException} (or subclass)
*
* @see #getOriginalMessage()
*/
protected QueryException generateQueryException(String queryString) {
return new QueryException( getOriginalMessage(), queryString, this );
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,4 @@ public QueryParameterException(String message, String queryString, Exception cau
public QueryParameterException(String message, String queryString) {
super( message, queryString );
}

@Override
protected QueryException generateQueryException(String queryString) {
return new QueryParameterException( super.getOriginalMessage(), queryString, this );
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -75,14 +75,6 @@ public SessionFactoryBuilderImpl(MetadataImplementor metadata, SessionFactoryOpt
addSessionFactoryObservers( new SessionFactoryObserverForRegistration() );
}

/**
* @deprecated This constructor will be removed
*/
@Deprecated(since = "6.2", forRemoval = true)
public SessionFactoryBuilderImpl(MetadataImplementor metadata, SessionFactoryOptionsBuilder optionsBuilder) {
this( metadata, optionsBuilder, metadata.getTypeConfiguration().getMetadataBuildingContext().getBootstrapContext() );
}

@Override
public SessionFactoryBuilder applyBeanManager(Object beanManager) {
this.optionsBuilder.applyBeanManager( beanManager );
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
* </li>
* </ol>
*
* @apiNote The API defined in this package replaced the now-deprecated interface
* {@link org.hibernate.cfg.NamingStrategy} from older versions of Hibernate.
* @apiNote The API defined in this package replaced the now-removed interface
* {@code org.hibernate.cfg.NamingStrategy} from older versions of Hibernate.
*/
package org.hibernate.boot.model.naming;
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,15 @@
*/
package org.hibernate.boot.model.source.internal.hbm;

import org.hibernate.annotations.FetchMode;
import org.hibernate.boot.jaxb.hbm.spi.JaxbHbmFetchProfileType;
import org.hibernate.mapping.FetchProfile;
import org.hibernate.mapping.MetadataSource;

import org.jboss.logging.Logger;

import static jakarta.persistence.FetchType.EAGER;

/**
* @author Steve Ebersole
*/
Expand Down Expand Up @@ -69,8 +72,17 @@ public static void processFetchProfile(
context.getOrigin()
);
}
profile.addFetch( entityName, fetchBinding.getAssociation(), fetchBinding.getStyle().value() );
String association = fetchBinding.getAssociation();
profile.addFetch( new FetchProfile.Fetch(entityName, association, fetchMode(fetchBinding.getStyle().value()), EAGER ) );
}
}

private static FetchMode fetchMode(String style) {
for ( FetchMode mode: FetchMode.values() ) {
if ( mode.name().equalsIgnoreCase( style ) ) {
return mode;
}
}
throw new IllegalArgumentException( "Unknown FetchMode: " + style );
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4124,8 +4124,7 @@ public void process() {

final List<Identifier> columnNames = new ArrayList<>();

final UniqueKey uk = new UniqueKey();
uk.setTable( entityBinding.getTable() );
final UniqueKey uk = new UniqueKey(entityBinding.getTable() );
for ( Property attributeBinding : attributeBindings ) {
for ( Selectable selectable : attributeBinding.getSelectables() ) {
if ( selectable instanceof Column ) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -229,14 +229,4 @@ default boolean isXmlMappingEnabled() {
* Check to see if extensions can be hosted in CDI
*/
boolean isAllowExtensionsInCdi();

/**
* Check to see if extensions can be hosted in CDI
*
* @deprecated Use {@link #isAllowExtensionsInCdi()}
*/
@Deprecated(forRemoval = true)
default boolean disallowExtensionsInCdi() {
return !isAllowExtensionsInCdi();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,6 @@ class ByteBuddyEnhancementContext {
this.enhancementContext = Objects.requireNonNull( enhancementContext );
}

/**
* @deprecated as it's currently unused and we're not always actually sourcing the classes to be transformed
* from a classloader, so this getter can't always be honoured correctly.
* @return the ClassLoader provided by the underlying EnhancementContext. Might be otherwise ignored.
*/
@Deprecated(forRemoval = true)
public ClassLoader getLoadingClassLoader() {
return enhancementContext.getLoadingClassLoader();
}

public boolean isEntityClass(TypeDescription classDescriptor) {
return enhancementContext.isEntityClass( new UnloadedTypeDescription( classDescriptor ) );
}
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -210,15 +210,4 @@ public interface AvailableSettings
* {@code hibernate.event.listener.eventType packageName.ClassName1, packageName.ClassName2}
*/
String EVENT_LISTENER_PREFIX = "hibernate.event.listener";

/**
* @deprecated There are much better ways to control the flush mode of a session,
* for example, {@link org.hibernate.SessionBuilder#flushMode} or
* {@link org.hibernate.Session#setHibernateFlushMode}.
*
* @see org.hibernate.jpa.HibernateHints#HINT_FLUSH_MODE
*/
@Deprecated(since = "6.2", forRemoval = true)
@SuppressWarnings("DeprecatedIsStillUsed")
String FLUSH_MODE = "org.hibernate.flushMode";
}
11 changes: 0 additions & 11 deletions hibernate-core/src/main/java/org/hibernate/cfg/Configuration.java
Original file line number Diff line number Diff line change
Expand Up @@ -1001,17 +1001,6 @@ public SessionFactory buildSessionFactory() throws HibernateException {
}
}

/**
* @deprecated use {@link #addSqlFunction(String, SqmFunctionDescriptor)}
*/
@Deprecated(since = "6.5", forRemoval = true)
public Map<String,SqmFunctionDescriptor> getSqlFunctions() {
if ( customFunctionDescriptors == null ) {
customFunctionDescriptors = new HashMap<>();
}
return customFunctionDescriptors;
}

/**
* Adds a {@linkplain SqmFunctionDescriptor function descriptor} to
* this configuration.
Expand Down

This file was deleted.

Loading

0 comments on commit 01ceadf

Please sign in to comment.