Skip to content

Commit e02e1e2

Browse files
committed
remove the layer-breaking getLobCreator() methods from the Hibernate class
This is in principle a breaking change, but one I consider pretty innocuous, since I can't imagine why anyone was calling Hibernate.getLobCreator(session) instead of session.getLobHelper().
1 parent e331c28 commit e02e1e2

File tree

7 files changed

+12
-60
lines changed

7 files changed

+12
-60
lines changed

hibernate-core/src/main/java/org/hibernate/Hibernate.java

Lines changed: 1 addition & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -28,20 +28,15 @@
2828
import org.hibernate.collection.spi.PersistentSortedMap;
2929
import org.hibernate.collection.spi.PersistentSortedSet;
3030
import org.hibernate.collection.spi.PersistentCollection;
31-
import org.hibernate.engine.jdbc.LobCreator;
32-
import org.hibernate.engine.jdbc.spi.JdbcServices;
3331
import org.hibernate.engine.spi.PersistentAttributeInterceptable;
3432
import org.hibernate.engine.spi.PersistentAttributeInterceptor;
3533
import org.hibernate.engine.spi.SessionFactoryImplementor;
36-
import org.hibernate.engine.spi.SessionImplementor;
37-
import org.hibernate.engine.spi.SharedSessionContractImplementor;
3834
import org.hibernate.persister.entity.EntityPersister;
3935
import org.hibernate.proxy.HibernateProxy;
4036
import org.hibernate.proxy.LazyInitializer;
4137

4238
/**
43-
* Various utility functions for working with proxies and lazy collection references,
44-
* along with factory methods for obtaining a {@link LobCreator}.
39+
* Various utility functions for working with proxies and lazy collection references.
4540
* <p>
4641
* Operations like {@link #isInitialized(Object)} and {@link #initialize(Object)} are
4742
* of general purpose. But {@link #createDetachedProxy(SessionFactory, Class, Object)}
@@ -63,11 +58,7 @@
6358
* the program to intervene in the process of serialization and of deserialization.
6459
*
6560
* @author Gavin King
66-
* @see java.sql.Clob
67-
* @see java.sql.Blob
68-
* @see org.hibernate.type.Type
6961
*/
70-
7162
public final class Hibernate {
7263
/**
7364
* Cannot be instantiated.
@@ -112,7 +103,6 @@ else if ( proxy instanceof PersistentAttributeInterceptable ) {
112103
* @param proxy a persistable object, proxy, persistent collection or {@code null}
113104
* @return true if the argument is already initialized, or is not a proxy or collection
114105
*/
115-
@SuppressWarnings("SimplifiableIfStatement")
116106
public static boolean isInitialized(Object proxy) {
117107
if ( proxy instanceof HibernateProxy ) {
118108
return !( (HibernateProxy) proxy ).getHibernateLazyInitializer().isUninitialized();
@@ -150,45 +140,6 @@ public static <T> Class<? extends T> getClass(T proxy) {
150140
return (Class<? extends T>) result;
151141
}
152142

153-
/**
154-
* Obtain a lob creator for the given session.
155-
*
156-
* @param session The session for which to obtain a lob creator
157-
*
158-
* @return The log creator reference
159-
*/
160-
public static LobCreator getLobCreator(Session session) {
161-
return getLobCreator( (SessionImplementor) session );
162-
}
163-
164-
/**
165-
* Obtain a lob creator for the given session.
166-
*
167-
* @param session The session for which to obtain a lob creator
168-
*
169-
* @return The log creator reference
170-
*/
171-
public static LobCreator getLobCreator(SharedSessionContractImplementor session) {
172-
return session.getFactory()
173-
.getServiceRegistry()
174-
.getService( JdbcServices.class )
175-
.getLobCreator( session );
176-
}
177-
178-
/**
179-
* Obtain a lob creator for the given session.
180-
*
181-
* @param session The session for which to obtain a lob creator
182-
*
183-
* @return The log creator reference
184-
*/
185-
public static LobCreator getLobCreator(SessionImplementor session) {
186-
return session.getFactory()
187-
.getServiceRegistry()
188-
.getService( JdbcServices.class )
189-
.getLobCreator( session );
190-
}
191-
192143
/**
193144
* Check if the property is initialized. If the named property does not exist or
194145
* is not persistent, this method always returns {@code true}.

hibernate-core/src/main/java/org/hibernate/internal/AbstractSharedSessionContract.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
import org.hibernate.EmptyInterceptor;
2525
import org.hibernate.EntityNameResolver;
2626
import org.hibernate.FlushMode;
27-
import org.hibernate.Hibernate;
2827
import org.hibernate.HibernateException;
2928
import org.hibernate.Interceptor;
3029
import org.hibernate.LockMode;
@@ -57,7 +56,6 @@
5756
import org.hibernate.procedure.ProcedureCall;
5857
import org.hibernate.procedure.internal.ProcedureCallImpl;
5958
import org.hibernate.procedure.spi.NamedCallableQueryMemento;
60-
import org.hibernate.query.NativeQuery;
6159
import org.hibernate.query.Query;
6260
import org.hibernate.query.criteria.HibernateCriteriaBuilder;
6361
import org.hibernate.query.hql.spi.HqlQueryImplementor;
@@ -570,7 +568,10 @@ public int getPreferredSqlTypeCodeForBoolean() {
570568

571569
@Override
572570
public LobCreator getLobCreator() {
573-
return Hibernate.getLobCreator( this );
571+
return ( (SharedSessionContractImplementor) this ).getFactory()
572+
.getServiceRegistry()
573+
.getService( JdbcServices.class )
574+
.getLobCreator(this);
574575
}
575576

576577
@Override

hibernate-core/src/test/java/org/hibernate/orm/test/bytecode/enhancement/lazy/proxy/FetchGraphTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -702,7 +702,7 @@ public void prepareTestData() {
702702
d.setOid( 1 );
703703

704704
byte[] lBytes = "agdfagdfagfgafgsfdgasfdgfgasdfgadsfgasfdgasfdgasdasfdg".getBytes();
705-
Blob lBlob = Hibernate.getLobCreator( session ).createBlob( lBytes );
705+
Blob lBlob = session.getLobCreator().createBlob( lBytes );
706706
d.setBlob( lBlob );
707707

708708
BEntity b1 = new BEntity();

hibernate-core/src/test/java/org/hibernate/orm/test/bytecode/enhancement/lazy/proxy/ProxyDeletionTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ public void prepareTestData() {
9696
d.setOid( 1 );
9797

9898
byte[] lBytes = "agdfagdfagfgafgsfdgasfdgfgasdfgadsfgasfdgasfdgasdasfdg".getBytes();
99-
Blob lBlob = Hibernate.getLobCreator( session ).createBlob( lBytes );
99+
Blob lBlob = session.getLobCreator().createBlob( lBytes );
100100
d.setBlob( lBlob );
101101

102102
BEntity b1 = new BEntity();

hibernate-core/src/test/java/org/hibernate/orm/test/connections/HibernateCreateBlobFailedCase.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,9 @@ public void configure(Configuration cfg) {
4747
public void testLobCreation() throws SQLException {
4848
Session session = sessionFactory().getCurrentSession();
4949
session.beginTransaction();
50-
Blob blob = Hibernate.getLobCreator( session ).createBlob( new byte[] {} );
50+
Blob blob = session.getLobHelper().createBlob( new byte[] {} );
5151
blob.free();
52-
Clob clob = Hibernate.getLobCreator( session ).createClob( "Steve" );
52+
Clob clob = session.getLobHelper().createClob( "Steve" );
5353
clob.free();
5454
session.getTransaction().commit();
5555
assertFalse( session.isOpen() );

hibernate-core/src/test/java/org/hibernate/orm/test/jpa/query/NativeQueryResultTypeAutoDiscoveryTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -249,12 +249,12 @@ public void lobTypes() {
249249
doTest(
250250
ClobEntity.class,
251251
Clob.class,
252-
session -> Hibernate.getLobCreator( session ).createClob( "some text" )
252+
session -> session.getLobHelper().createClob( "some text" )
253253
);
254254
doTest(
255255
BlobEntity.class,
256256
Blob.class,
257-
session -> Hibernate.getLobCreator( session ).createBlob( "some text".getBytes() )
257+
session -> session.getLobHelper().createBlob( "some text".getBytes() )
258258
);
259259
}
260260

hibernate-core/src/test/java/org/hibernate/orm/test/lob/BlobLocatorTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ public void testUnboundedBlobLocatorAccess() throws Throwable {
141141
Session s = openSession();
142142
s.beginTransaction();
143143
LobHolder entity = new LobHolder();
144-
entity.setBlobLocator( Hibernate.getLobCreator( s ).createBlob( original ) );
144+
entity.setBlobLocator( s.getLobHelper().createBlob( original ) );
145145
s.save( entity );
146146
s.getTransaction().commit();
147147
s.close();

0 commit comments

Comments
 (0)