mirror of
https://github.com/hibernate/hibernate-orm
synced 2025-02-08 12:14:47 +00:00
HHH-8662 : Deprecate functionality for initialized many-to-many collections of proxies
This commit is contained in:
parent
f679a3c783
commit
412d5d6fca
@ -2094,6 +2094,15 @@ else if ( "one-to-one".equals( node.getName() ) ) {
|
|||||||
fetchStyle = FetchMode.DEFAULT;
|
fetchStyle = FetchMode.DEFAULT;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
if ( "many-to-many".equals( node.getName() ) ) {
|
||||||
|
//NOTE <many-to-many outer-join="..." is deprecated.:
|
||||||
|
// Default to join and non-lazy for the "second join"
|
||||||
|
// of the many-to-many
|
||||||
|
LOG.deprecatedManyToManyOuterJoin();
|
||||||
|
lazy = false;
|
||||||
|
fetchStyle = FetchMode.JOIN;
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
// use old (HB 2.1) defaults if outer-join is specified
|
// use old (HB 2.1) defaults if outer-join is specified
|
||||||
String eoj = jfNode.getValue();
|
String eoj = jfNode.getValue();
|
||||||
@ -2106,11 +2115,22 @@ else if ( "one-to-one".equals( node.getName() ) ) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if ( "many-to-many".equals( node.getName() ) ) {
|
||||||
|
//NOTE <many-to-many fetch="..." is deprecated.:
|
||||||
|
// Default to join and non-lazy for the "second join"
|
||||||
|
// of the many-to-many
|
||||||
|
LOG.deprecatedManyToManyFetch();
|
||||||
|
lazy = false;
|
||||||
|
fetchStyle = FetchMode.JOIN;
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
boolean join = "join".equals( fetchNode.getValue() );
|
boolean join = "join".equals( fetchNode.getValue() );
|
||||||
//lazy = !join;
|
//lazy = !join;
|
||||||
fetchStyle = join ? FetchMode.JOIN : FetchMode.SELECT;
|
fetchStyle = join ? FetchMode.JOIN : FetchMode.SELECT;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
model.setFetchMode( fetchStyle );
|
model.setFetchMode( fetchStyle );
|
||||||
model.setLazy(lazy);
|
model.setLazy(lazy);
|
||||||
}
|
}
|
||||||
|
@ -1654,4 +1654,12 @@ void cannotResolveNonNullableTransientDependencies(String transientEntityString,
|
|||||||
@Message(value = "Exception while discovering OSGi service implementations : %s", id = 453)
|
@Message(value = "Exception while discovering OSGi service implementations : %s", id = 453)
|
||||||
void unableToDiscoverOsgiService(String service, @Cause Exception e);
|
void unableToDiscoverOsgiService(String service, @Cause Exception e);
|
||||||
|
|
||||||
|
@LogMessage(level = WARN)
|
||||||
|
@Message(value = "The outer-join attribute on <many-to-many> has been deprecated. Instead of outer-join=\"false\", use lazy=\"extra\" with <map>, <set>, <bag>, <idbag>, or <list>, which will only initialize entities (not as a proxy) as needed.", id = 454)
|
||||||
|
void deprecatedManyToManyOuterJoin();
|
||||||
|
|
||||||
|
@LogMessage(level = WARN)
|
||||||
|
@Message(value = "The fetch attribute on <many-to-many> has been deprecated. Instead of fetch=\"select\", use lazy=\"extra\" with <map>, <set>, <bag>, <idbag>, or <list>, which will only initialize entities (not as a proxy) as needed.", id = 455)
|
||||||
|
void deprecatedManyToManyFetch();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -4808,8 +4808,7 @@ public void testTransientOrphanDelete() throws Exception {
|
|||||||
s.close();
|
s.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@TestForIssue( jiraKey = "HHH-8662" )
|
||||||
@FailureExpected( jiraKey = "HHH-8662")
|
|
||||||
public void testProxiesInCollections() throws Exception {
|
public void testProxiesInCollections() throws Exception {
|
||||||
Session s = openSession();
|
Session s = openSession();
|
||||||
s.beginTransaction();
|
s.beginTransaction();
|
||||||
@ -4847,7 +4846,8 @@ public void testProxiesInCollections() throws Exception {
|
|||||||
BarProxy b1 = (BarProxy) i.next();
|
BarProxy b1 = (BarProxy) i.next();
|
||||||
BarProxy b2 = (BarProxy) i.next();
|
BarProxy b2 = (BarProxy) i.next();
|
||||||
assertTrue( ( b1==barprox && !(b2 instanceof HibernateProxy) ) || ( b2==barprox && !(b1 instanceof HibernateProxy) ) ); //one-to-many
|
assertTrue( ( b1==barprox && !(b2 instanceof HibernateProxy) ) || ( b2==barprox && !(b1 instanceof HibernateProxy) ) ); //one-to-many
|
||||||
assertTrue( baz.getFooArray()[0] instanceof HibernateProxy ); //many-to-many
|
// <many-to-many fetch="select" is deprecated by HHH-8662; so baz.getFooArray()[0] should not be a HibernateProxy.
|
||||||
|
assertFalse( baz.getFooArray()[0] instanceof HibernateProxy ); //many-to-many
|
||||||
assertTrue( baz.getFooArray()[1]==bar2prox );
|
assertTrue( baz.getFooArray()[1]==bar2prox );
|
||||||
if ( !isOuterJoinFetchingDisabled() ) assertTrue( !(baz.getFooBag().iterator().next() instanceof HibernateProxy) ); //many-to-many outer-join="true"
|
if ( !isOuterJoinFetchingDisabled() ) assertTrue( !(baz.getFooBag().iterator().next() instanceof HibernateProxy) ); //many-to-many outer-join="true"
|
||||||
assertTrue( !(baz.getFooSet().iterator().next() instanceof HibernateProxy) ); //one-to-many
|
assertTrue( !(baz.getFooSet().iterator().next() instanceof HibernateProxy) ); //one-to-many
|
||||||
|
Loading…
x
Reference in New Issue
Block a user