Skip to content

Commit 4a4f636

Browse files
committed
HHH-6330 - Remove entity mode switching capability
1 parent a8ee266 commit 4a4f636

File tree

254 files changed

+2190
-5204
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

254 files changed

+2190
-5204
lines changed

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

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
/*
22
* Hibernate, Relational Persistence for Idiomatic Java
33
*
4-
* Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
4+
* Copyright (c) 2008-2011, Red Hat Inc. or third-party contributors as
55
* indicated by the @author tags or express copyright attribution
66
* statements applied by the authors. All third-party contributions are
7-
* distributed under license by Red Hat Middleware LLC.
7+
* distributed under license by Red Hat Inc.
88
*
99
* This copyrighted material is made available to anyone wishing to use, modify,
1010
* copy, or redistribute it subject to the terms and conditions of the GNU
@@ -20,7 +20,6 @@
2020
* Free Software Foundation, Inc.
2121
* 51 Franklin Street, Fifth Floor
2222
* Boston, MA 02110-1301 USA
23-
*
2423
*/
2524
package org.hibernate;
2625

@@ -30,10 +29,11 @@
3029
* @author Steve Ebersole
3130
*/
3231
public enum EntityMode {
33-
POJO("pojo"),
34-
DOM4J("dom4j"),
35-
MAP("dynamic-map");
32+
POJO( "pojo" ),
33+
MAP( "dynamic-map" );
34+
3635
private final String name;
36+
3737
EntityMode(String name) {
3838
this.name = name;
3939
}
@@ -43,12 +43,22 @@ public String toString() {
4343
return name;
4444
}
4545

46+
private static final String DYNAMIC_MAP_NAME = MAP.name.toUpperCase();
47+
48+
/**
49+
* Legacy-style entity-mode name parsing. <b>Case insensitive</b>
50+
*
51+
* @param entityMode The entity mode name to evaluate
52+
*
53+
* @return The appropriate entity mode; {@code null} for incoming {@code entityMode} param is treated by returning
54+
* {@link #POJO}.
55+
*/
4656
public static EntityMode parse(String entityMode) {
47-
if(entityMode == null){
57+
if ( entityMode == null ) {
4858
return POJO;
4959
}
5060
entityMode = entityMode.toUpperCase();
51-
if ( entityMode.equals( "DYNAMIC-MAP" ) ) {
61+
if ( DYNAMIC_MAP_NAME.equals( entityMode ) ) {
5262
return MAP;
5363
}
5464
return valueOf( entityMode );

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

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -97,26 +97,6 @@ public interface Session extends SharedSessionContract {
9797
*/
9898
public SharedSessionBuilder sessionWithOptions();
9999

100-
/**
101-
* Retrieve the entity mode in effect for this session.
102-
*
103-
* @return The entity mode for this session.
104-
*/
105-
public EntityMode getEntityMode();
106-
107-
/**
108-
* Starts a new Session with the given entity mode in effect. This secondary
109-
* Session inherits the connection, transaction, and other context
110-
* information from the primary Session. It doesn't need to be flushed
111-
* or closed by the developer.
112-
*
113-
* @param entityMode The entity mode to use for the new session.
114-
* @return The new session
115-
* @deprecated
116-
*/
117-
@Deprecated
118-
public Session getSession(EntityMode entityMode);
119-
120100
/**
121101
* Force this session to flush. Must be called at the end of a
122102
* unit of work, before committing the transaction and closing the

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

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -78,15 +78,6 @@ public interface SessionBuilder {
7878
*/
7979
public SessionBuilder connectionReleaseMode(ConnectionReleaseMode connectionReleaseMode);
8080

81-
/**
82-
* Use a specific entity mode for these session options
83-
*
84-
* @param entityMode The entity mode to use.
85-
*
86-
* @return {@code this}, for method chaining
87-
*/
88-
public SessionBuilder entityMode(EntityMode entityMode);
89-
9081
/**
9182
* Should the session built automatically join in any ongoing JTA transactions
9283
*

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

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,6 @@ public interface SharedSessionBuilder extends SessionBuilder {
5252
*/
5353
public SharedSessionBuilder connectionReleaseMode();
5454

55-
/**
56-
* Signifies that the entity mode from the original session should be used to create the new session
57-
*
58-
* @return {@code this}, for method chaining
59-
*/
60-
public SharedSessionBuilder entityMode();
61-
6255
/**
6356
* Signifies that the autoJoinTransaction flag from the original session should be used to create the new session
6457
*
@@ -99,9 +92,6 @@ public interface SharedSessionBuilder extends SessionBuilder {
9992
@Override
10093
SharedSessionBuilder connectionReleaseMode(ConnectionReleaseMode connectionReleaseMode);
10194

102-
@Override
103-
SharedSessionBuilder entityMode(EntityMode entityMode);
104-
10595
@Override
10696
SharedSessionBuilder autoJoinTransactions(boolean autoJoinTransactions);
10797

hibernate-core/src/main/java/org/hibernate/action/internal/CollectionAction.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ public int compareTo(Object other) {
170170
else {
171171
//then by fk
172172
return persister.getKeyType()
173-
.compare( key, action.key, session.getEntityMode() );
173+
.compare( key, action.key );
174174
}
175175
}
176176

hibernate-core/src/main/java/org/hibernate/action/internal/EntityAction.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ public int compareTo(Object other) {
168168
}
169169
else {
170170
//then by id
171-
return persister.getIdentifierType().compare( id, action.id, session.getEntityMode() );
171+
return persister.getIdentifierType().compare( id, action.id );
172172
}
173173
}
174174

hibernate-core/src/main/java/org/hibernate/action/internal/EntityDeleteAction.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ public void execute() throws HibernateException {
7575
// we need to grab the version value from the entity, otherwise
7676
// we have issues with generated-version entities that may have
7777
// multiple actions queued during the same flush
78-
version = persister.getVersion( instance, session.getEntityMode() );
78+
version = persister.getVersion( instance );
7979
}
8080

8181
final CacheKey ck;

hibernate-core/src/main/java/org/hibernate/action/internal/EntityInsertAction.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ public void execute() throws HibernateException {
104104
CacheEntry ce = new CacheEntry(
105105
state,
106106
persister,
107-
persister.hasUninitializedLazyProperties( instance, session.getEntityMode() ),
107+
persister.hasUninitializedLazyProperties( instance ),
108108
version,
109109
session,
110110
instance

hibernate-core/src/main/java/org/hibernate/action/internal/EntityUpdateAction.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ public void execute() throws HibernateException {
9393
// we need to grab the version value from the entity, otherwise
9494
// we have issues with generated-version entities that may have
9595
// multiple actions queued during the same flush
96-
previousVersion = persister.getVersion( instance, session.getEntityMode() );
96+
previousVersion = persister.getVersion( instance );
9797
}
9898

9999
final CacheKey ck;
@@ -161,7 +161,7 @@ public void execute() throws HibernateException {
161161
CacheEntry ce = new CacheEntry(
162162
state,
163163
persister,
164-
persister.hasUninitializedLazyProperties( instance, session.getEntityMode() ),
164+
persister.hasUninitializedLazyProperties( instance ),
165165
nextVersion,
166166
getSession(),
167167
instance

hibernate-core/src/main/java/org/hibernate/cache/spi/CacheKey.java

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525

2626
import java.io.Serializable;
2727

28-
import org.hibernate.EntityMode;
2928
import org.hibernate.engine.spi.SessionFactoryImplementor;
3029
import org.hibernate.internal.util.compare.EqualsHelper;
3130
import org.hibernate.type.Type;
@@ -41,7 +40,6 @@ public class CacheKey implements Serializable {
4140
private final Serializable key;
4241
private final Type type;
4342
private final String entityOrRoleName;
44-
private final EntityMode entityMode;
4543
private final String tenantId;
4644
private final int hashCode;
4745

@@ -53,23 +51,20 @@ public class CacheKey implements Serializable {
5351
* @param id The identifier associated with the cached data
5452
* @param type The Hibernate type mapping
5553
* @param entityOrRoleName The entity or collection-role name.
56-
* @param entityMode The entity mode of the originating session
5754
* @param tenantId The tenant identifier associated this data.
5855
* @param factory The session factory for which we are caching
5956
*/
6057
public CacheKey(
6158
final Serializable id,
6259
final Type type,
6360
final String entityOrRoleName,
64-
final EntityMode entityMode,
6561
final String tenantId,
6662
final SessionFactoryImplementor factory) {
6763
this.key = id;
6864
this.type = type;
6965
this.entityOrRoleName = entityOrRoleName;
70-
this.entityMode = entityMode;
7166
this.tenantId = tenantId;
72-
this.hashCode = type.getHashCode( key, entityMode, factory );
67+
this.hashCode = type.getHashCode( key, factory );
7368
}
7469

7570
@Override
@@ -85,7 +80,7 @@ public boolean equals(Object other) {
8580
}
8681
CacheKey that = (CacheKey) other;
8782
return entityOrRoleName.equals( that.entityOrRoleName ) &&
88-
type.isEqual( key, that.key, entityMode ) &&
83+
type.isEqual( key, that.key ) &&
8984
EqualsHelper.equals( tenantId, that.tenantId );
9085
}
9186

hibernate-core/src/main/java/org/hibernate/cache/spi/FilterKey.java

Lines changed: 17 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,10 @@
2626
import java.io.Serializable;
2727
import java.util.HashMap;
2828
import java.util.HashSet;
29-
import java.util.Iterator;
3029
import java.util.Map;
3130
import java.util.Set;
3231

33-
import org.hibernate.EntityMode;
32+
import org.hibernate.Filter;
3433
import org.hibernate.engine.spi.TypedValue;
3534
import org.hibernate.internal.FilterImpl;
3635
import org.hibernate.type.Type;
@@ -42,15 +41,13 @@
4241
*/
4342
public final class FilterKey implements Serializable {
4443
private String filterName;
45-
private Map filterParameters = new HashMap();
44+
private Map<String,TypedValue> filterParameters = new HashMap<String,TypedValue>();
4645

47-
public FilterKey(String name, Map params, Map types, EntityMode entityMode) {
46+
public FilterKey(String name, Map<String,?> params, Map<String,Type> types) {
4847
filterName = name;
49-
Iterator iter = params.entrySet().iterator();
50-
while ( iter.hasNext() ) {
51-
Map.Entry me = (Map.Entry) iter.next();
52-
Type type = (Type) types.get( me.getKey() );
53-
filterParameters.put( me.getKey(), new TypedValue( type, me.getValue(), entityMode ) );
48+
for ( Map.Entry<String, ?> paramEntry : params.entrySet() ) {
49+
Type type = types.get( paramEntry.getKey() );
50+
filterParameters.put( paramEntry.getKey(), new TypedValue( type, paramEntry.getValue() ) );
5451
}
5552
}
5653

@@ -73,19 +70,18 @@ public String toString() {
7370
return "FilterKey[" + filterName + filterParameters + ']';
7471
}
7572

76-
public static Set createFilterKeys(Map enabledFilters, EntityMode entityMode) {
77-
if ( enabledFilters.size()==0 ) return null;
78-
Set result = new HashSet();
79-
Iterator iter = enabledFilters.values().iterator();
80-
while ( iter.hasNext() ) {
81-
FilterImpl filter = (FilterImpl) iter.next();
73+
public static Set<FilterKey> createFilterKeys(Map<String,Filter> enabledFilters) {
74+
if ( enabledFilters.size()==0 ) {
75+
return null;
76+
}
77+
Set<FilterKey> result = new HashSet<FilterKey>();
78+
for ( Filter filter : enabledFilters.values() ) {
8279
FilterKey key = new FilterKey(
83-
filter.getName(),
84-
filter.getParameters(),
85-
filter.getFilterDefinition().getParameterTypes(),
86-
entityMode
87-
);
88-
result.add(key);
80+
filter.getName(),
81+
( (FilterImpl) filter ).getParameters(),
82+
filter.getFilterDefinition().getParameterTypes()
83+
);
84+
result.add( key );
8985
}
9086
return result;
9187
}

0 commit comments

Comments
 (0)