From c3df793dbeb0edfb2135dae144c0e29f6f2f26cd Mon Sep 17 00:00:00 2001 From: Andrea Boriero Date: Mon, 22 Mar 2021 12:38:00 +0100 Subject: [PATCH] HHH-14509 : Git master -> main branch renaming --- docker_db.sh | 2 +- .../userguide/chapters/osgi/OSGi.adoc | 4 +- .../orm/test/tool/schema/scripts/Dog.java | 10 +- .../orm/test/tool/schema/scripts/Dog.hbm.xml | 2 +- .../orm/test/tool/schema/scripts/dogs.sql | 6 +- .../org/hibernate/test/hql/HQLTest.java | 6 +- .../test/hql/QueryTranslatorTestCase.java | 2 +- .../org/hibernate/test/legacy/FumTest.java | 36 +-- .../test/legacy/QueryByExampleTest.java | 42 +-- ...terDetailTest.java => RootDetailTest.java} | 249 +++++++++--------- .../internal/tools/query/QueryBuilder.java | 2 +- .../hibernate-gradle-plugin.gradle | 4 +- 12 files changed, 179 insertions(+), 186 deletions(-) rename hibernate-core/src/test_legacy/org/hibernate/test/legacy/{MasterDetailTest.java => RootDetailTest.java} (79%) diff --git a/docker_db.sh b/docker_db.sh index 20717cb44c..5abf61fb31 100755 --- a/docker_db.sh +++ b/docker_db.sh @@ -198,7 +198,7 @@ EOF" hana() { temp_dir=$(mktemp -d) - echo '{"master_password" : "H1bernate_test"}' >$temp_dir/password.json + echo '{"main_password" : "H1bernate_test"}' >$temp_dir/password.json chmod 777 -R $temp_dir docker rm -f hana || true docker run -d --name hana -p 39013:39013 -p 39017:39017 -p 39041-39045:39041-39045 -p 1128-1129:1128-1129 -p 59013-59014:59013-59014 \ diff --git a/documentation/src/main/asciidoc/userguide/chapters/osgi/OSGi.adoc b/documentation/src/main/asciidoc/userguide/chapters/osgi/OSGi.adoc index 0df3e9b601..38cfdab9a2 100644 --- a/documentation/src/main/asciidoc/userguide/chapters/osgi/OSGi.adoc +++ b/documentation/src/main/asciidoc/userguide/chapters/osgi/OSGi.adoc @@ -55,7 +55,7 @@ Originally, we intended to include those dependencies within our own `features.x However, after guidance from the Karaf and Aries teams, it was pulled out. This allows Hibernate OSGi to be portable and not be directly tied to Aries versions, instead of having the user choose which to use. -That being said, the QuickStart/Demo projects include a sample https://github.com/hibernate/hibernate-demos/tree/master/hibernate-orm/osgi/managed-jpa/features.xml[features.xml] +That being said, the QuickStart/Demo projects include a sample https://github.com/hibernate/hibernate-demos/tree/main/hibernate-orm/osgi/managed-jpa/features.xml[features.xml] showing which features need to be activated in Karaf in order to support this environment. As mentioned, use this purely as a reference! @@ -183,7 +183,7 @@ include::{sourcedir}/_native/HibernateUtil.java[tag=osgi-discover-SessionFactory === Optional Modules -The https://github.com/hibernate/hibernate-demos/tree/master/hibernate-orm/osgi/unmanaged-native[unmanaged-native] demo project displays the use of optional Hibernate modules. +The https://github.com/hibernate/hibernate-demos/tree/main/hibernate-orm/osgi/unmanaged-native[unmanaged-native] demo project displays the use of optional Hibernate modules. Each module adds additional dependency bundles that must first be activated, either manually or through an additional feature. As of ORM 4.2, Envers is fully supported. Support for C3P0, Proxool, EhCache, and Infinispan were added in 4.3. However, none of their 3rd party libraries currently work in OSGi (lots of `ClassLoader` problems, etc.). diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/tool/schema/scripts/Dog.java b/hibernate-core/src/test/java/org/hibernate/orm/test/tool/schema/scripts/Dog.java index cdb4acc06a..95fdc337ac 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/tool/schema/scripts/Dog.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/tool/schema/scripts/Dog.java @@ -12,7 +12,7 @@ package org.hibernate.orm.test.tool.schema.scripts; */ public class Dog { private Integer id; - private Human master; + private Human owner; public Integer getId() { return id; @@ -22,11 +22,11 @@ public class Dog { this.id = id; } - public Human getMaster() { - return master; + public Human getOwner() { + return owner; } - public void setMaster(Human master) { - this.master = master; + public void setOwner(Human owner) { + this.owner = owner; } } diff --git a/hibernate-core/src/test/resources/org/hibernate/orm/test/tool/schema/scripts/Dog.hbm.xml b/hibernate-core/src/test/resources/org/hibernate/orm/test/tool/schema/scripts/Dog.hbm.xml index 1735f3da2e..6b2c8c51cb 100644 --- a/hibernate-core/src/test/resources/org/hibernate/orm/test/tool/schema/scripts/Dog.hbm.xml +++ b/hibernate-core/src/test/resources/org/hibernate/orm/test/tool/schema/scripts/Dog.hbm.xml @@ -19,6 +19,6 @@ - + diff --git a/hibernate-core/src/test/resources/org/hibernate/orm/test/tool/schema/scripts/dogs.sql b/hibernate-core/src/test/resources/org/hibernate/orm/test/tool/schema/scripts/dogs.sql index bea6b3bcb6..92e08ee255 100644 --- a/hibernate-core/src/test/resources/org/hibernate/orm/test/tool/schema/scripts/dogs.sql +++ b/hibernate-core/src/test/resources/org/hibernate/orm/test/tool/schema/scripts/dogs.sql @@ -2,6 +2,6 @@ INSERT INTO human (id, fname, lname) VALUES (1,'Emmanuel','Bernard') INSERT INTO human (id, fname, lname) VALUES (2,'Gavin','King') INSERT INTO human (id, fname, lname) VALUES (3,'Max','Andersen') -INSERT INTO dog (id, master_fk) VALUES (1,1) -INSERT INTO dog (id, master_fk) VALUES (2,1) -INSERT INTO dog (id, master_fk) VALUES (3,1) \ No newline at end of file +INSERT INTO dog (id, owner_fk) VALUES (1,1) +INSERT INTO dog (id, owner_fk) VALUES (2,1) +INSERT INTO dog (id, owner_fk) VALUES (3,1) \ No newline at end of file diff --git a/hibernate-core/src/test_legacy/org/hibernate/test/hql/HQLTest.java b/hibernate-core/src/test_legacy/org/hibernate/test/hql/HQLTest.java index 56997abb87..6c23f1f5ef 100644 --- a/hibernate-core/src/test_legacy/org/hibernate/test/hql/HQLTest.java +++ b/hibernate-core/src/test_legacy/org/hibernate/test/hql/HQLTest.java @@ -445,8 +445,8 @@ public class HQLTest extends QueryTranslatorTestCase { public void testKeyManyToOneJoin() { //TODO: new parser generates unnecessary joins (though the query results are correct) assertTranslation( "from Order o left join fetch o.lineItems li left join fetch li.product p" ); - assertTranslation( "from Outer o where o.id.master.id.sup.dudu is not null" ); - assertTranslation( "from Outer o where o.id.master.id.sup.dudu is not null" ); + assertTranslation( "from Outer o where o.id.root.id.sup.dudu is not null" ); + assertTranslation( "from Outer o where o.id.root.id.sup.dudu is not null" ); } @Test @@ -670,7 +670,7 @@ public class HQLTest extends QueryTranslatorTestCase { @Test public void testCollectionFetchWithExplicitThetaJoin() { - assertTranslation( "select m from Master m1, Master m left join fetch m.details where m.name=m1.name" ); + assertTranslation( "select m from Root m1, Root m left join fetch m.details where m.name=m1.name" ); } @Test diff --git a/hibernate-core/src/test_legacy/org/hibernate/test/hql/QueryTranslatorTestCase.java b/hibernate-core/src/test_legacy/org/hibernate/test/hql/QueryTranslatorTestCase.java index 4699cf5509..9b6b57955f 100644 --- a/hibernate-core/src/test_legacy/org/hibernate/test/hql/QueryTranslatorTestCase.java +++ b/hibernate-core/src/test_legacy/org/hibernate/test/hql/QueryTranslatorTestCase.java @@ -60,7 +60,7 @@ public abstract class QueryTranslatorTestCase extends BaseCoreFunctionalTestCase "legacy/Holder.hbm.xml", "legacy/Many.hbm.xml", "legacy/Marelo.hbm.xml", - "legacy/MasterDetail.hbm.xml", + "legacy/RootDetail.hbm.xml", "legacy/Middle.hbm.xml", "legacy/Multi.hbm.xml", "legacy/Nameable.hbm.xml", diff --git a/hibernate-core/src/test_legacy/org/hibernate/test/legacy/FumTest.java b/hibernate-core/src/test_legacy/org/hibernate/test/legacy/FumTest.java index 1c70c7a358..fe1651dcda 100644 --- a/hibernate-core/src/test_legacy/org/hibernate/test/legacy/FumTest.java +++ b/hibernate-core/src/test_legacy/org/hibernate/test/legacy/FumTest.java @@ -662,7 +662,7 @@ public class FumTest extends LegacyTestCase { m.setBla("bla"); Outer d = new Outer(); OuterKey did = new OuterKey(); - did.setMaster(m); + did.setRoot(m); did.setDetailId("detail"); d.setId(did); d.setBubu("bubu"); @@ -688,10 +688,10 @@ public class FumTest extends LegacyTestCase { s = openSession(); s.beginTransaction(); d = (Outer) s.load(Outer.class, did); - assertTrue( d.getId().getMaster().getId().getSup().getDudu().equals("dudu") ); + assertTrue( d.getId().getRoot().getId().getSup().getDudu().equals("dudu") ); s.delete(d); - s.delete( d.getId().getMaster() ); - s.save( d.getId().getMaster() ); + s.delete( d.getId().getRoot() ); + s.save( d.getId().getRoot() ); s.save(d); s.getTransaction().commit(); s.close(); @@ -702,29 +702,29 @@ public class FumTest extends LegacyTestCase { .setParameter( 0, d.getId().getDetailId(), StandardBasicTypes.STRING ) .list() .get(0); - s.createQuery( "from Outer o where o.id.master.id.sup.dudu is not null" ).list(); - s.createQuery( "from Outer o where o.id.master.id.sup.id.akey is not null" ).list(); - s.createQuery( "from Inner i where i.backOut.id.master.id.sup.id.akey = i.id.bkey" ).list(); - List l = s.createQuery( "select o.id.master.id.sup.dudu from Outer o where o.id.master.id.sup.dudu is not null" ) + s.createQuery( "from Outer o where o.id.root.id.sup.dudu is not null" ).list(); + s.createQuery( "from Outer o where o.id.root.id.sup.id.akey is not null" ).list(); + s.createQuery( "from Inner i where i.backOut.id.root.id.sup.id.akey = i.id.bkey" ).list(); + List l = s.createQuery( "select o.id.root.id.sup.dudu from Outer o where o.id.root.id.sup.dudu is not null" ) .list(); assertTrue(l.size()==1); - l = s.createQuery( "select o.id.master.id.sup.id.akey from Outer o where o.id.master.id.sup.id.akey is not null" ) + l = s.createQuery( "select o.id.root.id.sup.id.akey from Outer o where o.id.root.id.sup.id.akey is not null" ) .list(); assertTrue(l.size()==1); s.createQuery( - "select i.backOut.id.master.id.sup.id.akey from Inner i where i.backOut.id.master.id.sup.id.akey = i.id.bkey" + "select i.backOut.id.root.id.sup.id.akey from Inner i where i.backOut.id.root.id.sup.id.akey = i.id.bkey" ).list(); - s.createQuery( "from Outer o where o.id.master.bla = ''" ).list(); - s.createQuery( "from Outer o where o.id.master.id.one = ''" ).list(); - s.createQuery( "from Inner inn where inn.id.bkey is not null and inn.backOut.id.master.id.sup.id.akey > 'a'" ) + s.createQuery( "from Outer o where o.id.root.bla = ''" ).list(); + s.createQuery( "from Outer o where o.id.root.id.one = ''" ).list(); + s.createQuery( "from Inner inn where inn.id.bkey is not null and inn.backOut.id.root.id.sup.id.akey > 'a'" ) .list(); - s.createQuery( "from Outer as o left join o.id.master m left join m.id.sup where o.bubu is not null" ).list(); - s.createQuery( "from Outer as o left join o.id.master.id.sup s where o.bubu is not null" ).list(); - s.createQuery( "from Outer as o left join o.id.master m left join o.id.master.id.sup s where o.bubu is not null" ) + s.createQuery( "from Outer as o left join o.id.root m left join m.id.sup where o.bubu is not null" ).list(); + s.createQuery( "from Outer as o left join o.id.root.id.sup s where o.bubu is not null" ).list(); + s.createQuery( "from Outer as o left join o.id.root m left join o.id.root.id.sup s where o.bubu is not null" ) .list(); s.delete(d); - s.delete( d.getId().getMaster() ); - s.delete( d.getId().getMaster().getId().getSup() ); + s.delete( d.getId().getRoot() ); + s.delete( d.getId().getRoot().getId().getSup() ); s.getTransaction().commit(); s.close(); } diff --git a/hibernate-core/src/test_legacy/org/hibernate/test/legacy/QueryByExampleTest.java b/hibernate-core/src/test_legacy/org/hibernate/test/legacy/QueryByExampleTest.java index 064b8f6f23..50f324a2b8 100644 --- a/hibernate-core/src/test_legacy/org/hibernate/test/legacy/QueryByExampleTest.java +++ b/hibernate-core/src/test_legacy/org/hibernate/test/legacy/QueryByExampleTest.java @@ -38,9 +38,9 @@ public class QueryByExampleTest extends LegacyTestCase { Session s = openSession(); Transaction t = s.beginTransaction(); - Componentizable master = getMaster("hibernate", "open sourc%", "open source1"); + Componentizable componentizable = getComponentizeable("hibernate", "open sourc%", "open source1"); Criteria crit = s.createCriteria(Componentizable.class); - Example ex = Example.create(master).enableLike(); + Example ex = Example.create(componentizable).enableLike(); crit.add(ex); List result = crit.list(); assertNotNull(result); @@ -57,9 +57,9 @@ public class QueryByExampleTest extends LegacyTestCase { initData(); Session s = openSession(); Transaction t = s.beginTransaction(); - Componentizable master = getMaster("hibernate", null, "ope%"); + Componentizable componentizable = getComponentizeable("hibernate", null, "ope%"); Criteria crit = s.createCriteria(Componentizable.class); - Example ex = Example.create(master).enableLike(); + Example ex = Example.create(componentizable).enableLike(); crit.add(Restrictions.or(Restrictions.not(ex), ex)); @@ -77,18 +77,18 @@ public class QueryByExampleTest extends LegacyTestCase { initData(); Session s = openSession(); Transaction t = s.beginTransaction(); - Componentizable master = getMaster("hibernate", null, "ope%"); + Componentizable getComponentizeable = getComponentizeable("hibernate", null, "ope%"); Criteria crit = s.createCriteria(Componentizable.class); - Example ex = Example.create(master).enableLike() + Example ex = Example.create(getComponentizeable).enableLike() .excludeProperty("component.subComponent"); crit.add(ex); List result = crit.list(); assertNotNull(result); assertEquals(3, result.size()); - master = getMaster("hibernate", "ORM tool", "fake stuff"); + getComponentizeable = getComponentizeable("hibernate", "ORM tool", "fake stuff"); crit = s.createCriteria(Componentizable.class); - ex = Example.create(master).enableLike() + ex = Example.create(getComponentizeable).enableLike() .excludeProperty("component.subComponent.subName1"); crit.add(ex); result = crit.list(); @@ -103,12 +103,12 @@ public class QueryByExampleTest extends LegacyTestCase { private void initData() throws Exception { Session s = openSession(); Transaction t = s.beginTransaction(); - Componentizable master = getMaster("hibernate", "ORM tool", "ORM tool1"); - s.saveOrUpdate(master); - master = getMaster("hibernate", "open source", "open source1"); - s.saveOrUpdate(master); - master = getMaster("hibernate", null, null); - s.saveOrUpdate(master); + Componentizable getComponentizeable = getComponentizeable("hibernate", "ORM tool", "ORM tool1"); + s.saveOrUpdate(getComponentizeable); + getComponentizeable = getComponentizeable("hibernate", "open source", "open source1"); + s.saveOrUpdate(getComponentizeable); + getComponentizeable = getComponentizeable("hibernate", null, null); + s.saveOrUpdate(getComponentizeable); t.commit(); s.close(); } @@ -123,19 +123,19 @@ public class QueryByExampleTest extends LegacyTestCase { s.close(); } - private Componentizable getMaster(String name, String subname, String subname1) { - Componentizable master = new Componentizable(); + private Componentizable getComponentizeable(String name, String subname, String subname1) { + Componentizable getComponentizeable = new Componentizable(); if (name != null) { - Component masterComp = new Component(); - masterComp.setName(name); + Component component = new Component(); + component.setName(name); if (subname != null || subname1 != null) { SubComponent subComponent = new SubComponent(); subComponent.setSubName(subname); subComponent.setSubName1(subname1); - masterComp.setSubComponent(subComponent); + component.setSubComponent(subComponent); } - master.setComponent(masterComp); + getComponentizeable.setComponent(component); } - return master; + return getComponentizeable; } } diff --git a/hibernate-core/src/test_legacy/org/hibernate/test/legacy/MasterDetailTest.java b/hibernate-core/src/test_legacy/org/hibernate/test/legacy/RootDetailTest.java similarity index 79% rename from hibernate-core/src/test_legacy/org/hibernate/test/legacy/MasterDetailTest.java rename to hibernate-core/src/test_legacy/org/hibernate/test/legacy/RootDetailTest.java index f0f51fe75f..931ce1ef55 100644 --- a/hibernate-core/src/test_legacy/org/hibernate/test/legacy/MasterDetailTest.java +++ b/hibernate-core/src/test_legacy/org/hibernate/test/legacy/RootDetailTest.java @@ -9,12 +9,17 @@ package org.hibernate.test.legacy; import java.io.Serializable; import java.sql.Connection; import java.sql.SQLException; -import java.util.*; +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; +import java.util.Properties; import org.hibernate.Hibernate; import org.hibernate.LockMode; import org.hibernate.ObjectNotFoundException; -import org.hibernate.query.Query; +import org.hibernate.Query; import org.hibernate.Session; import org.hibernate.Transaction; import org.hibernate.cfg.Configuration; @@ -23,13 +28,13 @@ import org.hibernate.criterion.Example; import org.hibernate.criterion.Restrictions; import org.hibernate.dialect.AbstractHANADialect; import org.hibernate.dialect.HSQLDialect; -import org.hibernate.dialect.MckoiDialect; import org.hibernate.dialect.MySQLDialect; import org.hibernate.dialect.SAPDBDialect; -import org.hibernate.dialect.CockroachDialect; +import org.hibernate.dialect.TimesTenDialect; import org.hibernate.engine.jdbc.connections.spi.JdbcConnectionAccess; import org.hibernate.engine.jdbc.spi.JdbcServices; import org.hibernate.jdbc.AbstractWork; + import org.hibernate.testing.SkipForDialect; import org.hibernate.testing.SkipLog; import org.junit.Test; @@ -39,11 +44,11 @@ import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; -public class MasterDetailTest extends LegacyTestCase { +public class RootDetailTest extends LegacyTestCase { @Override public String[] getMappings() { return new String[] { - "legacy/MasterDetail.hbm.xml", + "legacy/RootDetail.hbm.xml", "legacy/Custom.hbm.xml", "legacy/Category.hbm.xml", "legacy/Nameable.hbm.xml", @@ -92,15 +97,6 @@ public class MasterDetailTest extends LegacyTestCase { s.close(); } -// @Test -// public void testMeta() throws Exception { -// PersistentClass clazz = configuration().getClassMapping( Master.class.getName() ); -// MetaAttribute meta = clazz.getMetaAttribute("foo"); -// assertTrue( "foo".equals( meta.getValue() ) ); -// meta = clazz.getProperty("name").getMetaAttribute("bar"); -// assertTrue( meta.isMultiValued() ); -// } - @Test @SuppressWarnings( {"unchecked"}) public void testCopy() throws Exception { @@ -197,23 +193,23 @@ public class MasterDetailTest extends LegacyTestCase { } @Test - @SkipForDialect(value = CockroachDialect.class, comment = "https://github.com/cockroachdb/cockroach/issues/27871") + @SkipForDialect(value = CockroachDB192Dialect.class, comment = "https://github.com/cockroachdb/cockroach/issues/27871") public void testSelfManyToOne() throws Exception { Session s = openSession(); Transaction t = s.beginTransaction(); - Master m = new Master(); - m.setOtherMaster(m); + Root m = new Root(); + m.setOtherRoot(m); s.save(m); t.commit(); s.close(); s = openSession(); t = s.beginTransaction(); - Iterator i = s.createQuery( "from Master" ).iterate(); - m = (Master) i.next(); - assertTrue( m.getOtherMaster()==m ); + Iterator i = s.createQuery( "from Root" ).iterate(); + m = (Root) i.next(); + assertTrue( m.getOtherRoot()==m ); if ( getDialect() instanceof HSQLDialect || getDialect() instanceof MySQLDialect ) { - m.setOtherMaster(null); + m.setOtherRoot(null); s.flush(); } s.delete(m); @@ -222,45 +218,45 @@ public class MasterDetailTest extends LegacyTestCase { } @Test - @SkipForDialect(value = CockroachDialect.class, comment = "https://github.com/cockroachdb/cockroach/issues/27871") + @SkipForDialect(value = CockroachDB192Dialect.class, comment = "https://github.com/cockroachdb/cockroach/issues/27871") public void testExample() throws Exception { Session s = openSession(); Transaction t = s.beginTransaction(); - Master m = new Master(); + Root m = new Root(); m.setName("name"); m.setX(5); - m.setOtherMaster(m); + m.setOtherRoot(m); s.save(m); t.commit(); s.close(); s = openSession(); t = s.beginTransaction(); - Master m1 = (Master) s.createCriteria(Master.class) + Root m1 = (Root) s.createCriteria( Root.class) .add( Example.create(m).enableLike().ignoreCase().excludeProperty("bigDecimal") ) .uniqueResult(); - assertTrue( m1.getOtherMaster()==m1 ); - m1 = (Master) s.createCriteria(Master.class) + assertTrue( m1.getOtherRoot()==m1 ); + m1 = (Root) s.createCriteria( Root.class) .add( Restrictions.eq("name", "foobar") ) .uniqueResult(); assertTrue( m1==null ); - m1 = (Master) s.createCriteria(Master.class) + m1 = (Root) s.createCriteria( Root.class) .add( Example.create(m).excludeProperty("bigDecimal") ) - .createCriteria("otherMaster") + .createCriteria("otherRoot") .add( Example.create(m).excludeZeroes().excludeProperty("bigDecimal") ) .uniqueResult(); - assertTrue( m1.getOtherMaster()==m1 ); - Master m2 = (Master) s.createCriteria(Master.class) + assertTrue( m1.getOtherRoot()==m1 ); + Root m2 = (Root) s.createCriteria( Root.class) .add( Example.create(m).excludeNone().excludeProperty("bigDecimal") ) .uniqueResult(); assertTrue( m2==m1 ); m.setName(null); - m2 = (Master) s.createCriteria(Master.class) + m2 = (Root) s.createCriteria( Root.class) .add( Example.create(m).excludeNone().excludeProperty("bigDecimal") ) .uniqueResult(); assertTrue( null == m2 ); if (getDialect() instanceof HSQLDialect || getDialect() instanceof MySQLDialect) { - m1.setOtherMaster(null); + m1.setOtherRoot(null); s.flush(); } s.delete(m1); @@ -312,39 +308,39 @@ public class MasterDetailTest extends LegacyTestCase { Session s = openSession(); Transaction t = s.beginTransaction(); if ( !(getDialect() instanceof MySQLDialect) && !(getDialect() instanceof SAPDBDialect) && !(getDialect() instanceof MckoiDialect) ) { - s.createQuery( "FROM Master m WHERE NOT EXISTS ( FROM m.details d WHERE NOT d.i=5 )" ).iterate(); - s.createQuery( "FROM Master m WHERE NOT 5 IN ( SELECT d.i FROM m.details AS d )" ).iterate(); + s.createQuery( "FROM Root m WHERE NOT EXISTS ( FROM m.details d WHERE NOT d.i=5 )" ).iterate(); + s.createQuery( "FROM Root m WHERE NOT 5 IN ( SELECT d.i FROM m.details AS d )" ).iterate(); } - s.createQuery( "SELECT m FROM Master m JOIN m.details d WHERE d.i=5" ).iterate(); - s.createQuery( "SELECT m FROM Master m JOIN m.details d WHERE d.i=5" ).list(); - s.createQuery( "SELECT m.id FROM Master AS m JOIN m.details AS d WHERE d.i=5" ).list(); + s.createQuery( "SELECT m FROM Root m JOIN m.details d WHERE d.i=5" ).iterate(); + s.createQuery( "SELECT m FROM Root m JOIN m.details d WHERE d.i=5" ).list(); + s.createQuery( "SELECT m.id FROM Root AS m JOIN m.details AS d WHERE d.i=5" ).list(); t.commit(); s.close(); } @Test - public void testMasterDetail() throws Exception { + public void tesRootDetail() throws Exception { if (getDialect() instanceof HSQLDialect) return; Session s = openSession(); Transaction t = s.beginTransaction(); - Master master = new Master(); - assertTrue( "save returned native id", s.save(master)!=null ); - Serializable mid = s.getIdentifier(master); + Root root = new Root(); + assertTrue( "save returned native id", s.save( root )!=null ); + Serializable mid = s.getIdentifier( root ); Detail d1 = new Detail(); - d1.setMaster(master); + d1.setRoot( root ); Serializable did = s.save(d1); Detail d2 = new Detail(); d2.setI(12); - d2.setMaster(master); + d2.setRoot( root ); assertTrue( "generated id returned", s.save(d2)!=null); - master.addDetail(d1); - master.addDetail(d2); - if ( !(getDialect() instanceof MySQLDialect) && !(getDialect() instanceof SAPDBDialect) && !(getDialect() instanceof MckoiDialect) && !(getDialect() instanceof org.hibernate.dialect.TimesTenDialect)) { + root.addDetail(d1); + root.addDetail(d2); + if ( !(getDialect() instanceof MySQLDialect) && !(getDialect() instanceof SAPDBDialect) && !(getDialect() instanceof MckoiDialect) && !(getDialect() instanceof TimesTenDialect)) { assertTrue( "query", s.createQuery( - "from Detail d, Master m where m = d.master and size(m.outgoing) = 0 and size(m.incoming) = 0" + "from Detail d, Root m where m = d.root and size(m.outgoing) = 0 and size(m.incoming) = 0" ).list().size()==2 ); } @@ -353,42 +349,42 @@ public class MasterDetailTest extends LegacyTestCase { s = openSession(); t = s.beginTransaction(); - master = new Master(); - s.load(master, mid); - assertTrue( master.getDetails().size()==2 ); + root = new Root(); + s.load( root, mid); + assertTrue( root.getDetails().size()==2 ); t.commit(); s.close(); s = openSession(); t = s.beginTransaction(); - master = (Master) s.load(Master.class, mid); - Iterator iter = master.getDetails().iterator(); + root = (Root) s.load( Root.class, mid); + Iterator iter = root.getDetails().iterator(); int i=0; while ( iter.hasNext() ) { Detail d = (Detail) iter.next(); - assertTrue( "master-detail", d.getMaster()==master ); + assertTrue( "root-detail", d.getRoot()== root ); i++; } - assertTrue( "master-detail", i==2 ); + assertTrue( "root-detail", i==2 ); t.commit(); s.close(); s = openSession(); t = s.beginTransaction(); - assertTrue( s.createQuery( "select elements(master.details) from Master master" ).list().size()==2 ); + assertTrue( s.createQuery( "select elements(root.details) from Root root" ).list().size()==2 ); t.commit(); s.close(); s = openSession(); t = s.beginTransaction(); - List list = s.createQuery( "from Master m left join fetch m.details" ).list(); - Master m = (Master) list.get(0); + List list = s.createQuery( "from Root m left join fetch m.details" ).list(); + Root m = (Root) list.get(0); assertTrue( Hibernate.isInitialized( m.getDetails() ) ); assertTrue( m.getDetails().size()==2 ); - list = s.createQuery( "from Detail d inner join fetch d.master" ).list(); + list = s.createQuery( "from Detail d inner join fetch d.root" ).list(); Detail dt = (Detail) list.get(0); Serializable dtid = s.getIdentifier(dt); - assertTrue( dt.getMaster()==m ); + assertTrue( dt.getRoot()==m ); //assertTrue(m.getAllDetails().size()==2); @@ -397,25 +393,22 @@ public class MasterDetailTest extends LegacyTestCase { s = openSession(); t = s.beginTransaction(); - list = s.createQuery( "select m from Master m1, Master m left join fetch m.details where m.name=m1.name" ) + list = s.createQuery( "select m from Root m1, Root m left join fetch m.details where m.name=m1.name" ) .list(); - assertTrue( Hibernate.isInitialized( ( (Master) list.get(0) ).getDetails() ) ); + assertTrue( Hibernate.isInitialized( ( (Root) list.get(0) ).getDetails() ) ); dt = (Detail) s.load(Detail.class, dtid); - assertTrue( ( (Master) list.get(0) ).getDetails().contains(dt) ); + assertTrue( ( (Root) list.get(0) ).getDetails().contains(dt) ); t.commit(); s.close(); s = openSession(); t = s.beginTransaction(); list = s.createQuery( - "select m, m1.name from Master m1, Master m left join fetch m.details where m.name=m1.name" + "select m, m1.name from Root m1, Root m left join fetch m.details where m.name=m1.name" ).list(); - assertTrue( Hibernate.isInitialized( ( (Master) ( (Object[]) list.get(0) )[0] ).getDetails() ) ); + assertTrue( Hibernate.isInitialized( ( (Root) ( (Object[]) list.get(0) )[0] ).getDetails() ) ); dt = (Detail) s.load(Detail.class, dtid); - assertTrue( ( (Master) ( (Object[]) list.get(0) )[0] ).getDetails().contains(dt) ); - //list = s.find("select m from Master m, Master m2 left join fetch m.details"); -// depracted syntax -// list = s.find("select m.id from Master m inner join fetch m.details"); + assertTrue( ( (Root) ( (Object[]) list.get(0) )[0] ).getDetails().contains(dt) ); t.commit(); s.close(); @@ -423,14 +416,14 @@ public class MasterDetailTest extends LegacyTestCase { s = openSession(); t = s.beginTransaction(); Detail dd = (Detail) s.load(Detail.class, did); - master = dd.getMaster(); - assertTrue( "detail-master", master.getDetails().contains(dd) ); - assertTrue( s.createFilter( master.getDetails(), "order by this.i desc" ).list().size()==2 ); - assertTrue( s.createFilter( master.getDetails(), "select this where this.id > -1" ).list().size()==2 ); - Query q = s.createFilter( master.getDetails(), "where this.id > :id" ); + root = dd.getRoot(); + assertTrue( "detail-root", root.getDetails().contains(dd) ); + assertTrue( s.createFilter( root.getDetails(), "order by this.i desc" ).list().size()==2 ); + assertTrue( s.createFilter( root.getDetails(), "select this where this.id > -1" ).list().size()==2 ); + Query q = s.createFilter( root.getDetails(), "where this.id > :id" ); q.setInteger("id", -1); assertTrue( q.list().size()==2 ); - q = s.createFilter( master.getDetails(), "where this.id > :id1 and this.id < :id2" ); + q = s.createFilter( root.getDetails(), "where this.id > :id1 and this.id < :id2" ); q.setInteger("id1", -1); q.setInteger("id2", 99999999); assertTrue( q.list().size()==2 ); @@ -441,38 +434,38 @@ public class MasterDetailTest extends LegacyTestCase { list.add(did); list.add( new Long(-1) ); - q = s.createFilter( master.getDetails(), "where this.id in (:ids)" ); + q = s.createFilter( root.getDetails(), "where this.id in (:ids)" ); q.setParameterList("ids", list); assertTrue( q.list().size()==1 ); - q = s.createFilter( master.getDetails(), "where this.id in (:ids)" ); + q = s.createFilter( root.getDetails(), "where this.id in (:ids)" ); q.setParameterList("ids", list); assertTrue( q.iterate().hasNext() ); - assertTrue( s.createFilter( master.getDetails(), "where this.id > -1" ).list().size()==2 ); - assertTrue( s.createFilter( master.getDetails(), "select this.master where this.id > -1" ).list().size()==2 ); + assertTrue( s.createFilter( root.getDetails(), "where this.id > -1" ).list().size()==2 ); + assertTrue( s.createFilter( root.getDetails(), "select this.root where this.id > -1" ).list().size()==2 ); assertTrue( - s.createFilter( master.getDetails(), "select m from Master m where this.id > -1 and this.master=m" ) + s.createFilter( root.getDetails(), "select m from Root m where this.id > -1 and this.root=m" ) .list() .size()==2 ); - assertTrue( s.createFilter( master.getIncoming(), "where this.id > -1 and this.name is not null" ).list().size()==0 ); + assertTrue( s.createFilter( root.getIncoming(), "where this.id > -1 and this.name is not null" ).list().size()==0 ); - assertTrue( s.createFilter( master.getDetails(), "select max(this.i)" ).iterate().next() instanceof Integer ); - assertTrue( s.createFilter( master.getDetails(), "select max(this.i) group by this.id" ).iterate().next() instanceof Integer ); - assertTrue( s.createFilter( master.getDetails(), "select count(*)" ).iterate().next() instanceof Long ); + assertTrue( s.createFilter( root.getDetails(), "select max(this.i)" ).iterate().next() instanceof Integer ); + assertTrue( s.createFilter( root.getDetails(), "select max(this.i) group by this.id" ).iterate().next() instanceof Integer ); + assertTrue( s.createFilter( root.getDetails(), "select count(*)" ).iterate().next() instanceof Long ); - assertTrue( s.createFilter( master.getDetails(), "select this.master" ).list().size()==2 ); - assertTrue( s.createFilter( master.getMoreDetails(), "" ).list().size()==0 ); - assertTrue( s.createFilter( master.getIncoming(), "" ).list().size()==0 ); + assertTrue( s.createFilter( root.getDetails(), "select this.root" ).list().size()==2 ); + assertTrue( s.createFilter( root.getMoreDetails(), "" ).list().size()==0 ); + assertTrue( s.createFilter( root.getIncoming(), "" ).list().size()==0 ); - Query f = s.createFilter( master.getDetails(), "select max(this.i) where this.i < :top and this.i>=:bottom" ); + Query f = s.createFilter( root.getDetails(), "select max(this.i) where this.i < :top and this.i>=:bottom" ); f.setInteger("top", 100); f.setInteger("bottom", 0); assertEquals( f.iterate().next(), new Integer(12) ); f.setInteger("top", 2); assertEquals( f.iterate().next(), new Integer(0) ); - f = s.createFilter( master.getDetails(), "select max(this.i) where this.i not in (:list)" ); + f = s.createFilter( root.getDetails(), "select max(this.i) where this.i not in (:list)" ); Collection coll = new ArrayList(); coll.add( new Integer(-666) ); coll.add( new Integer(22) ); @@ -480,21 +473,21 @@ public class MasterDetailTest extends LegacyTestCase { f.setParameterList("list", coll); assertEquals( f.iterate().next(), new Integer(12) ); - f = s.createFilter( master.getDetails(), "select max(this.i) where this.i not in (:list) and this.master.name = :listy2" ); + f = s.createFilter( root.getDetails(), "select max(this.i) where this.i not in (:list) and this.root.name = :listy2" ); f.setParameterList("list", coll); - f.setParameter( "listy2", master.getName() ); + f.setParameter( "listy2", root.getName() ); assertEquals( f.iterate().next(), new Integer(12) ); - iter = master.getDetails().iterator(); + iter = root.getDetails().iterator(); i=0; while ( iter.hasNext() ) { Detail d = (Detail) iter.next(); - assertTrue( "master-detail", d.getMaster()==master ); + assertTrue( "root-detail", d.getRoot()== root ); s.delete(d); i++; } - assertTrue( "master-detail", i==2 ); - s.delete(master); + assertTrue( "root-detail", i==2 ); + s.delete( root ); t.commit(); s.close(); } @@ -503,19 +496,19 @@ public class MasterDetailTest extends LegacyTestCase { public void testIncomingOutgoing() throws Exception { Session s = openSession(); s.beginTransaction(); - Master master1 = new Master(); - Master master2 = new Master(); - Master master3 = new Master(); - s.save(master1); - s.save(master2); - s.save(master3); - master1.addIncoming(master2); - master2.addOutgoing(master1); - master1.addIncoming(master3); - master3.addOutgoing(master1); - Serializable m1id = s.getIdentifier(master1); + Root root1 = new Root(); + Root root2 = new Root(); + Root root3 = new Root(); + s.save( root1 ); + s.save( root2 ); + s.save( root3 ); + root1.addIncoming( root2 ); + root2.addOutgoing( root1 ); + root1.addIncoming( root3 ); + root3.addOutgoing( root1 ); + Serializable m1id = s.getIdentifier( root1 ); assertTrue( - s.createFilter( master1.getIncoming(), "where this.id > 0 and this.name is not null" ) + s.createFilter( root1.getIncoming(), "where this.id > 0 and this.name is not null" ) .list() .size() == 2 ); @@ -524,18 +517,18 @@ public class MasterDetailTest extends LegacyTestCase { s = openSession(); s.beginTransaction(); - master1 = (Master) s.load(Master.class, m1id); - Iterator iter = master1.getIncoming().iterator(); + root1 = (Root) s.load( Root.class, m1id); + Iterator iter = root1.getIncoming().iterator(); int i=0; while ( iter.hasNext() ) { - Master m = (Master) iter.next(); + Root m = (Root) iter.next(); assertTrue( "outgoing", m.getOutgoing().size()==1 ); - assertTrue( "outgoing", m.getOutgoing().contains(master1) ); + assertTrue( "outgoing", m.getOutgoing().contains( root1 ) ); s.delete(m); i++; } assertTrue( "incoming-outgoing", i == 2 ); - s.delete( master1 ); + s.delete( root1 ); s.getTransaction().commit(); s.close(); } @@ -547,11 +540,11 @@ public class MasterDetailTest extends LegacyTestCase { Detail d1 = new Detail(); Detail d2 = new Detail(); d2.setI(22); - Master m = new Master(); - Master m0 = new Master(); + Root m = new Root(); + Root m0 = new Root(); Serializable m0id = s.save(m0); m0.addDetail(d1); m0.addDetail(d2); - d1.setMaster(m0); d2.setMaster(m0); + d1.setRoot(m0); d2.setRoot(m0); m.getMoreDetails().add(d1); m.getMoreDetails().add(d2); Serializable mid = s.save(m); @@ -560,11 +553,11 @@ public class MasterDetailTest extends LegacyTestCase { s = openSession(); s.beginTransaction(); - m = (Master) s.load(Master.class, mid); + m = (Root) s.load( Root.class, mid); assertTrue( "cascade save", m.getMoreDetails().size()==2 ); - assertTrue( "cascade save", ( (Detail) m.getMoreDetails().iterator().next() ).getMaster().getDetails().size()==2 ); + assertTrue( "cascade save", ( (Detail) m.getMoreDetails().iterator().next() ).getRoot().getDetails().size()==2 ); s.delete( m ); - s.delete( s.load( Master.class, m0id ) ); + s.delete( s.load( Root.class, m0id ) ); s.getTransaction().commit(); s.close(); } @@ -583,13 +576,13 @@ public class MasterDetailTest extends LegacyTestCase { public void testUpdateLazyCollections() throws Exception { Session s = openSession(); s.beginTransaction(); - Master m = new Master(); + Root m = new Root(); s.save( m ); Detail d1 = new Detail(); Detail d2 = new Detail(); d2.setX( 14 ); - d1.setMaster( m ); - d2.setMaster( m ); + d1.setRoot( m ); + d2.setRoot( m ); s.save( d1 ); s.save( d2 ); m.addDetail( d1 ); @@ -599,7 +592,7 @@ public class MasterDetailTest extends LegacyTestCase { s = openSession(); s.beginTransaction(); - m = (Master) s.load( Master.class, m.getId() ); + m = (Root) s.load( Root.class, m.getId() ); s.getTransaction().commit(); s.close(); m.setName("New Name"); @@ -627,11 +620,11 @@ public class MasterDetailTest extends LegacyTestCase { Transaction txn = s.beginTransaction(); Detail detail = new Detail(); SubDetail subdetail = new SubDetail(); - Master m = new Master(); - Master m0 = new Master(); + Root m = new Root(); + Root m0 = new Root(); Serializable m0id = s.save(m0); m0.addDetail(detail); - detail.setMaster(m0); + detail.setRoot(m0); m.getMoreDetails().add(detail); detail.setSubDetails( new HashSet() ); detail.getSubDetails().add(subdetail); @@ -641,12 +634,12 @@ public class MasterDetailTest extends LegacyTestCase { s = openSession(); txn = s.beginTransaction(); - m = (Master) s.load( Master.class, mid ); + m = (Root) s.load( Root.class, mid ); assertTrue( ( (Detail) m.getMoreDetails().iterator().next() ).getSubDetails().size()!=0 ); s.delete(m); assertTrue( s.createQuery( "from SubDetail" ).list().size()==0 ); assertTrue( s.createQuery( "from Detail d" ).list().size()==0 ); - s.delete( s.load(Master.class, m0id) ); + s.delete( s.load( Root.class, m0id) ); txn.commit(); s.close(); } diff --git a/hibernate-envers/src/main/java/org/hibernate/envers/internal/tools/query/QueryBuilder.java b/hibernate-envers/src/main/java/org/hibernate/envers/internal/tools/query/QueryBuilder.java index b5a3b2377b..d84df9c522 100644 --- a/hibernate-envers/src/main/java/org/hibernate/envers/internal/tools/query/QueryBuilder.java +++ b/hibernate-envers/src/main/java/org/hibernate/envers/internal/tools/query/QueryBuilder.java @@ -247,7 +247,7 @@ public class QueryBuilder { StringTools.append( sb, getOrderList().iterator(), ", " ); } else if ( !orderFragments.isEmpty() ) { - // todo (6.0) : How to backport HHH-12992 to use Template#translateOrderBy from master? + // todo (6.0) : How to backport HHH-12992 to use Template#translateOrderBy from main? throw new NotYetImplementedFor6Exception( getClass() ); // sb.append( " order by " ); diff --git a/tooling/hibernate-gradle-plugin/hibernate-gradle-plugin.gradle b/tooling/hibernate-gradle-plugin/hibernate-gradle-plugin.gradle index e01636c6f0..6b922c72ee 100644 --- a/tooling/hibernate-gradle-plugin/hibernate-gradle-plugin.gradle +++ b/tooling/hibernate-gradle-plugin/hibernate-gradle-plugin.gradle @@ -62,8 +62,8 @@ gradlePlugin { } pluginBundle { - website = 'https://github.com/hibernate/hibernate-orm/tree/master/tooling/hibernate-gradle-plugin' - vcsUrl = 'https://github.com/hibernate/hibernate-orm/tree/master/tooling/hibernate-gradle-plugin' + website = 'https://github.com/hibernate/hibernate-orm/tree/main/tooling/hibernate-gradle-plugin' + vcsUrl = 'https://github.com/hibernate/hibernate-orm/tree/main/tooling/hibernate-gradle-plugin' tags = ['hibernate','orm','bytecode','enhancement','bytebuddy'] plugins {