HHH-14509 : Git master -> main branch renaming

This commit is contained in:
Steve Ebersole 2021-03-19 10:59:03 -05:00
parent b4bf58188c
commit 725faa258f
47 changed files with 403 additions and 454 deletions

View File

@ -9,11 +9,11 @@ name: Hibernate ORM build
on:
push:
branches:
- 'master'
- 'main'
- 'wip/6.0'
pull_request:
branches:
- 'master'
- 'main'
- 'wip/6.0'
jobs:
build:

View File

@ -62,8 +62,8 @@ although this is more of a mnemonic strategy than a hard-and-fast rule - but doi
_If there is not already a JIRA issue covering the work you want to do, create one._
Assuming you will be working from the master branch and working
on the JIRA HHH-123 : `git checkout -b HHH-123 master`
Assuming you will be working from the `main` branch and working
on the JIRA HHH-123 : `git checkout -b HHH-123 main`
## Code

View File

@ -8,7 +8,7 @@ It also provides an implementation of the JPA specification, which is the standa
This is the repository of its source code: see [Hibernate.org](http://hibernate.org/orm/) for additional information.
[![Build Status](http://ci.hibernate.org/job/hibernate-orm-master-h2-main/badge/icon)](http://ci.hibernate.org/job/hibernate-orm-master-h2-main/)
[![Build Status](http://ci.hibernate.org/job/hibernate-orm-main-h2-main/badge/icon)](http://ci.hibernate.org/job/hibernate-orm-main-h2-main/)
[![Language grade: Java](https://img.shields.io/lgtm/grade/java/g/hibernate/hibernate-orm.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/hibernate/hibernate-orm/context:java)
Building from sources

View File

@ -190,7 +190,7 @@ hibernate.connection.url jdbc:hsqldb:./build/db/hsqldb/hibernate
#hibernate.dialect org.hibernate.dialect.InterbaseDialect
#hibernate.connection.username sysdba
#hibernate.connection.password masterkey
#hibernate.connection.password thekey
## DO NOT specify hibernate.connection.sqlDialect

View File

@ -169,7 +169,7 @@ hibernate.connection.url @DB_URL@
#hibernate.dialect org.hibernate.dialect.InterbaseDialect
#hibernate.connection.username sysdba
#hibernate.connection.password masterkey
#hibernate.connection.password thepass
## DO NOT specify hibernate.connection.sqlDialect

View File

@ -1669,7 +1669,7 @@ public interface CoreMessageLogger extends BasicLogger {
)
void applyingExplicitDiscriminatorColumnForJoined(String className, String overrideSetting);
// 458-466 reserved for use by master (ORM 5.0.0)
// 458-466 reserved for use by main branch (ORM 5.0.0)
@LogMessage(level = DEBUG)
@Message(value = "Creating pooled optimizer (lo) with [incrementSize=%s; returnClass=%s]", id = 467)

View File

@ -26,7 +26,7 @@ public class FormalLastName {
@Embedded
private LastName lastName;
private String designation; /* Mr/Mrs/Master */
private String designation; /* Mr/Mrs */
public Integer getId() {
return id;

View File

@ -12,7 +12,7 @@ package org.hibernate.test.fileimport;
*/
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;
}
}

View File

@ -21,7 +21,7 @@ public class AnnotatedFormWithBeanValidationNotNullTest extends BaseUnitTestCase
@TestForIssue( jiraKey = "HHH-8167" )
public void testAnnotatedFormWithBeanValidationNotNull() {
Configuration cfg = new Configuration();
cfg.addAnnotatedClass( AnnotatedMaster.class ).addAnnotatedClass( AnnotatedDetail.class );
cfg.addAnnotatedClass( AnnotatedRoot.class ).addAnnotatedClass( AnnotatedDetail.class );
cfg.buildSessionFactory().close();
}
}

View File

@ -22,7 +22,7 @@ import org.hibernate.annotations.JoinFormula;
* @author Steve Ebersole
*/
@Entity
public class AnnotatedMaster {
public class AnnotatedRoot {
@Id
private Integer id;
private String name;

View File

@ -14,7 +14,7 @@ import java.io.Serializable;
*/
public class Detail implements Serializable {
private Long id;
private Master master;
private Root root;
private int version;
private String details;
private boolean currentVersion;
@ -37,11 +37,11 @@ public class Detail implements Serializable {
public void setId(Long id) {
this.id = id;
}
public Master getMaster() {
return master;
public Root getRoot() {
return root;
}
public void setMaster(Master master) {
this.master = master;
public void setRoot(Root root) {
this.root = root;
}
public int getVersion() {
return version;

View File

@ -24,27 +24,27 @@ import static org.junit.Assert.assertTrue;
*/
public class FormulaJoinTest extends BaseCoreFunctionalTestCase {
public String[] getMappings() {
return new String[] { "formulajoin/Master.hbm.xml" };
return new String[] { "formulajoin/Root.hbm.xml" };
}
@Test
public void testFormulaJoin() {
Session s = openSession();
Transaction tx = s.beginTransaction();
Master master = new Master();
master.setName("master 1");
Root root = new Root();
root.setName("root 1");
Detail current = new Detail();
current.setCurrentVersion(true);
current.setVersion(2);
current.setDetails("details of master 1 blah blah");
current.setMaster(master);
master.setDetail(current);
current.setDetails("details of root 1 blah blah");
current.setRoot( root );
root.setDetail(current);
Detail past = new Detail();
past.setCurrentVersion(false);
past.setVersion(1);
past.setDetails("old details of master 1 yada yada");
past.setMaster(master);
s.persist(master);
past.setDetails("old details of root 1 yada yada");
past.setRoot( root );
s.persist( root );
s.persist(past);
s.persist(current);
tx.commit();
@ -54,42 +54,42 @@ public class FormulaJoinTest extends BaseCoreFunctionalTestCase {
s = openSession();
tx = s.beginTransaction();
List l = s.createQuery("from Master m left join m.detail d").list();
List l = s.createQuery("from Root m left join m.detail d").list();
assertEquals( l.size(), 1 );
tx.commit();
s.close();
s = openSession();
tx = s.beginTransaction();
l = s.createQuery("from Master m left join fetch m.detail").list();
l = s.createQuery("from Root m left join fetch m.detail").list();
assertEquals( l.size(), 1 );
Master m = (Master) l.get(0);
assertEquals( "master 1", m.getDetail().getMaster().getName() );
assertTrue( m==m.getDetail().getMaster() );
Root m = (Root) l.get(0);
assertEquals( "root 1", m.getDetail().getRoot().getName() );
assertTrue( m==m.getDetail().getRoot() );
tx.commit();
s.close();
s = openSession();
tx = s.beginTransaction();
l = s.createQuery("from Master m join fetch m.detail").list();
l = s.createQuery("from Root m join fetch m.detail").list();
assertEquals( l.size(), 1 );
tx.commit();
s.close();
s = openSession();
tx = s.beginTransaction();
l = s.createQuery("from Detail d join fetch d.currentMaster.master").list();
l = s.createQuery("from Detail d join fetch d.currentRoot.root").list();
assertEquals( l.size(), 2 );
tx.commit();
s.close();
s = openSession();
tx = s.beginTransaction();
l = s.createQuery("from Detail d join fetch d.currentMaster.master m join fetch m.detail").list();
l = s.createQuery("from Detail d join fetch d.currentRoot.root m join fetch m.detail").list();
assertEquals( l.size(), 2 );
s.createQuery("delete from Detail").executeUpdate();
s.createQuery("delete from Master").executeUpdate();
s.createQuery("delete from Root").executeUpdate();
tx.commit();
s.close();

View File

@ -18,7 +18,7 @@
<hibernate-mapping package="org.hibernate.test.formulajoin">
<class name="Master" table="t_masters">
<class name="Root" table="t_roots">
<id name="id">
<generator class="increment"/>
@ -30,7 +30,7 @@
update="false"/>
<many-to-one name="detail"
property-ref="currentMaster"
property-ref="currentRoot"
insert="false"
update="false">
<column name="id"/>
@ -53,13 +53,13 @@
<property name="version" update="false">
<column name="version"
not-null="true"
unique-key="masterVersion"/>
unique-key="rootVersion"/>
</property>
<properties name="currentMaster">
<many-to-one name="master">
<column name="cur_master"
unique-key="masterVersion"
<properties name="currentRoot">
<many-to-one name="root">
<column name="cur_root"
unique-key="rootVersion"
not-null="true"/>
</many-to-one>
<property name="currentVersion"

View File

@ -4,15 +4,14 @@
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
//$Id: Master.java 4602 2004-09-26 11:42:47Z oneovthafew $
package org.hibernate.test.formulajoin;
import java.io.Serializable;
/**
* @author Gavin King
*/
public class Master implements Serializable {
public class Root implements Serializable {
private Long id;
private String name;
private Detail detail;

View File

@ -21,45 +21,45 @@ public class DeleteQuerySubqueryReferencingTargetPropertyTest extends BaseEntity
@Override
protected Class<?>[] getAnnotatedClasses() {
return new Class<?>[] { Master.class, Detail.class };
return new Class<?>[] { Root.class, Detail.class };
}
@Test
public void testSubQueryReferencingTargetProperty() {
// prepare
doInJPA( this::entityManagerFactory, entityManager -> {
Master m1 = new Master();
Root m1 = new Root();
entityManager.persist( m1 );
Detail d11 = new Detail( m1 );
entityManager.persist( d11 );
Detail d12 = new Detail( m1 );
entityManager.persist( d12 );
Master m2 = new Master();
Root m2 = new Root();
entityManager.persist( m2 );
} );
doInJPA( this::entityManagerFactory, entityManager -> {
// depending on the generated ids above this delete removes all masters or nothing
// removal of all masters results in foreign key constraint violation
// removal of nothing is incorrect since 2nd master does not have any details
// depending on the generated ids above this delete removes all Roots or nothing
// removal of all Roots results in foreign key constraint violation
// removal of nothing is incorrect since 2nd Root does not have any details
// DO NOT CHANGE this query: it used to trigger a very specific bug caused
// by the alias not being added to the generated query
String d = "delete from Master m where not exists (select d from Detail d where d.master=m)";
String d = "delete from Root m where not exists (select d from Detail d where d.root=m)";
Query del = entityManager.createQuery( d );
del.executeUpdate();
// so check for exactly one master after deletion
// so check for exactly one Root after deletion
CriteriaBuilder builder = entityManager.getCriteriaBuilder();
CriteriaQuery<Master> query = builder.createQuery( Master.class );
query.select( query.from( Master.class ) );
CriteriaQuery<Root> query = builder.createQuery( Root.class );
query.select( query.from( Root.class ) );
Assert.assertEquals( 1, entityManager.createQuery( query ).getResultList().size() );
} );
}
@Entity(name = "Master")
public static class Master {
@Entity(name = "Root")
public static class Root {
@Id
@GeneratedValue
private Integer id;
@ -72,10 +72,10 @@ public class DeleteQuerySubqueryReferencingTargetPropertyTest extends BaseEntity
private Integer id;
@ManyToOne(optional = false)
private Master master;
private Root root;
public Detail(Master master) {
this.master = master;
public Detail(Root root) {
this.root = root;
}
}
}

View File

@ -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

View File

@ -676,16 +676,16 @@ public class HqlParserTest {
parse( "from fo in class org.hibernate.test.Fo where fo.id.string like 'an instance of fo'" );
parse( "from org.hibernate.test.Inner" );
parse( "from org.hibernate.test.Outer o where o.id.detailId = ?" );
parse( "from org.hibernate.test.Outer o where o.id.master.id.sup.dudu is not null" );
parse( "from org.hibernate.test.Outer o where o.id.master.id.sup.id.akey is not null" );
parse( "select o.id.master.id.sup.dudu from org.hibernate.test.Outer o where o.id.master.id.sup.dudu is not null" );
parse( "select o.id.master.id.sup.id.akey from org.hibernate.test.Outer o where o.id.master.id.sup.id.akey is not null" );
parse( "from org.hibernate.test.Outer o where o.id.master.bla = ''" );
parse( "from org.hibernate.test.Outer o where o.id.master.id.one = ''" );
parse( "from org.hibernate.test.Inner inn where inn.id.bkey is not null and inn.backOut.id.master.id.sup.id.akey > 'a'" );
parse( "from org.hibernate.test.Outer as o left join o.id.master m left join m.id.sup where o.bubu is not null" );
parse( "from org.hibernate.test.Outer as o left join o.id.master.id.sup s where o.bubu is not null" );
parse( "from org.hibernate.test.Outer as o left join o.id.master m left join o.id.master.id.sup s where o.bubu is not null" );
parse( "from org.hibernate.test.Outer o where o.id.main.id.sup.dudu is not null" );
parse( "from org.hibernate.test.Outer o where o.id.main.id.sup.id.akey is not null" );
parse( "select o.id.main.id.sup.dudu from org.hibernate.test.Outer o where o.id.main.id.sup.dudu is not null" );
parse( "select o.id.main.id.sup.id.akey from org.hibernate.test.Outer o where o.id.main.id.sup.id.akey is not null" );
parse( "from org.hibernate.test.Outer o where o.id.main.bla = ''" );
parse( "from org.hibernate.test.Outer o where o.id.main.id.one = ''" );
parse( "from org.hibernate.test.Inner inn where inn.id.bkey is not null and inn.backOut.id.main.id.sup.id.akey > 'a'" );
parse( "from org.hibernate.test.Outer as o left join o.id.main m left join m.id.sup where o.bubu is not null" );
parse( "from org.hibernate.test.Outer as o left join o.id.main.id.sup s where o.bubu is not null" );
parse( "from org.hibernate.test.Outer as o left join o.id.main m left join o.id.main.id.sup s where o.bubu is not null" );
parse( "select fum1.fo from fum1 in class org.hibernate.test.Fum where fum1.fo.fum is not null" );
parse( "from fum1 in class org.hibernate.test.Fum where fum1.fo.fum is not null order by fum1.fo.fum" );
parse( "select elements(fum1.friends) from fum1 in class org.hibernate.test.Fum" );
@ -696,7 +696,7 @@ public class HqlParserTest {
parse( "from org.hibernate.test.Up up order by up.id2 asc" );
parse( "from org.hibernate.test.Down down" );
parse( "from org.hibernate.test.Up up" );
parse( "from m in class org.hibernate.test.Master" );
parse( "from m in class org.hibernate.test.Root" );
parse( "from s in class org.hibernate.test.Several" );
parse( "from s in class org.hibernate.test.Single" );
parse( "\n" +
@ -915,11 +915,11 @@ public class HqlParserTest {
parse( "from bar in class org.hibernate.test.Bar, foo in elements(bar.baz.fooSet)" );
parse( "from one in class org.hibernate.test.One, many in elements(one.manies) where one.id = 1 and many.id = 1" );
parse( "from org.hibernate.test.Inner _inner join _inner.middles middle" );
parse( "FROM m IN CLASS org.hibernate.test.Master WHERE NOT EXISTS ( FROM d IN elements(m.details) WHERE NOT d.i=5 )" );
parse( "FROM m IN CLASS org.hibernate.test.Master WHERE NOT 5 IN ( SELECT d.i FROM d IN elements(m.details) )" );
parse( "SELECT m FROM m IN CLASS org.hibernate.test.Master, d IN elements(m.details) WHERE d.i=5" );
parse( "SELECT m FROM m IN CLASS org.hibernate.test.Master, d IN elements(m.details) WHERE d.i=5" );
parse( "SELECT m.id FROM m IN CLASS org.hibernate.test.Master, d IN elements(m.details) WHERE d.i=5" );
parse( "FROM m IN CLASS org.hibernate.test.Root WHERE NOT EXISTS ( FROM d IN elements(m.details) WHERE NOT d.i=5 )" );
parse( "FROM m IN CLASS org.hibernate.test.Root WHERE NOT 5 IN ( SELECT d.i FROM d IN elements(m.details) )" );
parse( "SELECT m FROM m IN CLASS org.hibernate.test.Root, d IN elements(m.details) WHERE d.i=5" );
parse( "SELECT m FROM m IN CLASS org.hibernate.test.Root, d IN elements(m.details) WHERE d.i=5" );
parse( "SELECT m.id FROM m IN CLASS org.hibernate.test.Root, d IN elements(m.details) WHERE d.i=5" );
// I'm not sure about these... [jsd]
// parse("select bar.string, foo.string from bar in class org.hibernate.test.Bar inner join bar.baz as baz inner join elements(baz.fooSet) as foo where baz.name = 'name'");
// parse("select bar.string, foo.string from bar in class org.hibernate.test.Bar, bar.baz as baz, elements(baz.fooSet) as foo where baz.name = 'name'");

View File

@ -61,7 +61,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",

View File

@ -19,14 +19,14 @@ public class UpdateJoinedSubclassCorrelationTest extends BaseEntityManagerFuncti
@Override
protected Class<?>[] getAnnotatedClasses() {
return new Class<?>[] { Master.class, SubMaster.class, Detail.class };
return new Class<?>[] { Root.class, SubRoot.class, Detail.class };
}
@Test
public void testJoinedSubclassUpdateWithCorrelation() {
// prepare
doInJPA( this::entityManagerFactory, entityManager -> {
Master m1 = new SubMaster( 1, null );
Root m1 = new SubRoot( 1, null );
entityManager.persist( m1 );
Detail d11 = new Detail( 10, m1 );
entityManager.persist( d11 );
@ -35,40 +35,40 @@ public class UpdateJoinedSubclassCorrelationTest extends BaseEntityManagerFuncti
doInJPA( this::entityManagerFactory, entityManager -> {
// DO NOT CHANGE this query: it used to trigger a very specific bug caused
// by the root table alias being added to the generated subquery instead of the table name
String u = "update SubMaster m set name = (select 'test' from Detail d where d.master = m)";
String u = "update SubRoot m set name = (select 'test' from Detail d where d.root = m)";
Query updateQuery = entityManager.createQuery( u );
updateQuery.executeUpdate();
// so check if the name of the SubMaster has been correctly updated
// so check if the name of the SubRoot has been correctly updated
CriteriaBuilder builder = entityManager.getCriteriaBuilder();
CriteriaQuery<Master> query = builder.createQuery( Master.class );
query.select( query.from( Master.class ) );
List<Master> masters = entityManager.createQuery( query ).getResultList();
Assert.assertEquals( 1, masters.size() );
Assert.assertEquals( "test", ((SubMaster) masters.get(0)).name );
CriteriaQuery<Root> query = builder.createQuery( Root.class );
query.select( query.from( Root.class ) );
List<Root> roots = entityManager.createQuery( query ).getResultList();
Assert.assertEquals( 1, roots.size() );
Assert.assertEquals( "test", ((SubRoot) roots.get(0)).name );
} );
}
@Inheritance(strategy = JOINED)
@Entity(name = "Master")
public static abstract class Master {
@Entity(name = "Root")
public static abstract class Root {
@Id
private Integer id;
public Master() { }
public Root() { }
public Master( Integer id ) {
public Root(Integer id ) {
this.id = id;
}
}
@Entity(name = "SubMaster")
public static class SubMaster extends Master {
@Entity(name = "SubRoot")
public static class SubRoot extends Root {
private String name;
public SubMaster() { }
public SubRoot() { }
public SubMaster( Integer id, String name ) {
public SubRoot(Integer id, String name ) {
super(id);
this.name = name;
}
@ -80,11 +80,11 @@ public class UpdateJoinedSubclassCorrelationTest extends BaseEntityManagerFuncti
private Integer id;
@ManyToOne(optional = false)
private Master master;
private Root root;
public Detail( Integer id, Master master ) {
public Detail( Integer id, Root root) {
this.id = id;
this.master = master;
this.root = root;
}
}
}

View File

@ -11,7 +11,7 @@
<hibernate-mapping default-lazy="false">
<class name="org.hibernate.test.legacy.ComponentNotNullMaster"> <!-- discriminator-value="A"> -->
<class name="org.hibernate.test.legacy.ComponentNotNullRoot"> <!-- discriminator-value="A"> -->
<id name="id" column="container_id">
<generator class="native" />
</id>
@ -28,10 +28,10 @@
</component>
</component>
<list name="components" lazy="true" table="CompNotNullMaster_Comps">
<list name="components" lazy="true" table="CompNotNullRoot_Comps">
<key column = "container_id"/>
<index column = "list_index"/>
<composite-element class="org.hibernate.test.legacy.ComponentNotNullMaster$ContainerInnerClass">
<composite-element class="org.hibernate.test.legacy.ComponentNotNullRoot$ContainerInnerClass">
<property name="name"/>
<property name="count" column="count_"/>
<many-to-one name="simple" not-null="true" cascade="save-update"/>
@ -40,15 +40,15 @@
</composite-element>
</list>
<list name="componentsImplicit" lazy="true" table="CompNotNullMaster_CompsImpl">
<list name="componentsImplicit" lazy="true" table="CompNotNullRoot_CompsImpl">
<key column = "container_id"/>
<index column = "list_index3"/>
<composite-element class="org.hibernate.test.legacy.ComponentNotNullMaster$ContainerInnerClass">
<composite-element class="org.hibernate.test.legacy.ComponentNotNullRoot$ContainerInnerClass">
<property name="name"/>
<property name="count" column="count_"/>
<many-to-one name="simple" cascade="save-update"/>
<many-to-one name="one" cascade="save-update"/>
<nested-composite-element name="nested" class="org.hibernate.test.legacy.ComponentNotNullMaster$ContainerInnerClass">
<nested-composite-element name="nested" class="org.hibernate.test.legacy.ComponentNotNullRoot$ContainerInnerClass">
<property name="nestedproperty" not-null="true"/>
</nested-composite-element>
</composite-element>

View File

@ -4,9 +4,8 @@
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
//$Id: ComponentNotNullMaster.java 4599 2004-09-26 05:18:27Z oneovthafew $
package org.hibernate.test.legacy;
import java.util.List;
/**
@ -14,7 +13,7 @@ import java.util.List;
*
* @author Emmanuel Bernard
*/
public class ComponentNotNullMaster {
public class ComponentNotNullRoot {
private int id;
private String test;

View File

@ -26,7 +26,7 @@ public class ComponentNotNullTest extends LegacyTestCase {
@Override
public String[] getMappings() {
return new String[] {
"legacy/ComponentNotNullMaster.hbm.xml",
"legacy/ComponentNotNullRoot.hbm.xml",
"legacy/One.hbm.xml",
"legacy/Many.hbm.xml",
"legacy/Simple.hbm.xml" };
@ -45,16 +45,16 @@ public class ComponentNotNullTest extends LegacyTestCase {
//
Session s = openSession();
Transaction t = s.beginTransaction();
ComponentNotNullMaster master = new ComponentNotNullMaster();
ComponentNotNullRoot root = new ComponentNotNullRoot();
ComponentNotNull nullable = new ComponentNotNull();
ComponentNotNull supercomp = new ComponentNotNull();
ComponentNotNull subcomp = new ComponentNotNull();
master.setNullable(nullable);
root.setNullable(nullable);
subcomp.setProp1Subcomp("test");
supercomp.setSubcomp(subcomp);
master.setSupercomp(supercomp);
s.save(master);
root.setSupercomp(supercomp);
s.save(root);
t.commit();
s.close();
@ -63,20 +63,20 @@ public class ComponentNotNullTest extends LegacyTestCase {
s = openSession();
t = s.beginTransaction();
master = new ComponentNotNullMaster();
root = new ComponentNotNullRoot();
nullable = new ComponentNotNull();
supercomp = new ComponentNotNull();
subcomp = new ComponentNotNull();
master.setNullable(nullable);
root.setNullable(nullable);
// do not set property
//subcomp.setProp1Subcomp("test");
supercomp.setSubcomp(subcomp);
master.setSupercomp(supercomp);
root.setSupercomp(supercomp);
try {
s.save(master);
s.save(root);
t.commit();
fail("Inserting not-null null property should fail");
} catch (PropertyValueException e) {
@ -90,20 +90,20 @@ public class ComponentNotNullTest extends LegacyTestCase {
s = openSession();
t = s.beginTransaction();
master = new ComponentNotNullMaster();
root = new ComponentNotNullRoot();
nullable = new ComponentNotNull();
supercomp = new ComponentNotNull();
subcomp = new ComponentNotNull();
master.setNullable(nullable);
// do not set supercomp for master
root.setNullable(nullable);
// do not set supercomp for root
//subcomp.setProp1Subcomp("test");
//supercomp.setSubcomp(subcomp);
//master.setSupercomp(supercomp);
//root.setSupercomp(supercomp);
try {
s.save(master);
s.save(root);
t.commit();
fail("Inserting not-null null property should fail");
} catch (PropertyValueException e) {
@ -118,23 +118,23 @@ public class ComponentNotNullTest extends LegacyTestCase {
//composite-element nullable
Session s = openSession();
Transaction t = s.beginTransaction();
ComponentNotNullMaster master = new ComponentNotNullMaster();
ComponentNotNullRoot root = new ComponentNotNullRoot();
ComponentNotNull nullable = new ComponentNotNull();
ComponentNotNull supercomp = new ComponentNotNull();
ComponentNotNull subcomp = new ComponentNotNull();
master.setNullable(nullable);
root.setNullable(nullable);
subcomp.setProp1Subcomp("test");
supercomp.setSubcomp(subcomp);
master.setSupercomp(supercomp);
root.setSupercomp(supercomp);
master.setComponents(new ArrayList());
ComponentNotNullMaster.ContainerInnerClass cc =
new ComponentNotNullMaster.ContainerInnerClass();
master.getComponents().add(cc);
root.setComponents(new ArrayList());
ComponentNotNullRoot.ContainerInnerClass cc =
new ComponentNotNullRoot.ContainerInnerClass();
root.getComponents().add(cc);
try {
s.save(master);
s.save(root);
t.commit();
fail("Inserting not-null many-to-one should fail");
} catch (PropertyValueException e) {
@ -148,26 +148,26 @@ public class ComponentNotNullTest extends LegacyTestCase {
s = openSession();
t = s.beginTransaction();
master = new ComponentNotNullMaster();
root = new ComponentNotNullRoot();
nullable = new ComponentNotNull();
supercomp = new ComponentNotNull();
subcomp = new ComponentNotNull();
master.setNullable(nullable);
root.setNullable(nullable);
subcomp.setProp1Subcomp("test");
supercomp.setSubcomp(subcomp);
master.setSupercomp(supercomp);
root.setSupercomp(supercomp);
master.setComponentsImplicit(new ArrayList());
ComponentNotNullMaster.ContainerInnerClass nestedCc =
new ComponentNotNullMaster.ContainerInnerClass();
root.setComponentsImplicit(new ArrayList());
ComponentNotNullRoot.ContainerInnerClass nestedCc =
new ComponentNotNullRoot.ContainerInnerClass();
cc =
new ComponentNotNullMaster.ContainerInnerClass();
new ComponentNotNullRoot.ContainerInnerClass();
cc.setNested(nestedCc);
master.getComponentsImplicit().add(cc);
root.getComponentsImplicit().add(cc);
try {
s.save(master);
s.save(root);
t.commit();
fail("Inserting not-null null property should fail");
} catch (PropertyValueException e) {
@ -181,26 +181,26 @@ public class ComponentNotNullTest extends LegacyTestCase {
s = openSession();
t = s.beginTransaction();
master = new ComponentNotNullMaster();
root = new ComponentNotNullRoot();
nullable = new ComponentNotNull();
supercomp = new ComponentNotNull();
subcomp = new ComponentNotNull();
master.setNullable(nullable);
root.setNullable(nullable);
subcomp.setProp1Subcomp("test");
supercomp.setSubcomp(subcomp);
master.setSupercomp(supercomp);
root.setSupercomp(supercomp);
master.setComponentsImplicit(new ArrayList());
root.setComponentsImplicit(new ArrayList());
nestedCc =
new ComponentNotNullMaster.ContainerInnerClass();
new ComponentNotNullRoot.ContainerInnerClass();
cc =
new ComponentNotNullMaster.ContainerInnerClass();
new ComponentNotNullRoot.ContainerInnerClass();
cc.setNested(nestedCc);
nestedCc.setNestedproperty("test");
master.getComponentsImplicit().add(cc);
root.getComponentsImplicit().add(cc);
s.save(master);
s.save(root);
t.commit();
s.close();
}

View File

@ -13,7 +13,7 @@ import java.util.Set;
public class Detail implements Serializable {
private Master master;
private Root root;
private int i;
private Set details = new HashSet();
private int x;
@ -25,12 +25,12 @@ public class Detail implements Serializable {
this.x = x;
}
public Master getMaster() {
return master;
public Root getRoot() {
return root;
}
public void setMaster(Master master) {
this.master = master;
public void setRoot(Root root) {
this.root = root;
}
public int getI() {

View File

@ -663,7 +663,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");
@ -689,10 +689,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();
@ -703,29 +703,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();
}

View File

@ -47,7 +47,7 @@
<class name="org.hibernate.test.legacy.Outer" table="CID_OUT">
<composite-id name="id">
<key-many-to-one name="master">
<key-many-to-one name="root">
<column length="10" name="AKEY"/>
<column length="10" name="BKEY"/>
<column length="10" name="ONE"/>

View File

@ -34,9 +34,9 @@ public class Middle implements Serializable {
if (this == o) return true;
if (!(o instanceof Middle)) return false;
final Middle cidMaster = (Middle) o;
final Middle cidMiddle = (Middle) o;
if (id != null ? !id.equals(cidMaster.id) : cidMaster.id != null) return false;
if (id != null ? !id.equals(cidMiddle.id) : cidMiddle.id != null) return false;
return true;
}

View File

@ -43,11 +43,11 @@ public class MiddleKey implements Serializable {
if (this == o) return true;
if (!(o instanceof MiddleKey)) return false;
final MiddleKey cidMasterID = (MiddleKey) o;
final MiddleKey cidMiddleKey = (MiddleKey) o;
if (one != null ? !one.equals(cidMasterID.one) : cidMasterID.one != null) return false;
if (sup != null ? !sup.equals(cidMasterID.sup) : cidMasterID.sup != null) return false;
if (two != null ? !two.equals(cidMasterID.two) : cidMasterID.two != null) return false;
if (one != null ? !one.equals(cidMiddleKey.one) : cidMiddleKey.one != null) return false;
if (sup != null ? !sup.equals(cidMiddleKey.sup) : cidMiddleKey.sup != null) return false;
if (two != null ? !two.equals(cidMiddleKey.two) : cidMiddleKey.two != null) return false;
return true;
}

View File

@ -11,15 +11,15 @@ import java.io.Serializable;
* @author Stefano Travelli
*/
public class OuterKey implements Serializable {
private Middle master;
private Middle root;
private String detailId;
public Middle getMaster() {
return master;
public Middle getRoot() {
return root;
}
public void setMaster(Middle master) {
this.master = master;
public void setRoot(Middle root) {
this.root = root;
}
public String getDetailId() {
@ -37,14 +37,14 @@ public class OuterKey implements Serializable {
final OuterKey cidDetailID = (OuterKey) o;
if (detailId != null ? !detailId.equals(cidDetailID.detailId) : cidDetailID.detailId != null) return false;
if (master != null ? !master.equals(cidDetailID.master) : cidDetailID.master != null) return false;
if ( root != null ? !root.equals(cidDetailID.root ) : cidDetailID.root != null) return false;
return true;
}
public int hashCode() {
int result;
result = (master != null ? master.hashCode() : 0);
result = ( root != null ? root.hashCode() : 0);
result = 29 * result + (detailId != null ? detailId.hashCode() : 0);
return result;
}

View File

@ -39,9 +39,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);
@ -58,9 +58,9 @@ public class QueryByExampleTest extends LegacyTestCase {
initData();
Session s = openSession();
Transaction t = s.beginTransaction();
Componentizable master = getMaster("hibernate", null, "ope%");
Componentizable componentizeable = getComponentizeable("hibernate", null, "ope%");
Criteria crit = s.createCriteria(Componentizable.class);
Example ex = Example.create(master).enableLike();
Example ex = Example.create(componentizeable).enableLike();
crit.add(Restrictions.or(Restrictions.not(ex), ex));
@ -78,18 +78,18 @@ public class QueryByExampleTest extends LegacyTestCase {
initData();
Session s = openSession();
Transaction t = s.beginTransaction();
Componentizable master = getMaster("hibernate", null, "ope%");
Componentizable componentizeable = getComponentizeable("hibernate", null, "ope%");
Criteria crit = s.createCriteria(Componentizable.class);
Example ex = Example.create(master).enableLike()
Example ex = Example.create(componentizeable).enableLike()
.excludeProperty("component.subComponent");
crit.add(ex);
List result = crit.list();
assertNotNull(result);
assertEquals(3, result.size());
master = getMaster("hibernate", "ORM tool", "fake stuff");
componentizeable = getComponentizeable("hibernate", "ORM tool", "fake stuff");
crit = s.createCriteria(Componentizable.class);
ex = Example.create(master).enableLike()
ex = Example.create(componentizeable).enableLike()
.excludeProperty("component.subComponent.subName1");
crit.add(ex);
result = crit.list();
@ -104,12 +104,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 componentizeable = getComponentizeable("hibernate", "ORM tool", "ORM tool1");
s.saveOrUpdate(componentizeable);
componentizeable = getComponentizeable("hibernate", "open source", "open source1");
s.saveOrUpdate(componentizeable);
componentizeable = getComponentizeable("hibernate", null, null);
s.saveOrUpdate(componentizeable);
t.commit();
s.close();
}
@ -124,19 +124,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 componentizable = 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);
componentizable.setComponent(component);
}
return master;
return componentizable;
}
}

View File

@ -4,9 +4,8 @@
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
//$Id: Master.java 4599 2004-09-26 05:18:27Z oneovthafew $
package org.hibernate.test.legacy;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Collection;
@ -14,21 +13,21 @@ import java.util.Date;
import java.util.HashSet;
import java.util.Set;
public class Master implements Serializable, Named {
public class Root implements Serializable, Named {
private Long id;
private Master otherMaster;
private Root otherRoot;
private Set details = new HashSet();
private Set moreDetails = new HashSet();
private Set incoming = new HashSet();
private Set outgoing = new HashSet();
private String name="master";
private String name="root";
private Date stamp;
private int version;
private BigDecimal bigDecimal = new BigDecimal("1234.123");
private int x;
private Collection allDetails;
public Master() {
public Root() {
}
public Long getId() {
@ -63,19 +62,19 @@ public class Master implements Serializable, Named {
details.remove(d);
}
public void addIncoming(Master m) {
public void addIncoming(Root m) {
incoming.add(m);
}
public void removeIncoming(Master m) {
public void removeIncoming(Root m) {
incoming.remove(m);
}
public void addOutgoing(Master m) {
public void addOutgoing(Root m) {
outgoing.add(m);
}
public void removeOutgoing(Master m) {
public void removeOutgoing(Root m) {
outgoing.remove(m);
}
@ -130,15 +129,15 @@ public class Master implements Serializable, Named {
/**
* @return
*/
public Master getOtherMaster() {
return otherMaster;
public Root getOtherRoot() {
return otherRoot;
}
/**
* @param master
* @param root
*/
public void setOtherMaster(Master master) {
otherMaster = master;
public void setOtherRoot(Root root) {
otherRoot = root;
}
/**

View File

@ -11,9 +11,9 @@
<hibernate-mapping default-lazy="false">
<class name="org.hibernate.test.legacy.Master" table="`master`">
<class name="org.hibernate.test.legacy.Root" table="`root`">
<meta attribute="foo">foo</meta>
<id name="id" column="master_key_column" type="long">
<id name="id" column="root_key_column" type="long">
<generator class="native"/>
</id>
<version name="version" access="field"/>
@ -26,24 +26,24 @@
<property name="x"/>
<property name="bigDecimal" column="big_dec" precision="7" scale="3"/>
<set name="details" inverse="true" lazy="true" order-by="i asc">
<key column="master_key"/>
<key column="root_key"/>
<one-to-many class="org.hibernate.test.legacy.Detail"/>
</set>
<set name="moreDetails" cascade="all" lazy="true" order-by="i desc">
<key column="more_master_key"/>
<key column="more_root_key"/>
<one-to-many class="org.hibernate.test.legacy.Detail"/>
</set>
<set name="incoming" lazy="true" table="mtm">
<key foreign-key="AA" column="outgoingabcdef"/>
<many-to-many class="org.hibernate.test.legacy.Master" foreign-key="BB">
<many-to-many class="org.hibernate.test.legacy.Root" foreign-key="BB">
<column name="incomingabcdef" index="IBB"/>
</many-to-many>
</set>
<set name="outgoing" lazy="true" table="mtm" inverse="true">
<key column="incomingabcdef"/>
<many-to-many class="org.hibernate.test.legacy.Master" column="outgoingabcdef"/>
<many-to-many class="org.hibernate.test.legacy.Root" column="outgoingabcdef"/>
</set>
<many-to-one name="otherMaster"/>
<many-to-one name="otherRoot"/>
<!--query-list name="allDetails" query-ref="all_details"/-->
</class>
@ -57,8 +57,8 @@
<property name="i">
<column name="i" unique-key="uk" not-null="true"/>
</property>
<many-to-one name="master" foreign-key="CC"> <!--not-null="true"-->
<column name="master_key" unique-key="uk" not-null="true"/>
<many-to-one name="root" foreign-key="CC"> <!--not-null="true"-->
<column name="root_key" unique-key="uk" not-null="true"/>
</many-to-one>
<!-- <cache timeout="10000" type="readwrite"/> -->
<set name="subDetails" lazy="true" cascade="all">

View File

@ -34,11 +34,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",
@ -87,15 +87,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 {
@ -196,19 +187,19 @@ public class MasterDetailTest extends LegacyTestCase {
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);
@ -221,41 +212,41 @@ public class MasterDetailTest extends LegacyTestCase {
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);
@ -307,39 +298,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);
root.addDetail(d1);
root.addDetail(d2);
if ( !(getDialect() instanceof MySQLDialect) && !(getDialect() instanceof SAPDBDialect) && !(getDialect() instanceof MckoiDialect) && !(getDialect() instanceof org.hibernate.dialect.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
);
}
@ -348,42 +339,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);
@ -392,25 +383,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();
@ -418,14 +406,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 );
@ -436,38 +424,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) );
@ -475,21 +463,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();
}
@ -498,19 +486,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
);
@ -519,18 +507,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();
}
@ -542,11 +530,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);
@ -555,11 +543,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();
}
@ -578,13 +566,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 );
@ -594,7 +582,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");
@ -622,11 +610,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);
@ -636,12 +624,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();
}

View File

@ -12,6 +12,6 @@
<hibernate-mapping package="org.hibernate.test.fileimport">
<class name="Dog" table="dog">
<id name="id"/>
<many-to-one name="master" column="master_fk"/>
<many-to-one name="owner" column="owner_fk"/>
</class>
</hibernate-mapping>

View File

@ -1,3 +1,3 @@
INSERT INTO dog (id, master_fk) VALUES (1,1)
INSERT INTO dog (id, master_fk) VALUES (2,2)
INSERT INTO dog (id, master_fk) VALUES (3,3)
INSERT INTO dog (id, owner_fk) VALUES (1,1)
INSERT INTO dog (id, owner_fk) VALUES (2,2)
INSERT INTO dog (id, owner_fk) VALUES (3,3)

View File

@ -15,7 +15,7 @@ public class DetailSuperclass {
private long id;
private List<Master> masters;
private List<Root> roots;
public DetailSuperclass() {
@ -29,12 +29,12 @@ public class DetailSuperclass {
this.id = id;
}
public List<Master> getMasters() {
return masters;
public List<Root> getRoots() {
return roots;
}
public void setMasters(List<Master> masters) {
this.masters = masters;
public void setRoots(List<Root> roots) {
this.roots = roots;
}
}

View File

@ -30,7 +30,7 @@ public class ManyToManyInverseToSuperclassTest extends BaseEnversJPAFunctionalTe
public void initData() {
EntityManager em = getEntityManager();
Master m1 = new Master();
Root m1 = new Root();
DetailSubclass det1 = new DetailSubclass2();
// Revision 1
@ -38,66 +38,24 @@ public class ManyToManyInverseToSuperclassTest extends BaseEnversJPAFunctionalTe
det1.setStr2( "detail 1" );
m1.setStr( "master" );
m1.setStr( "root" );
m1.setItems( new ArrayList<DetailSubclass>() );
m1.getItems().add( det1 );
det1.setMasters( new ArrayList<Master>() );
det1.getMasters().add( m1 );
det1.setRoots( new ArrayList<Root>() );
det1.getRoots().add( m1 );
em.persist( m1 );
em.getTransaction().commit();
m1_id = m1.getId();
// Revision 2
// em.getTransaction().begin();
//
// m1 = em.find(Master.class, m1_id);
//
// det2.setStr2("detail 2");
// det2.setParent(m1);
// m1.getItems().add(det2);
// em.getTransaction().commit();
//
// // Revision 3
// em.getTransaction().begin();
//
// m1 = em.find(Master.class, m1_id);
// m1.setStr("new master");
//
// det1 = m1.getItems().get(0);
// det1.setStr2("new detail");
// DetailSubclass det3 = new DetailSubclass2();
// det3.setStr2("detail 3");
// det3.setParent(m1);
//
// m1.getItems().get(1).setParent(null);
// // m1.getItems().remove(1);
// m1.getItems().add(det3);
//
// em.persist(m1);
// em.getTransaction().commit();
//
// // Revision 4
// em.getTransaction().begin();
//
// m1 = em.find(Master.class, m1_id);
//
// det1 = m1.getItems().get(0);
// det1.setParent(null);
// // m1.getItems().remove(det1);
//
// em.persist(m1);
// em.getTransaction().commit();
}
@Test
public void testHistoryExists() {
Master rev1_1 = getAuditReader().find( Master.class, m1_id, 1 );
Master rev1_2 = getAuditReader().find( Master.class, m1_id, 2 );
Master rev1_3 = getAuditReader().find( Master.class, m1_id, 3 );
Master rev1_4 = getAuditReader().find( Master.class, m1_id, 4 );
Root rev1_1 = getAuditReader().find( Root.class, m1_id, 1 );
Root rev1_2 = getAuditReader().find( Root.class, m1_id, 2 );
Root rev1_3 = getAuditReader().find( Root.class, m1_id, 3 );
Root rev1_4 = getAuditReader().find( Root.class, m1_id, 4 );
assert (rev1_1 != null);
assert (rev1_2 != null);

View File

@ -11,7 +11,7 @@ import java.util.List;
import org.hibernate.envers.Audited;
@Audited
public class Master {
public class Root {
private long id;
@ -19,7 +19,7 @@ public class Master {
private List<DetailSubclass> items;
public Master() {
public Root() {
}

View File

@ -48,16 +48,16 @@ public class ManyToOneNotInsertable extends BaseEnversJPAFunctionalTestCase {
// Rev 2
em.getTransaction().begin();
ManyToOneNotInsertableEntity master = new ManyToOneNotInsertableEntity( mto_id1, type_id1, type1 );
em.persist( master );
ManyToOneNotInsertableEntity entity = new ManyToOneNotInsertableEntity( mto_id1, type_id1, type1 );
em.persist( entity );
em.getTransaction().commit();
// Rev 2
em.getTransaction().begin();
master = em.find( ManyToOneNotInsertableEntity.class, mto_id1 );
master.setNumber( type_id2 );
entity = em.find( ManyToOneNotInsertableEntity.class, mto_id1 );
entity.setNumber( type_id2 );
em.getTransaction().commit();
}

View File

@ -13,7 +13,7 @@ public class DetailSuperclass {
private long id;
private Master parent;
private Root parent;
public DetailSuperclass() {
@ -27,11 +27,11 @@ public class DetailSuperclass {
this.id = id;
}
public Master getParent() {
public Root getParent() {
return parent;
}
public void setParent(Master parent) {
public void setParent(Root parent) {
this.parent = parent;
}

View File

@ -32,7 +32,7 @@ public class OneToManyInverseToSuperclassTest extends BaseEnversJPAFunctionalTes
public void initData() {
EntityManager em = getEntityManager();
Master m1 = new Master();
Root m1 = new Root();
DetailSubclass det1 = new DetailSubclass2();
DetailSubclass det2 = new DetailSubclass2();
@ -41,7 +41,7 @@ public class OneToManyInverseToSuperclassTest extends BaseEnversJPAFunctionalTes
det1.setStr2( "detail 1" );
m1.setStr( "master" );
m1.setStr( "root" );
m1.setItems( new ArrayList<DetailSubclass>() );
m1.getItems().add( det1 );
det1.setParent( m1 );
@ -53,7 +53,7 @@ public class OneToManyInverseToSuperclassTest extends BaseEnversJPAFunctionalTes
// Revision 2
em.getTransaction().begin();
m1 = em.find( Master.class, m1_id );
m1 = em.find( Root.class, m1_id );
det2.setStr2( "detail 2" );
det2.setParent( m1 );
@ -63,8 +63,8 @@ public class OneToManyInverseToSuperclassTest extends BaseEnversJPAFunctionalTes
// Revision 3
em.getTransaction().begin();
m1 = em.find( Master.class, m1_id );
m1.setStr( "new master" );
m1 = em.find( Root.class, m1_id );
m1.setStr( "new root" );
det1 = m1.getItems().get( 0 );
det1.setStr2( "new detail" );
@ -82,7 +82,7 @@ public class OneToManyInverseToSuperclassTest extends BaseEnversJPAFunctionalTes
// Revision 4
em.getTransaction().begin();
m1 = em.find( Master.class, m1_id );
m1 = em.find( Root.class, m1_id );
det1 = m1.getItems().get( 0 );
det1.setParent( null );
@ -95,10 +95,10 @@ public class OneToManyInverseToSuperclassTest extends BaseEnversJPAFunctionalTes
@Test
public void testHistoryExists() {
Master rev1_1 = getAuditReader().find( Master.class, m1_id, 1 );
Master rev1_2 = getAuditReader().find( Master.class, m1_id, 2 );
Master rev1_3 = getAuditReader().find( Master.class, m1_id, 3 );
Master rev1_4 = getAuditReader().find( Master.class, m1_id, 4 );
Root rev1_1 = getAuditReader().find( Root.class, m1_id, 1 );
Root rev1_2 = getAuditReader().find( Root.class, m1_id, 2 );
Root rev1_3 = getAuditReader().find( Root.class, m1_id, 3 );
Root rev1_4 = getAuditReader().find( Root.class, m1_id, 4 );
assert (rev1_1 != null);
assert (rev1_2 != null);

View File

@ -11,7 +11,7 @@ import java.util.List;
import org.hibernate.envers.Audited;
@Audited
public class Master {
public class Root {
private long id;
@ -19,7 +19,7 @@ public class Master {
private List<DetailSubclass> items;
public Master() {
public Root() {
}

View File

@ -9,8 +9,8 @@
<hibernate-mapping>
<class
name="org.hibernate.envers.test.integration.manytomany.inverseToSuperclass.Master"
table="HIB_MASTER_ENTITY">
name="org.hibernate.envers.test.integration.manytomany.inverseToSuperclass.Root"
table="HIB_ROOT_ENTITY">
<id name="id" column="ID" type="long">
<generator class="increment" />
@ -19,8 +19,8 @@
<property name="str" column="STR" />
<bag name="items" lazy="true" cascade="all" access="property" inverse="true"
table="HIB_MASTER_DETAIL">
<key column="ID_MASTER" />
table="HIB_ROOT_DETAIL">
<key column="ID_ROOT" />
<many-to-many
class="org.hibernate.envers.test.integration.manytomany.inverseToSuperclass.DetailSubclass2"
column="ID_DETAIL" />
@ -36,11 +36,11 @@
</id>
<discriminator column="DISCRIMINATOR" type="string" />
<bag name="masters" lazy="true" access="property" table="HIB_MASTER_DETAIL">
<bag name="roots" lazy="true" access="property" table="HIB_ROOT_DETAIL">
<key column="ID_DETAIL" />
<many-to-many
class="org.hibernate.envers.test.integration.manytomany.inverseToSuperclass.Master"
column="ID_MASTER" />
class="org.hibernate.envers.test.integration.manytomany.inverseToSuperclass.Root"
column="ID_ROOT" />
</bag>
<subclass

View File

@ -9,8 +9,8 @@
<hibernate-mapping>
<class
name="org.hibernate.envers.test.integration.onetomany.inverseToSuperclass.Master"
table="HIB_MASTER_ENTITY">
name="org.hibernate.envers.test.integration.onetomany.inverseToSuperclass.Root"
table="HIB_ROOT_ENTITY">
<id name="id" column="ID" type="long">
<generator class="increment" />
@ -20,7 +20,7 @@
<bag name="items" lazy="true" cascade="all" access="property"
inverse="true">
<key column="ID_MASTER" />
<key column="ID_ROOT" />
<one-to-many
class="org.hibernate.envers.test.integration.onetomany.inverseToSuperclass.DetailSubclass2" />
</bag>
@ -35,8 +35,8 @@
</id>
<discriminator column="DISCRIMINATOR" type="string" />
<many-to-one name="parent" column="ID_MASTER"
class="org.hibernate.envers.test.integration.onetomany.inverseToSuperclass.Master" />
<many-to-one name="parent" column="ID_ROOT"
class="org.hibernate.envers.test.integration.onetomany.inverseToSuperclass.Root" />
<subclass
name="org.hibernate.envers.test.integration.onetomany.inverseToSuperclass.DetailSubclass"

View File

@ -31,6 +31,12 @@
<property name="message" value="Line has leading space characters; indentation should be performed with tabs only." />
</module>
<module name="Regexp">
<property name="format" value="/^(master|slave)$/"/>
<property name="illegalPattern" value="true"/>
<property name="message" value="Conscious Language (use of terms 'master' or 'slave' not allowed)"/>
</module>
<module name="MissingDeprecated" />
<module name="MissingOverride" />

View File

@ -15,7 +15,7 @@ There are a number of tenants that make up a good test case as opposed to a poor
== Test templates
The Hibernate team maintains a set of "test templates" intended to help developers write tests. These test templates are maintained in GitHub @ https://github.com/hibernate/hibernate-test-case-templates/tree/master/orm[hibernate-test-case-templates]
The Hibernate team maintains a set of "test templates" intended to help developers write tests. These test templates are maintained in GitHub @ https://github.com/hibernate/hibernate-test-case-templates/tree/main/orm[hibernate-test-case-templates]
* If you want to use the Hibernate native API, you should follow the instructions from http://in.relation.to/2015/06/26/hibernate-test-case-templates/[this article].
* If you want to use JPA, you should use the JPA templates that were detailed in http://in.relation.to/2016/01/14/hibernate-jpa-test-case-template/[this article].

View File

@ -86,7 +86,7 @@ public class AccessTypeTest extends CompilationTest {
@TestForIssue(jiraKey = " METAGEN-81")
public void testAccessTypeForEmbeddableDeterminedByIdAnnotationInRootEntity() {
assertPresenceOfFieldInMetamodelFor(
Hotel.class, "webmaster",
Hotel.class, "webDomainExpert",
"Access type should be inherited position of the @Id field annotation in the root entity"
);
}

View File

@ -16,13 +16,13 @@ import javax.persistence.OneToOne;
public class Hotel {
@OneToOne
private User webmaster;
private User webDomainExpert;
public User getWebmaster() {
return webmaster;
public User getWebDomainExpert() {
return webDomainExpert;
}
public void setWebmaster(User webmaster) {
this.webmaster = webmaster;
public void setWebDomainExpert(User webDomainExpert) {
this.webDomainExpert = webDomainExpert;
}
}