HHH-14509 : Git master -> main branch renaming
This commit is contained in:
parent
96d103215c
commit
c3df793dbe
|
@ -198,7 +198,7 @@ EOF"
|
||||||
|
|
||||||
hana() {
|
hana() {
|
||||||
temp_dir=$(mktemp -d)
|
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
|
chmod 777 -R $temp_dir
|
||||||
docker rm -f hana || true
|
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 \
|
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 \
|
||||||
|
|
|
@ -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.
|
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.
|
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.
|
showing which features need to be activated in Karaf in order to support this environment.
|
||||||
As mentioned, use this purely as a reference!
|
As mentioned, use this purely as a reference!
|
||||||
|
|
||||||
|
@ -183,7 +183,7 @@ include::{sourcedir}/_native/HibernateUtil.java[tag=osgi-discover-SessionFactory
|
||||||
|
|
||||||
=== Optional Modules
|
=== 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.
|
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.
|
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.).
|
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.).
|
||||||
|
|
|
@ -12,7 +12,7 @@ package org.hibernate.orm.test.tool.schema.scripts;
|
||||||
*/
|
*/
|
||||||
public class Dog {
|
public class Dog {
|
||||||
private Integer id;
|
private Integer id;
|
||||||
private Human master;
|
private Human owner;
|
||||||
|
|
||||||
public Integer getId() {
|
public Integer getId() {
|
||||||
return id;
|
return id;
|
||||||
|
@ -22,11 +22,11 @@ public class Dog {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Human getMaster() {
|
public Human getOwner() {
|
||||||
return master;
|
return owner;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setMaster(Human master) {
|
public void setOwner(Human owner) {
|
||||||
this.master = master;
|
this.owner = owner;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,6 +19,6 @@
|
||||||
<hibernate-mapping package="org.hibernate.orm.test.tool.schema.scripts">
|
<hibernate-mapping package="org.hibernate.orm.test.tool.schema.scripts">
|
||||||
<class name="Dog" table="dog">
|
<class name="Dog" table="dog">
|
||||||
<id name="id"/>
|
<id name="id"/>
|
||||||
<many-to-one name="master" column="master_fk"/>
|
<many-to-one name="owner" column="owner_fk"/>
|
||||||
</class>
|
</class>
|
||||||
</hibernate-mapping>
|
</hibernate-mapping>
|
||||||
|
|
|
@ -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 (2,'Gavin','King')
|
||||||
INSERT INTO human (id, fname, lname) VALUES (3,'Max','Andersen')
|
INSERT INTO human (id, fname, lname) VALUES (3,'Max','Andersen')
|
||||||
|
|
||||||
INSERT INTO dog (id, master_fk) VALUES (1,1)
|
INSERT INTO dog (id, owner_fk) VALUES (1,1)
|
||||||
INSERT INTO dog (id, master_fk) VALUES (2,1)
|
INSERT INTO dog (id, owner_fk) VALUES (2,1)
|
||||||
INSERT INTO dog (id, master_fk) VALUES (3,1)
|
INSERT INTO dog (id, owner_fk) VALUES (3,1)
|
|
@ -445,8 +445,8 @@ public class HQLTest extends QueryTranslatorTestCase {
|
||||||
public void testKeyManyToOneJoin() {
|
public void testKeyManyToOneJoin() {
|
||||||
//TODO: new parser generates unnecessary joins (though the query results are correct)
|
//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 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.root.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" );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -670,7 +670,7 @@ public class HQLTest extends QueryTranslatorTestCase {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testCollectionFetchWithExplicitThetaJoin() {
|
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
|
@Test
|
||||||
|
|
|
@ -60,7 +60,7 @@ public abstract class QueryTranslatorTestCase extends BaseCoreFunctionalTestCase
|
||||||
"legacy/Holder.hbm.xml",
|
"legacy/Holder.hbm.xml",
|
||||||
"legacy/Many.hbm.xml",
|
"legacy/Many.hbm.xml",
|
||||||
"legacy/Marelo.hbm.xml",
|
"legacy/Marelo.hbm.xml",
|
||||||
"legacy/MasterDetail.hbm.xml",
|
"legacy/RootDetail.hbm.xml",
|
||||||
"legacy/Middle.hbm.xml",
|
"legacy/Middle.hbm.xml",
|
||||||
"legacy/Multi.hbm.xml",
|
"legacy/Multi.hbm.xml",
|
||||||
"legacy/Nameable.hbm.xml",
|
"legacy/Nameable.hbm.xml",
|
||||||
|
|
|
@ -662,7 +662,7 @@ public class FumTest extends LegacyTestCase {
|
||||||
m.setBla("bla");
|
m.setBla("bla");
|
||||||
Outer d = new Outer();
|
Outer d = new Outer();
|
||||||
OuterKey did = new OuterKey();
|
OuterKey did = new OuterKey();
|
||||||
did.setMaster(m);
|
did.setRoot(m);
|
||||||
did.setDetailId("detail");
|
did.setDetailId("detail");
|
||||||
d.setId(did);
|
d.setId(did);
|
||||||
d.setBubu("bubu");
|
d.setBubu("bubu");
|
||||||
|
@ -688,10 +688,10 @@ public class FumTest extends LegacyTestCase {
|
||||||
s = openSession();
|
s = openSession();
|
||||||
s.beginTransaction();
|
s.beginTransaction();
|
||||||
d = (Outer) s.load(Outer.class, did);
|
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);
|
||||||
s.delete( d.getId().getMaster() );
|
s.delete( d.getId().getRoot() );
|
||||||
s.save( d.getId().getMaster() );
|
s.save( d.getId().getRoot() );
|
||||||
s.save(d);
|
s.save(d);
|
||||||
s.getTransaction().commit();
|
s.getTransaction().commit();
|
||||||
s.close();
|
s.close();
|
||||||
|
@ -702,29 +702,29 @@ public class FumTest extends LegacyTestCase {
|
||||||
.setParameter( 0, d.getId().getDetailId(), StandardBasicTypes.STRING )
|
.setParameter( 0, d.getId().getDetailId(), StandardBasicTypes.STRING )
|
||||||
.list()
|
.list()
|
||||||
.get(0);
|
.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.root.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 Outer o where o.id.root.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();
|
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.master.id.sup.dudu from Outer o where o.id.master.id.sup.dudu is not null" )
|
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();
|
.list();
|
||||||
assertTrue(l.size()==1);
|
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();
|
.list();
|
||||||
assertTrue(l.size()==1);
|
assertTrue(l.size()==1);
|
||||||
s.createQuery(
|
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();
|
).list();
|
||||||
s.createQuery( "from Outer o where o.id.master.bla = ''" ).list();
|
s.createQuery( "from Outer o where o.id.root.bla = ''" ).list();
|
||||||
s.createQuery( "from Outer o where o.id.master.id.one = ''" ).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.master.id.sup.id.akey > 'a'" )
|
s.createQuery( "from Inner inn where inn.id.bkey is not null and inn.backOut.id.root.id.sup.id.akey > 'a'" )
|
||||||
.list();
|
.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.root 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.root.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 o.id.root.id.sup s where o.bubu is not null" )
|
||||||
.list();
|
.list();
|
||||||
s.delete(d);
|
s.delete(d);
|
||||||
s.delete( d.getId().getMaster() );
|
s.delete( d.getId().getRoot() );
|
||||||
s.delete( d.getId().getMaster().getId().getSup() );
|
s.delete( d.getId().getRoot().getId().getSup() );
|
||||||
s.getTransaction().commit();
|
s.getTransaction().commit();
|
||||||
s.close();
|
s.close();
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,9 +38,9 @@ public class QueryByExampleTest extends LegacyTestCase {
|
||||||
Session s = openSession();
|
Session s = openSession();
|
||||||
|
|
||||||
Transaction t = s.beginTransaction();
|
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);
|
Criteria crit = s.createCriteria(Componentizable.class);
|
||||||
Example ex = Example.create(master).enableLike();
|
Example ex = Example.create(componentizable).enableLike();
|
||||||
crit.add(ex);
|
crit.add(ex);
|
||||||
List result = crit.list();
|
List result = crit.list();
|
||||||
assertNotNull(result);
|
assertNotNull(result);
|
||||||
|
@ -57,9 +57,9 @@ public class QueryByExampleTest extends LegacyTestCase {
|
||||||
initData();
|
initData();
|
||||||
Session s = openSession();
|
Session s = openSession();
|
||||||
Transaction t = s.beginTransaction();
|
Transaction t = s.beginTransaction();
|
||||||
Componentizable master = getMaster("hibernate", null, "ope%");
|
Componentizable componentizable = getComponentizeable("hibernate", null, "ope%");
|
||||||
Criteria crit = s.createCriteria(Componentizable.class);
|
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));
|
crit.add(Restrictions.or(Restrictions.not(ex), ex));
|
||||||
|
|
||||||
|
@ -77,18 +77,18 @@ public class QueryByExampleTest extends LegacyTestCase {
|
||||||
initData();
|
initData();
|
||||||
Session s = openSession();
|
Session s = openSession();
|
||||||
Transaction t = s.beginTransaction();
|
Transaction t = s.beginTransaction();
|
||||||
Componentizable master = getMaster("hibernate", null, "ope%");
|
Componentizable getComponentizeable = getComponentizeable("hibernate", null, "ope%");
|
||||||
Criteria crit = s.createCriteria(Componentizable.class);
|
Criteria crit = s.createCriteria(Componentizable.class);
|
||||||
Example ex = Example.create(master).enableLike()
|
Example ex = Example.create(getComponentizeable).enableLike()
|
||||||
.excludeProperty("component.subComponent");
|
.excludeProperty("component.subComponent");
|
||||||
crit.add(ex);
|
crit.add(ex);
|
||||||
List result = crit.list();
|
List result = crit.list();
|
||||||
assertNotNull(result);
|
assertNotNull(result);
|
||||||
assertEquals(3, result.size());
|
assertEquals(3, result.size());
|
||||||
|
|
||||||
master = getMaster("hibernate", "ORM tool", "fake stuff");
|
getComponentizeable = getComponentizeable("hibernate", "ORM tool", "fake stuff");
|
||||||
crit = s.createCriteria(Componentizable.class);
|
crit = s.createCriteria(Componentizable.class);
|
||||||
ex = Example.create(master).enableLike()
|
ex = Example.create(getComponentizeable).enableLike()
|
||||||
.excludeProperty("component.subComponent.subName1");
|
.excludeProperty("component.subComponent.subName1");
|
||||||
crit.add(ex);
|
crit.add(ex);
|
||||||
result = crit.list();
|
result = crit.list();
|
||||||
|
@ -103,12 +103,12 @@ public class QueryByExampleTest extends LegacyTestCase {
|
||||||
private void initData() throws Exception {
|
private void initData() throws Exception {
|
||||||
Session s = openSession();
|
Session s = openSession();
|
||||||
Transaction t = s.beginTransaction();
|
Transaction t = s.beginTransaction();
|
||||||
Componentizable master = getMaster("hibernate", "ORM tool", "ORM tool1");
|
Componentizable getComponentizeable = getComponentizeable("hibernate", "ORM tool", "ORM tool1");
|
||||||
s.saveOrUpdate(master);
|
s.saveOrUpdate(getComponentizeable);
|
||||||
master = getMaster("hibernate", "open source", "open source1");
|
getComponentizeable = getComponentizeable("hibernate", "open source", "open source1");
|
||||||
s.saveOrUpdate(master);
|
s.saveOrUpdate(getComponentizeable);
|
||||||
master = getMaster("hibernate", null, null);
|
getComponentizeable = getComponentizeable("hibernate", null, null);
|
||||||
s.saveOrUpdate(master);
|
s.saveOrUpdate(getComponentizeable);
|
||||||
t.commit();
|
t.commit();
|
||||||
s.close();
|
s.close();
|
||||||
}
|
}
|
||||||
|
@ -123,19 +123,19 @@ public class QueryByExampleTest extends LegacyTestCase {
|
||||||
s.close();
|
s.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
private Componentizable getMaster(String name, String subname, String subname1) {
|
private Componentizable getComponentizeable(String name, String subname, String subname1) {
|
||||||
Componentizable master = new Componentizable();
|
Componentizable getComponentizeable = new Componentizable();
|
||||||
if (name != null) {
|
if (name != null) {
|
||||||
Component masterComp = new Component();
|
Component component = new Component();
|
||||||
masterComp.setName(name);
|
component.setName(name);
|
||||||
if (subname != null || subname1 != null) {
|
if (subname != null || subname1 != null) {
|
||||||
SubComponent subComponent = new SubComponent();
|
SubComponent subComponent = new SubComponent();
|
||||||
subComponent.setSubName(subname);
|
subComponent.setSubName(subname);
|
||||||
subComponent.setSubName1(subname1);
|
subComponent.setSubName1(subname1);
|
||||||
masterComp.setSubComponent(subComponent);
|
component.setSubComponent(subComponent);
|
||||||
}
|
}
|
||||||
master.setComponent(masterComp);
|
getComponentizeable.setComponent(component);
|
||||||
}
|
}
|
||||||
return master;
|
return getComponentizeable;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,12 +9,17 @@ package org.hibernate.test.legacy;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
import java.sql.SQLException;
|
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.Hibernate;
|
||||||
import org.hibernate.LockMode;
|
import org.hibernate.LockMode;
|
||||||
import org.hibernate.ObjectNotFoundException;
|
import org.hibernate.ObjectNotFoundException;
|
||||||
import org.hibernate.query.Query;
|
import org.hibernate.Query;
|
||||||
import org.hibernate.Session;
|
import org.hibernate.Session;
|
||||||
import org.hibernate.Transaction;
|
import org.hibernate.Transaction;
|
||||||
import org.hibernate.cfg.Configuration;
|
import org.hibernate.cfg.Configuration;
|
||||||
|
@ -23,13 +28,13 @@ import org.hibernate.criterion.Example;
|
||||||
import org.hibernate.criterion.Restrictions;
|
import org.hibernate.criterion.Restrictions;
|
||||||
import org.hibernate.dialect.AbstractHANADialect;
|
import org.hibernate.dialect.AbstractHANADialect;
|
||||||
import org.hibernate.dialect.HSQLDialect;
|
import org.hibernate.dialect.HSQLDialect;
|
||||||
import org.hibernate.dialect.MckoiDialect;
|
|
||||||
import org.hibernate.dialect.MySQLDialect;
|
import org.hibernate.dialect.MySQLDialect;
|
||||||
import org.hibernate.dialect.SAPDBDialect;
|
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.connections.spi.JdbcConnectionAccess;
|
||||||
import org.hibernate.engine.jdbc.spi.JdbcServices;
|
import org.hibernate.engine.jdbc.spi.JdbcServices;
|
||||||
import org.hibernate.jdbc.AbstractWork;
|
import org.hibernate.jdbc.AbstractWork;
|
||||||
|
|
||||||
import org.hibernate.testing.SkipForDialect;
|
import org.hibernate.testing.SkipForDialect;
|
||||||
import org.hibernate.testing.SkipLog;
|
import org.hibernate.testing.SkipLog;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
@ -39,11 +44,11 @@ import static org.junit.Assert.assertFalse;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
|
|
||||||
public class MasterDetailTest extends LegacyTestCase {
|
public class RootDetailTest extends LegacyTestCase {
|
||||||
@Override
|
@Override
|
||||||
public String[] getMappings() {
|
public String[] getMappings() {
|
||||||
return new String[] {
|
return new String[] {
|
||||||
"legacy/MasterDetail.hbm.xml",
|
"legacy/RootDetail.hbm.xml",
|
||||||
"legacy/Custom.hbm.xml",
|
"legacy/Custom.hbm.xml",
|
||||||
"legacy/Category.hbm.xml",
|
"legacy/Category.hbm.xml",
|
||||||
"legacy/Nameable.hbm.xml",
|
"legacy/Nameable.hbm.xml",
|
||||||
|
@ -92,15 +97,6 @@ public class MasterDetailTest extends LegacyTestCase {
|
||||||
s.close();
|
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
|
@Test
|
||||||
@SuppressWarnings( {"unchecked"})
|
@SuppressWarnings( {"unchecked"})
|
||||||
public void testCopy() throws Exception {
|
public void testCopy() throws Exception {
|
||||||
|
@ -197,23 +193,23 @@ public class MasterDetailTest extends LegacyTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@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 {
|
public void testSelfManyToOne() throws Exception {
|
||||||
Session s = openSession();
|
Session s = openSession();
|
||||||
Transaction t = s.beginTransaction();
|
Transaction t = s.beginTransaction();
|
||||||
Master m = new Master();
|
Root m = new Root();
|
||||||
m.setOtherMaster(m);
|
m.setOtherRoot(m);
|
||||||
s.save(m);
|
s.save(m);
|
||||||
t.commit();
|
t.commit();
|
||||||
s.close();
|
s.close();
|
||||||
|
|
||||||
s = openSession();
|
s = openSession();
|
||||||
t = s.beginTransaction();
|
t = s.beginTransaction();
|
||||||
Iterator i = s.createQuery( "from Master" ).iterate();
|
Iterator i = s.createQuery( "from Root" ).iterate();
|
||||||
m = (Master) i.next();
|
m = (Root) i.next();
|
||||||
assertTrue( m.getOtherMaster()==m );
|
assertTrue( m.getOtherRoot()==m );
|
||||||
if ( getDialect() instanceof HSQLDialect || getDialect() instanceof MySQLDialect ) {
|
if ( getDialect() instanceof HSQLDialect || getDialect() instanceof MySQLDialect ) {
|
||||||
m.setOtherMaster(null);
|
m.setOtherRoot(null);
|
||||||
s.flush();
|
s.flush();
|
||||||
}
|
}
|
||||||
s.delete(m);
|
s.delete(m);
|
||||||
|
@ -222,45 +218,45 @@ public class MasterDetailTest extends LegacyTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@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 {
|
public void testExample() throws Exception {
|
||||||
Session s = openSession();
|
Session s = openSession();
|
||||||
Transaction t = s.beginTransaction();
|
Transaction t = s.beginTransaction();
|
||||||
Master m = new Master();
|
Root m = new Root();
|
||||||
m.setName("name");
|
m.setName("name");
|
||||||
m.setX(5);
|
m.setX(5);
|
||||||
m.setOtherMaster(m);
|
m.setOtherRoot(m);
|
||||||
s.save(m);
|
s.save(m);
|
||||||
t.commit();
|
t.commit();
|
||||||
s.close();
|
s.close();
|
||||||
|
|
||||||
s = openSession();
|
s = openSession();
|
||||||
t = s.beginTransaction();
|
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") )
|
.add( Example.create(m).enableLike().ignoreCase().excludeProperty("bigDecimal") )
|
||||||
.uniqueResult();
|
.uniqueResult();
|
||||||
assertTrue( m1.getOtherMaster()==m1 );
|
assertTrue( m1.getOtherRoot()==m1 );
|
||||||
m1 = (Master) s.createCriteria(Master.class)
|
m1 = (Root) s.createCriteria( Root.class)
|
||||||
.add( Restrictions.eq("name", "foobar") )
|
.add( Restrictions.eq("name", "foobar") )
|
||||||
.uniqueResult();
|
.uniqueResult();
|
||||||
assertTrue( m1==null );
|
assertTrue( m1==null );
|
||||||
m1 = (Master) s.createCriteria(Master.class)
|
m1 = (Root) s.createCriteria( Root.class)
|
||||||
.add( Example.create(m).excludeProperty("bigDecimal") )
|
.add( Example.create(m).excludeProperty("bigDecimal") )
|
||||||
.createCriteria("otherMaster")
|
.createCriteria("otherRoot")
|
||||||
.add( Example.create(m).excludeZeroes().excludeProperty("bigDecimal") )
|
.add( Example.create(m).excludeZeroes().excludeProperty("bigDecimal") )
|
||||||
.uniqueResult();
|
.uniqueResult();
|
||||||
assertTrue( m1.getOtherMaster()==m1 );
|
assertTrue( m1.getOtherRoot()==m1 );
|
||||||
Master m2 = (Master) s.createCriteria(Master.class)
|
Root m2 = (Root) s.createCriteria( Root.class)
|
||||||
.add( Example.create(m).excludeNone().excludeProperty("bigDecimal") )
|
.add( Example.create(m).excludeNone().excludeProperty("bigDecimal") )
|
||||||
.uniqueResult();
|
.uniqueResult();
|
||||||
assertTrue( m2==m1 );
|
assertTrue( m2==m1 );
|
||||||
m.setName(null);
|
m.setName(null);
|
||||||
m2 = (Master) s.createCriteria(Master.class)
|
m2 = (Root) s.createCriteria( Root.class)
|
||||||
.add( Example.create(m).excludeNone().excludeProperty("bigDecimal") )
|
.add( Example.create(m).excludeNone().excludeProperty("bigDecimal") )
|
||||||
.uniqueResult();
|
.uniqueResult();
|
||||||
assertTrue( null == m2 );
|
assertTrue( null == m2 );
|
||||||
if (getDialect() instanceof HSQLDialect || getDialect() instanceof MySQLDialect) {
|
if (getDialect() instanceof HSQLDialect || getDialect() instanceof MySQLDialect) {
|
||||||
m1.setOtherMaster(null);
|
m1.setOtherRoot(null);
|
||||||
s.flush();
|
s.flush();
|
||||||
}
|
}
|
||||||
s.delete(m1);
|
s.delete(m1);
|
||||||
|
@ -312,39 +308,39 @@ public class MasterDetailTest extends LegacyTestCase {
|
||||||
Session s = openSession();
|
Session s = openSession();
|
||||||
Transaction t = s.beginTransaction();
|
Transaction t = s.beginTransaction();
|
||||||
if ( !(getDialect() instanceof MySQLDialect) && !(getDialect() instanceof SAPDBDialect) && !(getDialect() instanceof MckoiDialect) ) {
|
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 Root 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 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 Root 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 FROM Root 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.id FROM Root AS m JOIN m.details AS d WHERE d.i=5" ).list();
|
||||||
t.commit();
|
t.commit();
|
||||||
s.close();
|
s.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testMasterDetail() throws Exception {
|
public void tesRootDetail() throws Exception {
|
||||||
if (getDialect() instanceof HSQLDialect) return;
|
if (getDialect() instanceof HSQLDialect) return;
|
||||||
|
|
||||||
Session s = openSession();
|
Session s = openSession();
|
||||||
Transaction t = s.beginTransaction();
|
Transaction t = s.beginTransaction();
|
||||||
Master master = new Master();
|
Root root = new Root();
|
||||||
assertTrue( "save returned native id", s.save(master)!=null );
|
assertTrue( "save returned native id", s.save( root )!=null );
|
||||||
Serializable mid = s.getIdentifier(master);
|
Serializable mid = s.getIdentifier( root );
|
||||||
Detail d1 = new Detail();
|
Detail d1 = new Detail();
|
||||||
d1.setMaster(master);
|
d1.setRoot( root );
|
||||||
Serializable did = s.save(d1);
|
Serializable did = s.save(d1);
|
||||||
Detail d2 = new Detail();
|
Detail d2 = new Detail();
|
||||||
d2.setI(12);
|
d2.setI(12);
|
||||||
d2.setMaster(master);
|
d2.setRoot( root );
|
||||||
assertTrue( "generated id returned", s.save(d2)!=null);
|
assertTrue( "generated id returned", s.save(d2)!=null);
|
||||||
master.addDetail(d1);
|
root.addDetail(d1);
|
||||||
master.addDetail(d2);
|
root.addDetail(d2);
|
||||||
if ( !(getDialect() instanceof MySQLDialect) && !(getDialect() instanceof SAPDBDialect) && !(getDialect() instanceof MckoiDialect) && !(getDialect() instanceof org.hibernate.dialect.TimesTenDialect)) {
|
if ( !(getDialect() instanceof MySQLDialect) && !(getDialect() instanceof SAPDBDialect) && !(getDialect() instanceof MckoiDialect) && !(getDialect() instanceof TimesTenDialect)) {
|
||||||
assertTrue(
|
assertTrue(
|
||||||
"query",
|
"query",
|
||||||
s.createQuery(
|
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
|
).list().size()==2
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -353,42 +349,42 @@ public class MasterDetailTest extends LegacyTestCase {
|
||||||
|
|
||||||
s = openSession();
|
s = openSession();
|
||||||
t = s.beginTransaction();
|
t = s.beginTransaction();
|
||||||
master = new Master();
|
root = new Root();
|
||||||
s.load(master, mid);
|
s.load( root, mid);
|
||||||
assertTrue( master.getDetails().size()==2 );
|
assertTrue( root.getDetails().size()==2 );
|
||||||
t.commit();
|
t.commit();
|
||||||
s.close();
|
s.close();
|
||||||
|
|
||||||
s = openSession();
|
s = openSession();
|
||||||
t = s.beginTransaction();
|
t = s.beginTransaction();
|
||||||
master = (Master) s.load(Master.class, mid);
|
root = (Root) s.load( Root.class, mid);
|
||||||
Iterator iter = master.getDetails().iterator();
|
Iterator iter = root.getDetails().iterator();
|
||||||
int i=0;
|
int i=0;
|
||||||
while ( iter.hasNext() ) {
|
while ( iter.hasNext() ) {
|
||||||
Detail d = (Detail) iter.next();
|
Detail d = (Detail) iter.next();
|
||||||
assertTrue( "master-detail", d.getMaster()==master );
|
assertTrue( "root-detail", d.getRoot()== root );
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
assertTrue( "master-detail", i==2 );
|
assertTrue( "root-detail", i==2 );
|
||||||
t.commit();
|
t.commit();
|
||||||
s.close();
|
s.close();
|
||||||
|
|
||||||
s = openSession();
|
s = openSession();
|
||||||
t = s.beginTransaction();
|
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();
|
t.commit();
|
||||||
s.close();
|
s.close();
|
||||||
|
|
||||||
s = openSession();
|
s = openSession();
|
||||||
t = s.beginTransaction();
|
t = s.beginTransaction();
|
||||||
List list = s.createQuery( "from Master m left join fetch m.details" ).list();
|
List list = s.createQuery( "from Root m left join fetch m.details" ).list();
|
||||||
Master m = (Master) list.get(0);
|
Root m = (Root) list.get(0);
|
||||||
assertTrue( Hibernate.isInitialized( m.getDetails() ) );
|
assertTrue( Hibernate.isInitialized( m.getDetails() ) );
|
||||||
assertTrue( m.getDetails().size()==2 );
|
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);
|
Detail dt = (Detail) list.get(0);
|
||||||
Serializable dtid = s.getIdentifier(dt);
|
Serializable dtid = s.getIdentifier(dt);
|
||||||
assertTrue( dt.getMaster()==m );
|
assertTrue( dt.getRoot()==m );
|
||||||
|
|
||||||
//assertTrue(m.getAllDetails().size()==2);
|
//assertTrue(m.getAllDetails().size()==2);
|
||||||
|
|
||||||
|
@ -397,25 +393,22 @@ public class MasterDetailTest extends LegacyTestCase {
|
||||||
|
|
||||||
s = openSession();
|
s = openSession();
|
||||||
t = s.beginTransaction();
|
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();
|
.list();
|
||||||
assertTrue( Hibernate.isInitialized( ( (Master) list.get(0) ).getDetails() ) );
|
assertTrue( Hibernate.isInitialized( ( (Root) list.get(0) ).getDetails() ) );
|
||||||
dt = (Detail) s.load(Detail.class, dtid);
|
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();
|
t.commit();
|
||||||
s.close();
|
s.close();
|
||||||
|
|
||||||
s = openSession();
|
s = openSession();
|
||||||
t = s.beginTransaction();
|
t = s.beginTransaction();
|
||||||
list = s.createQuery(
|
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();
|
).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);
|
dt = (Detail) s.load(Detail.class, dtid);
|
||||||
assertTrue( ( (Master) ( (Object[]) list.get(0) )[0] ).getDetails().contains(dt) );
|
assertTrue( ( (Root) ( (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");
|
|
||||||
t.commit();
|
t.commit();
|
||||||
s.close();
|
s.close();
|
||||||
|
|
||||||
|
@ -423,14 +416,14 @@ public class MasterDetailTest extends LegacyTestCase {
|
||||||
s = openSession();
|
s = openSession();
|
||||||
t = s.beginTransaction();
|
t = s.beginTransaction();
|
||||||
Detail dd = (Detail) s.load(Detail.class, did);
|
Detail dd = (Detail) s.load(Detail.class, did);
|
||||||
master = dd.getMaster();
|
root = dd.getRoot();
|
||||||
assertTrue( "detail-master", master.getDetails().contains(dd) );
|
assertTrue( "detail-root", root.getDetails().contains(dd) );
|
||||||
assertTrue( s.createFilter( master.getDetails(), "order by this.i desc" ).list().size()==2 );
|
assertTrue( s.createFilter( root.getDetails(), "order by this.i desc" ).list().size()==2 );
|
||||||
assertTrue( s.createFilter( master.getDetails(), "select this where this.id > -1" ).list().size()==2 );
|
assertTrue( s.createFilter( root.getDetails(), "select this where this.id > -1" ).list().size()==2 );
|
||||||
Query q = s.createFilter( master.getDetails(), "where this.id > :id" );
|
Query q = s.createFilter( root.getDetails(), "where this.id > :id" );
|
||||||
q.setInteger("id", -1);
|
q.setInteger("id", -1);
|
||||||
assertTrue( q.list().size()==2 );
|
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("id1", -1);
|
||||||
q.setInteger("id2", 99999999);
|
q.setInteger("id2", 99999999);
|
||||||
assertTrue( q.list().size()==2 );
|
assertTrue( q.list().size()==2 );
|
||||||
|
@ -441,38 +434,38 @@ public class MasterDetailTest extends LegacyTestCase {
|
||||||
list.add(did);
|
list.add(did);
|
||||||
list.add( new Long(-1) );
|
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);
|
q.setParameterList("ids", list);
|
||||||
assertTrue( q.list().size()==1 );
|
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);
|
q.setParameterList("ids", list);
|
||||||
assertTrue( q.iterate().hasNext() );
|
assertTrue( q.iterate().hasNext() );
|
||||||
|
|
||||||
assertTrue( s.createFilter( master.getDetails(), "where this.id > -1" ).list().size()==2 );
|
assertTrue( s.createFilter( root.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(), "select this.root where this.id > -1" ).list().size()==2 );
|
||||||
assertTrue(
|
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()
|
.list()
|
||||||
.size()==2 );
|
.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( root.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( root.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 count(*)" ).iterate().next() instanceof Long );
|
||||||
|
|
||||||
assertTrue( s.createFilter( master.getDetails(), "select this.master" ).list().size()==2 );
|
assertTrue( s.createFilter( root.getDetails(), "select this.root" ).list().size()==2 );
|
||||||
assertTrue( s.createFilter( master.getMoreDetails(), "" ).list().size()==0 );
|
assertTrue( s.createFilter( root.getMoreDetails(), "" ).list().size()==0 );
|
||||||
assertTrue( s.createFilter( master.getIncoming(), "" ).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("top", 100);
|
||||||
f.setInteger("bottom", 0);
|
f.setInteger("bottom", 0);
|
||||||
assertEquals( f.iterate().next(), new Integer(12) );
|
assertEquals( f.iterate().next(), new Integer(12) );
|
||||||
f.setInteger("top", 2);
|
f.setInteger("top", 2);
|
||||||
assertEquals( f.iterate().next(), new Integer(0) );
|
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();
|
Collection coll = new ArrayList();
|
||||||
coll.add( new Integer(-666) );
|
coll.add( new Integer(-666) );
|
||||||
coll.add( new Integer(22) );
|
coll.add( new Integer(22) );
|
||||||
|
@ -480,21 +473,21 @@ public class MasterDetailTest extends LegacyTestCase {
|
||||||
f.setParameterList("list", coll);
|
f.setParameterList("list", coll);
|
||||||
assertEquals( f.iterate().next(), new Integer(12) );
|
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.setParameterList("list", coll);
|
||||||
f.setParameter( "listy2", master.getName() );
|
f.setParameter( "listy2", root.getName() );
|
||||||
assertEquals( f.iterate().next(), new Integer(12) );
|
assertEquals( f.iterate().next(), new Integer(12) );
|
||||||
|
|
||||||
iter = master.getDetails().iterator();
|
iter = root.getDetails().iterator();
|
||||||
i=0;
|
i=0;
|
||||||
while ( iter.hasNext() ) {
|
while ( iter.hasNext() ) {
|
||||||
Detail d = (Detail) iter.next();
|
Detail d = (Detail) iter.next();
|
||||||
assertTrue( "master-detail", d.getMaster()==master );
|
assertTrue( "root-detail", d.getRoot()== root );
|
||||||
s.delete(d);
|
s.delete(d);
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
assertTrue( "master-detail", i==2 );
|
assertTrue( "root-detail", i==2 );
|
||||||
s.delete(master);
|
s.delete( root );
|
||||||
t.commit();
|
t.commit();
|
||||||
s.close();
|
s.close();
|
||||||
}
|
}
|
||||||
|
@ -503,19 +496,19 @@ public class MasterDetailTest extends LegacyTestCase {
|
||||||
public void testIncomingOutgoing() throws Exception {
|
public void testIncomingOutgoing() throws Exception {
|
||||||
Session s = openSession();
|
Session s = openSession();
|
||||||
s.beginTransaction();
|
s.beginTransaction();
|
||||||
Master master1 = new Master();
|
Root root1 = new Root();
|
||||||
Master master2 = new Master();
|
Root root2 = new Root();
|
||||||
Master master3 = new Master();
|
Root root3 = new Root();
|
||||||
s.save(master1);
|
s.save( root1 );
|
||||||
s.save(master2);
|
s.save( root2 );
|
||||||
s.save(master3);
|
s.save( root3 );
|
||||||
master1.addIncoming(master2);
|
root1.addIncoming( root2 );
|
||||||
master2.addOutgoing(master1);
|
root2.addOutgoing( root1 );
|
||||||
master1.addIncoming(master3);
|
root1.addIncoming( root3 );
|
||||||
master3.addOutgoing(master1);
|
root3.addOutgoing( root1 );
|
||||||
Serializable m1id = s.getIdentifier(master1);
|
Serializable m1id = s.getIdentifier( root1 );
|
||||||
assertTrue(
|
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()
|
.list()
|
||||||
.size() == 2
|
.size() == 2
|
||||||
);
|
);
|
||||||
|
@ -524,18 +517,18 @@ public class MasterDetailTest extends LegacyTestCase {
|
||||||
|
|
||||||
s = openSession();
|
s = openSession();
|
||||||
s.beginTransaction();
|
s.beginTransaction();
|
||||||
master1 = (Master) s.load(Master.class, m1id);
|
root1 = (Root) s.load( Root.class, m1id);
|
||||||
Iterator iter = master1.getIncoming().iterator();
|
Iterator iter = root1.getIncoming().iterator();
|
||||||
int i=0;
|
int i=0;
|
||||||
while ( iter.hasNext() ) {
|
while ( iter.hasNext() ) {
|
||||||
Master m = (Master) iter.next();
|
Root m = (Root) iter.next();
|
||||||
assertTrue( "outgoing", m.getOutgoing().size()==1 );
|
assertTrue( "outgoing", m.getOutgoing().size()==1 );
|
||||||
assertTrue( "outgoing", m.getOutgoing().contains(master1) );
|
assertTrue( "outgoing", m.getOutgoing().contains( root1 ) );
|
||||||
s.delete(m);
|
s.delete(m);
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
assertTrue( "incoming-outgoing", i == 2 );
|
assertTrue( "incoming-outgoing", i == 2 );
|
||||||
s.delete( master1 );
|
s.delete( root1 );
|
||||||
s.getTransaction().commit();
|
s.getTransaction().commit();
|
||||||
s.close();
|
s.close();
|
||||||
}
|
}
|
||||||
|
@ -547,11 +540,11 @@ public class MasterDetailTest extends LegacyTestCase {
|
||||||
Detail d1 = new Detail();
|
Detail d1 = new Detail();
|
||||||
Detail d2 = new Detail();
|
Detail d2 = new Detail();
|
||||||
d2.setI(22);
|
d2.setI(22);
|
||||||
Master m = new Master();
|
Root m = new Root();
|
||||||
Master m0 = new Master();
|
Root m0 = new Root();
|
||||||
Serializable m0id = s.save(m0);
|
Serializable m0id = s.save(m0);
|
||||||
m0.addDetail(d1); m0.addDetail(d2);
|
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(d1);
|
||||||
m.getMoreDetails().add(d2);
|
m.getMoreDetails().add(d2);
|
||||||
Serializable mid = s.save(m);
|
Serializable mid = s.save(m);
|
||||||
|
@ -560,11 +553,11 @@ public class MasterDetailTest extends LegacyTestCase {
|
||||||
|
|
||||||
s = openSession();
|
s = openSession();
|
||||||
s.beginTransaction();
|
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", 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( m );
|
||||||
s.delete( s.load( Master.class, m0id ) );
|
s.delete( s.load( Root.class, m0id ) );
|
||||||
s.getTransaction().commit();
|
s.getTransaction().commit();
|
||||||
s.close();
|
s.close();
|
||||||
}
|
}
|
||||||
|
@ -583,13 +576,13 @@ public class MasterDetailTest extends LegacyTestCase {
|
||||||
public void testUpdateLazyCollections() throws Exception {
|
public void testUpdateLazyCollections() throws Exception {
|
||||||
Session s = openSession();
|
Session s = openSession();
|
||||||
s.beginTransaction();
|
s.beginTransaction();
|
||||||
Master m = new Master();
|
Root m = new Root();
|
||||||
s.save( m );
|
s.save( m );
|
||||||
Detail d1 = new Detail();
|
Detail d1 = new Detail();
|
||||||
Detail d2 = new Detail();
|
Detail d2 = new Detail();
|
||||||
d2.setX( 14 );
|
d2.setX( 14 );
|
||||||
d1.setMaster( m );
|
d1.setRoot( m );
|
||||||
d2.setMaster( m );
|
d2.setRoot( m );
|
||||||
s.save( d1 );
|
s.save( d1 );
|
||||||
s.save( d2 );
|
s.save( d2 );
|
||||||
m.addDetail( d1 );
|
m.addDetail( d1 );
|
||||||
|
@ -599,7 +592,7 @@ public class MasterDetailTest extends LegacyTestCase {
|
||||||
|
|
||||||
s = openSession();
|
s = openSession();
|
||||||
s.beginTransaction();
|
s.beginTransaction();
|
||||||
m = (Master) s.load( Master.class, m.getId() );
|
m = (Root) s.load( Root.class, m.getId() );
|
||||||
s.getTransaction().commit();
|
s.getTransaction().commit();
|
||||||
s.close();
|
s.close();
|
||||||
m.setName("New Name");
|
m.setName("New Name");
|
||||||
|
@ -627,11 +620,11 @@ public class MasterDetailTest extends LegacyTestCase {
|
||||||
Transaction txn = s.beginTransaction();
|
Transaction txn = s.beginTransaction();
|
||||||
Detail detail = new Detail();
|
Detail detail = new Detail();
|
||||||
SubDetail subdetail = new SubDetail();
|
SubDetail subdetail = new SubDetail();
|
||||||
Master m = new Master();
|
Root m = new Root();
|
||||||
Master m0 = new Master();
|
Root m0 = new Root();
|
||||||
Serializable m0id = s.save(m0);
|
Serializable m0id = s.save(m0);
|
||||||
m0.addDetail(detail);
|
m0.addDetail(detail);
|
||||||
detail.setMaster(m0);
|
detail.setRoot(m0);
|
||||||
m.getMoreDetails().add(detail);
|
m.getMoreDetails().add(detail);
|
||||||
detail.setSubDetails( new HashSet() );
|
detail.setSubDetails( new HashSet() );
|
||||||
detail.getSubDetails().add(subdetail);
|
detail.getSubDetails().add(subdetail);
|
||||||
|
@ -641,12 +634,12 @@ public class MasterDetailTest extends LegacyTestCase {
|
||||||
|
|
||||||
s = openSession();
|
s = openSession();
|
||||||
txn = s.beginTransaction();
|
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 );
|
assertTrue( ( (Detail) m.getMoreDetails().iterator().next() ).getSubDetails().size()!=0 );
|
||||||
s.delete(m);
|
s.delete(m);
|
||||||
assertTrue( s.createQuery( "from SubDetail" ).list().size()==0 );
|
assertTrue( s.createQuery( "from SubDetail" ).list().size()==0 );
|
||||||
assertTrue( s.createQuery( "from Detail d" ).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();
|
txn.commit();
|
||||||
s.close();
|
s.close();
|
||||||
}
|
}
|
|
@ -247,7 +247,7 @@ public class QueryBuilder {
|
||||||
StringTools.append( sb, getOrderList().iterator(), ", " );
|
StringTools.append( sb, getOrderList().iterator(), ", " );
|
||||||
}
|
}
|
||||||
else if ( !orderFragments.isEmpty() ) {
|
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() );
|
throw new NotYetImplementedFor6Exception( getClass() );
|
||||||
|
|
||||||
// sb.append( " order by " );
|
// sb.append( " order by " );
|
||||||
|
|
|
@ -62,8 +62,8 @@ gradlePlugin {
|
||||||
}
|
}
|
||||||
|
|
||||||
pluginBundle {
|
pluginBundle {
|
||||||
website = '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/master/tooling/hibernate-gradle-plugin'
|
vcsUrl = 'https://github.com/hibernate/hibernate-orm/tree/main/tooling/hibernate-gradle-plugin'
|
||||||
tags = ['hibernate','orm','bytecode','enhancement','bytebuddy']
|
tags = ['hibernate','orm','bytecode','enhancement','bytebuddy']
|
||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
|
|
Loading…
Reference in New Issue