HHH-14509 : Git master -> main branch renaming
This commit is contained in:
parent
b4bf58188c
commit
725faa258f
|
@ -9,11 +9,11 @@ name: Hibernate ORM build
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- 'master'
|
- 'main'
|
||||||
- 'wip/6.0'
|
- 'wip/6.0'
|
||||||
pull_request:
|
pull_request:
|
||||||
branches:
|
branches:
|
||||||
- 'master'
|
- 'main'
|
||||||
- 'wip/6.0'
|
- 'wip/6.0'
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
|
|
|
@ -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._
|
_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
|
Assuming you will be working from the `main` branch and working
|
||||||
on the JIRA HHH-123 : `git checkout -b HHH-123 master`
|
on the JIRA HHH-123 : `git checkout -b HHH-123 main`
|
||||||
|
|
||||||
|
|
||||||
## Code
|
## Code
|
||||||
|
|
|
@ -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.
|
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)
|
[![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
|
Building from sources
|
||||||
|
|
|
@ -190,7 +190,7 @@ hibernate.connection.url jdbc:hsqldb:./build/db/hsqldb/hibernate
|
||||||
|
|
||||||
#hibernate.dialect org.hibernate.dialect.InterbaseDialect
|
#hibernate.dialect org.hibernate.dialect.InterbaseDialect
|
||||||
#hibernate.connection.username sysdba
|
#hibernate.connection.username sysdba
|
||||||
#hibernate.connection.password masterkey
|
#hibernate.connection.password thekey
|
||||||
|
|
||||||
## DO NOT specify hibernate.connection.sqlDialect
|
## DO NOT specify hibernate.connection.sqlDialect
|
||||||
|
|
||||||
|
|
|
@ -169,7 +169,7 @@ hibernate.connection.url @DB_URL@
|
||||||
|
|
||||||
#hibernate.dialect org.hibernate.dialect.InterbaseDialect
|
#hibernate.dialect org.hibernate.dialect.InterbaseDialect
|
||||||
#hibernate.connection.username sysdba
|
#hibernate.connection.username sysdba
|
||||||
#hibernate.connection.password masterkey
|
#hibernate.connection.password thepass
|
||||||
|
|
||||||
## DO NOT specify hibernate.connection.sqlDialect
|
## DO NOT specify hibernate.connection.sqlDialect
|
||||||
|
|
||||||
|
|
|
@ -1669,7 +1669,7 @@ public interface CoreMessageLogger extends BasicLogger {
|
||||||
)
|
)
|
||||||
void applyingExplicitDiscriminatorColumnForJoined(String className, String overrideSetting);
|
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)
|
@LogMessage(level = DEBUG)
|
||||||
@Message(value = "Creating pooled optimizer (lo) with [incrementSize=%s; returnClass=%s]", id = 467)
|
@Message(value = "Creating pooled optimizer (lo) with [incrementSize=%s; returnClass=%s]", id = 467)
|
||||||
|
|
|
@ -26,7 +26,7 @@ public class FormalLastName {
|
||||||
@Embedded
|
@Embedded
|
||||||
private LastName lastName;
|
private LastName lastName;
|
||||||
|
|
||||||
private String designation; /* Mr/Mrs/Master */
|
private String designation; /* Mr/Mrs */
|
||||||
|
|
||||||
public Integer getId() {
|
public Integer getId() {
|
||||||
return id;
|
return id;
|
||||||
|
|
|
@ -12,7 +12,7 @@ package org.hibernate.test.fileimport;
|
||||||
*/
|
*/
|
||||||
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,7 +21,7 @@ public class AnnotatedFormWithBeanValidationNotNullTest extends BaseUnitTestCase
|
||||||
@TestForIssue( jiraKey = "HHH-8167" )
|
@TestForIssue( jiraKey = "HHH-8167" )
|
||||||
public void testAnnotatedFormWithBeanValidationNotNull() {
|
public void testAnnotatedFormWithBeanValidationNotNull() {
|
||||||
Configuration cfg = new Configuration();
|
Configuration cfg = new Configuration();
|
||||||
cfg.addAnnotatedClass( AnnotatedMaster.class ).addAnnotatedClass( AnnotatedDetail.class );
|
cfg.addAnnotatedClass( AnnotatedRoot.class ).addAnnotatedClass( AnnotatedDetail.class );
|
||||||
cfg.buildSessionFactory().close();
|
cfg.buildSessionFactory().close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,7 +22,7 @@ import org.hibernate.annotations.JoinFormula;
|
||||||
* @author Steve Ebersole
|
* @author Steve Ebersole
|
||||||
*/
|
*/
|
||||||
@Entity
|
@Entity
|
||||||
public class AnnotatedMaster {
|
public class AnnotatedRoot {
|
||||||
@Id
|
@Id
|
||||||
private Integer id;
|
private Integer id;
|
||||||
private String name;
|
private String name;
|
|
@ -14,7 +14,7 @@ import java.io.Serializable;
|
||||||
*/
|
*/
|
||||||
public class Detail implements Serializable {
|
public class Detail implements Serializable {
|
||||||
private Long id;
|
private Long id;
|
||||||
private Master master;
|
private Root root;
|
||||||
private int version;
|
private int version;
|
||||||
private String details;
|
private String details;
|
||||||
private boolean currentVersion;
|
private boolean currentVersion;
|
||||||
|
@ -37,11 +37,11 @@ public class Detail implements Serializable {
|
||||||
public void setId(Long id) {
|
public void setId(Long id) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
}
|
}
|
||||||
public Master getMaster() {
|
public Root getRoot() {
|
||||||
return master;
|
return root;
|
||||||
}
|
}
|
||||||
public void setMaster(Master master) {
|
public void setRoot(Root root) {
|
||||||
this.master = master;
|
this.root = root;
|
||||||
}
|
}
|
||||||
public int getVersion() {
|
public int getVersion() {
|
||||||
return version;
|
return version;
|
||||||
|
|
|
@ -24,27 +24,27 @@ import static org.junit.Assert.assertTrue;
|
||||||
*/
|
*/
|
||||||
public class FormulaJoinTest extends BaseCoreFunctionalTestCase {
|
public class FormulaJoinTest extends BaseCoreFunctionalTestCase {
|
||||||
public String[] getMappings() {
|
public String[] getMappings() {
|
||||||
return new String[] { "formulajoin/Master.hbm.xml" };
|
return new String[] { "formulajoin/Root.hbm.xml" };
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFormulaJoin() {
|
public void testFormulaJoin() {
|
||||||
Session s = openSession();
|
Session s = openSession();
|
||||||
Transaction tx = s.beginTransaction();
|
Transaction tx = s.beginTransaction();
|
||||||
Master master = new Master();
|
Root root = new Root();
|
||||||
master.setName("master 1");
|
root.setName("root 1");
|
||||||
Detail current = new Detail();
|
Detail current = new Detail();
|
||||||
current.setCurrentVersion(true);
|
current.setCurrentVersion(true);
|
||||||
current.setVersion(2);
|
current.setVersion(2);
|
||||||
current.setDetails("details of master 1 blah blah");
|
current.setDetails("details of root 1 blah blah");
|
||||||
current.setMaster(master);
|
current.setRoot( root );
|
||||||
master.setDetail(current);
|
root.setDetail(current);
|
||||||
Detail past = new Detail();
|
Detail past = new Detail();
|
||||||
past.setCurrentVersion(false);
|
past.setCurrentVersion(false);
|
||||||
past.setVersion(1);
|
past.setVersion(1);
|
||||||
past.setDetails("old details of master 1 yada yada");
|
past.setDetails("old details of root 1 yada yada");
|
||||||
past.setMaster(master);
|
past.setRoot( root );
|
||||||
s.persist(master);
|
s.persist( root );
|
||||||
s.persist(past);
|
s.persist(past);
|
||||||
s.persist(current);
|
s.persist(current);
|
||||||
tx.commit();
|
tx.commit();
|
||||||
|
@ -54,42 +54,42 @@ public class FormulaJoinTest extends BaseCoreFunctionalTestCase {
|
||||||
|
|
||||||
s = openSession();
|
s = openSession();
|
||||||
tx = s.beginTransaction();
|
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 );
|
assertEquals( l.size(), 1 );
|
||||||
tx.commit();
|
tx.commit();
|
||||||
s.close();
|
s.close();
|
||||||
|
|
||||||
s = openSession();
|
s = openSession();
|
||||||
tx = s.beginTransaction();
|
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 );
|
assertEquals( l.size(), 1 );
|
||||||
Master m = (Master) l.get(0);
|
Root m = (Root) l.get(0);
|
||||||
assertEquals( "master 1", m.getDetail().getMaster().getName() );
|
assertEquals( "root 1", m.getDetail().getRoot().getName() );
|
||||||
assertTrue( m==m.getDetail().getMaster() );
|
assertTrue( m==m.getDetail().getRoot() );
|
||||||
tx.commit();
|
tx.commit();
|
||||||
s.close();
|
s.close();
|
||||||
|
|
||||||
s = openSession();
|
s = openSession();
|
||||||
tx = s.beginTransaction();
|
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 );
|
assertEquals( l.size(), 1 );
|
||||||
tx.commit();
|
tx.commit();
|
||||||
s.close();
|
s.close();
|
||||||
|
|
||||||
s = openSession();
|
s = openSession();
|
||||||
tx = s.beginTransaction();
|
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 );
|
assertEquals( l.size(), 2 );
|
||||||
tx.commit();
|
tx.commit();
|
||||||
s.close();
|
s.close();
|
||||||
|
|
||||||
s = openSession();
|
s = openSession();
|
||||||
tx = s.beginTransaction();
|
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 );
|
assertEquals( l.size(), 2 );
|
||||||
|
|
||||||
s.createQuery("delete from Detail").executeUpdate();
|
s.createQuery("delete from Detail").executeUpdate();
|
||||||
s.createQuery("delete from Master").executeUpdate();
|
s.createQuery("delete from Root").executeUpdate();
|
||||||
|
|
||||||
tx.commit();
|
tx.commit();
|
||||||
s.close();
|
s.close();
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
|
|
||||||
<hibernate-mapping package="org.hibernate.test.formulajoin">
|
<hibernate-mapping package="org.hibernate.test.formulajoin">
|
||||||
|
|
||||||
<class name="Master" table="t_masters">
|
<class name="Root" table="t_roots">
|
||||||
|
|
||||||
<id name="id">
|
<id name="id">
|
||||||
<generator class="increment"/>
|
<generator class="increment"/>
|
||||||
|
@ -30,7 +30,7 @@
|
||||||
update="false"/>
|
update="false"/>
|
||||||
|
|
||||||
<many-to-one name="detail"
|
<many-to-one name="detail"
|
||||||
property-ref="currentMaster"
|
property-ref="currentRoot"
|
||||||
insert="false"
|
insert="false"
|
||||||
update="false">
|
update="false">
|
||||||
<column name="id"/>
|
<column name="id"/>
|
||||||
|
@ -53,13 +53,13 @@
|
||||||
<property name="version" update="false">
|
<property name="version" update="false">
|
||||||
<column name="version"
|
<column name="version"
|
||||||
not-null="true"
|
not-null="true"
|
||||||
unique-key="masterVersion"/>
|
unique-key="rootVersion"/>
|
||||||
</property>
|
</property>
|
||||||
|
|
||||||
<properties name="currentMaster">
|
<properties name="currentRoot">
|
||||||
<many-to-one name="master">
|
<many-to-one name="root">
|
||||||
<column name="cur_master"
|
<column name="cur_root"
|
||||||
unique-key="masterVersion"
|
unique-key="rootVersion"
|
||||||
not-null="true"/>
|
not-null="true"/>
|
||||||
</many-to-one>
|
</many-to-one>
|
||||||
<property name="currentVersion"
|
<property name="currentVersion"
|
|
@ -4,15 +4,14 @@
|
||||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
* 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>.
|
* 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;
|
package org.hibernate.test.formulajoin;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Gavin King
|
* @author Gavin King
|
||||||
*/
|
*/
|
||||||
public class Master implements Serializable {
|
public class Root implements Serializable {
|
||||||
private Long id;
|
private Long id;
|
||||||
private String name;
|
private String name;
|
||||||
private Detail detail;
|
private Detail detail;
|
|
@ -21,45 +21,45 @@ public class DeleteQuerySubqueryReferencingTargetPropertyTest extends BaseEntity
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Class<?>[] getAnnotatedClasses() {
|
protected Class<?>[] getAnnotatedClasses() {
|
||||||
return new Class<?>[] { Master.class, Detail.class };
|
return new Class<?>[] { Root.class, Detail.class };
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSubQueryReferencingTargetProperty() {
|
public void testSubQueryReferencingTargetProperty() {
|
||||||
// prepare
|
// prepare
|
||||||
doInJPA( this::entityManagerFactory, entityManager -> {
|
doInJPA( this::entityManagerFactory, entityManager -> {
|
||||||
Master m1 = new Master();
|
Root m1 = new Root();
|
||||||
entityManager.persist( m1 );
|
entityManager.persist( m1 );
|
||||||
Detail d11 = new Detail( m1 );
|
Detail d11 = new Detail( m1 );
|
||||||
entityManager.persist( d11 );
|
entityManager.persist( d11 );
|
||||||
Detail d12 = new Detail( m1 );
|
Detail d12 = new Detail( m1 );
|
||||||
entityManager.persist( d12 );
|
entityManager.persist( d12 );
|
||||||
|
|
||||||
Master m2 = new Master();
|
Root m2 = new Root();
|
||||||
entityManager.persist( m2 );
|
entityManager.persist( m2 );
|
||||||
} );
|
} );
|
||||||
|
|
||||||
doInJPA( this::entityManagerFactory, entityManager -> {
|
doInJPA( this::entityManagerFactory, entityManager -> {
|
||||||
// depending on the generated ids above this delete removes all masters or nothing
|
// depending on the generated ids above this delete removes all Roots or nothing
|
||||||
// removal of all masters results in foreign key constraint violation
|
// removal of all Roots results in foreign key constraint violation
|
||||||
// removal of nothing is incorrect since 2nd master does not have any details
|
// 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
|
// DO NOT CHANGE this query: it used to trigger a very specific bug caused
|
||||||
// by the alias not being added to the generated query
|
// 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 );
|
Query del = entityManager.createQuery( d );
|
||||||
del.executeUpdate();
|
del.executeUpdate();
|
||||||
|
|
||||||
// so check for exactly one master after deletion
|
// so check for exactly one Root after deletion
|
||||||
CriteriaBuilder builder = entityManager.getCriteriaBuilder();
|
CriteriaBuilder builder = entityManager.getCriteriaBuilder();
|
||||||
CriteriaQuery<Master> query = builder.createQuery( Master.class );
|
CriteriaQuery<Root> query = builder.createQuery( Root.class );
|
||||||
query.select( query.from( Master.class ) );
|
query.select( query.from( Root.class ) );
|
||||||
Assert.assertEquals( 1, entityManager.createQuery( query ).getResultList().size() );
|
Assert.assertEquals( 1, entityManager.createQuery( query ).getResultList().size() );
|
||||||
} );
|
} );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Entity(name = "Master")
|
@Entity(name = "Root")
|
||||||
public static class Master {
|
public static class Root {
|
||||||
@Id
|
@Id
|
||||||
@GeneratedValue
|
@GeneratedValue
|
||||||
private Integer id;
|
private Integer id;
|
||||||
|
@ -72,10 +72,10 @@ public class DeleteQuerySubqueryReferencingTargetPropertyTest extends BaseEntity
|
||||||
private Integer id;
|
private Integer id;
|
||||||
|
|
||||||
@ManyToOne(optional = false)
|
@ManyToOne(optional = false)
|
||||||
private Master master;
|
private Root root;
|
||||||
|
|
||||||
public Detail(Master master) {
|
public Detail(Root root) {
|
||||||
this.master = master;
|
this.root = root;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -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 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.Inner" );
|
||||||
parse( "from org.hibernate.test.Outer o where o.id.detailId = ?" );
|
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.main.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( "from org.hibernate.test.Outer o where o.id.main.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.main.id.sup.dudu from org.hibernate.test.Outer o where o.id.main.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( "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.master.bla = ''" );
|
parse( "from org.hibernate.test.Outer o where o.id.main.bla = ''" );
|
||||||
parse( "from org.hibernate.test.Outer o where o.id.master.id.one = ''" );
|
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.master.id.sup.id.akey > 'a'" );
|
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.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.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.master.id.sup s 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.master m 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.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( "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( "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" );
|
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.Up up order by up.id2 asc" );
|
||||||
parse( "from org.hibernate.test.Down down" );
|
parse( "from org.hibernate.test.Down down" );
|
||||||
parse( "from org.hibernate.test.Up up" );
|
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.Several" );
|
||||||
parse( "from s in class org.hibernate.test.Single" );
|
parse( "from s in class org.hibernate.test.Single" );
|
||||||
parse( "\n" +
|
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 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 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 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.Root 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( "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.Master, 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 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.Root, 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( "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]
|
// 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 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'");
|
// 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'");
|
||||||
|
|
|
@ -61,7 +61,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",
|
||||||
|
|
|
@ -19,14 +19,14 @@ public class UpdateJoinedSubclassCorrelationTest extends BaseEntityManagerFuncti
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Class<?>[] getAnnotatedClasses() {
|
protected Class<?>[] getAnnotatedClasses() {
|
||||||
return new Class<?>[] { Master.class, SubMaster.class, Detail.class };
|
return new Class<?>[] { Root.class, SubRoot.class, Detail.class };
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testJoinedSubclassUpdateWithCorrelation() {
|
public void testJoinedSubclassUpdateWithCorrelation() {
|
||||||
// prepare
|
// prepare
|
||||||
doInJPA( this::entityManagerFactory, entityManager -> {
|
doInJPA( this::entityManagerFactory, entityManager -> {
|
||||||
Master m1 = new SubMaster( 1, null );
|
Root m1 = new SubRoot( 1, null );
|
||||||
entityManager.persist( m1 );
|
entityManager.persist( m1 );
|
||||||
Detail d11 = new Detail( 10, m1 );
|
Detail d11 = new Detail( 10, m1 );
|
||||||
entityManager.persist( d11 );
|
entityManager.persist( d11 );
|
||||||
|
@ -35,40 +35,40 @@ public class UpdateJoinedSubclassCorrelationTest extends BaseEntityManagerFuncti
|
||||||
doInJPA( this::entityManagerFactory, entityManager -> {
|
doInJPA( this::entityManagerFactory, entityManager -> {
|
||||||
// DO NOT CHANGE this query: it used to trigger a very specific bug caused
|
// 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
|
// 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 );
|
Query updateQuery = entityManager.createQuery( u );
|
||||||
updateQuery.executeUpdate();
|
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();
|
CriteriaBuilder builder = entityManager.getCriteriaBuilder();
|
||||||
CriteriaQuery<Master> query = builder.createQuery( Master.class );
|
CriteriaQuery<Root> query = builder.createQuery( Root.class );
|
||||||
query.select( query.from( Master.class ) );
|
query.select( query.from( Root.class ) );
|
||||||
List<Master> masters = entityManager.createQuery( query ).getResultList();
|
List<Root> roots = entityManager.createQuery( query ).getResultList();
|
||||||
Assert.assertEquals( 1, masters.size() );
|
Assert.assertEquals( 1, roots.size() );
|
||||||
Assert.assertEquals( "test", ((SubMaster) masters.get(0)).name );
|
Assert.assertEquals( "test", ((SubRoot) roots.get(0)).name );
|
||||||
} );
|
} );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Inheritance(strategy = JOINED)
|
@Inheritance(strategy = JOINED)
|
||||||
@Entity(name = "Master")
|
@Entity(name = "Root")
|
||||||
public static abstract class Master {
|
public static abstract class Root {
|
||||||
@Id
|
@Id
|
||||||
private Integer id;
|
private Integer id;
|
||||||
|
|
||||||
public Master() { }
|
public Root() { }
|
||||||
|
|
||||||
public Master( Integer id ) {
|
public Root(Integer id ) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Entity(name = "SubMaster")
|
@Entity(name = "SubRoot")
|
||||||
public static class SubMaster extends Master {
|
public static class SubRoot extends Root {
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
public SubMaster() { }
|
public SubRoot() { }
|
||||||
|
|
||||||
public SubMaster( Integer id, String name ) {
|
public SubRoot(Integer id, String name ) {
|
||||||
super(id);
|
super(id);
|
||||||
this.name = name;
|
this.name = name;
|
||||||
}
|
}
|
||||||
|
@ -80,11 +80,11 @@ public class UpdateJoinedSubclassCorrelationTest extends BaseEntityManagerFuncti
|
||||||
private Integer id;
|
private Integer id;
|
||||||
|
|
||||||
@ManyToOne(optional = false)
|
@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.id = id;
|
||||||
this.master = master;
|
this.root = root;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
|
|
||||||
<hibernate-mapping default-lazy="false">
|
<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">
|
<id name="id" column="container_id">
|
||||||
<generator class="native" />
|
<generator class="native" />
|
||||||
</id>
|
</id>
|
||||||
|
@ -28,10 +28,10 @@
|
||||||
</component>
|
</component>
|
||||||
</component>
|
</component>
|
||||||
|
|
||||||
<list name="components" lazy="true" table="CompNotNullMaster_Comps">
|
<list name="components" lazy="true" table="CompNotNullRoot_Comps">
|
||||||
<key column = "container_id"/>
|
<key column = "container_id"/>
|
||||||
<index column = "list_index"/>
|
<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="name"/>
|
||||||
<property name="count" column="count_"/>
|
<property name="count" column="count_"/>
|
||||||
<many-to-one name="simple" not-null="true" cascade="save-update"/>
|
<many-to-one name="simple" not-null="true" cascade="save-update"/>
|
||||||
|
@ -40,15 +40,15 @@
|
||||||
</composite-element>
|
</composite-element>
|
||||||
</list>
|
</list>
|
||||||
|
|
||||||
<list name="componentsImplicit" lazy="true" table="CompNotNullMaster_CompsImpl">
|
<list name="componentsImplicit" lazy="true" table="CompNotNullRoot_CompsImpl">
|
||||||
<key column = "container_id"/>
|
<key column = "container_id"/>
|
||||||
<index column = "list_index3"/>
|
<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="name"/>
|
||||||
<property name="count" column="count_"/>
|
<property name="count" column="count_"/>
|
||||||
<many-to-one name="simple" cascade="save-update"/>
|
<many-to-one name="simple" cascade="save-update"/>
|
||||||
<many-to-one name="one" 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"/>
|
<property name="nestedproperty" not-null="true"/>
|
||||||
</nested-composite-element>
|
</nested-composite-element>
|
||||||
</composite-element>
|
</composite-element>
|
|
@ -4,9 +4,8 @@
|
||||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
* 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>.
|
* 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;
|
package org.hibernate.test.legacy;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -14,7 +13,7 @@ import java.util.List;
|
||||||
*
|
*
|
||||||
* @author Emmanuel Bernard
|
* @author Emmanuel Bernard
|
||||||
*/
|
*/
|
||||||
public class ComponentNotNullMaster {
|
public class ComponentNotNullRoot {
|
||||||
|
|
||||||
private int id;
|
private int id;
|
||||||
private String test;
|
private String test;
|
|
@ -26,7 +26,7 @@ public class ComponentNotNullTest extends LegacyTestCase {
|
||||||
@Override
|
@Override
|
||||||
public String[] getMappings() {
|
public String[] getMappings() {
|
||||||
return new String[] {
|
return new String[] {
|
||||||
"legacy/ComponentNotNullMaster.hbm.xml",
|
"legacy/ComponentNotNullRoot.hbm.xml",
|
||||||
"legacy/One.hbm.xml",
|
"legacy/One.hbm.xml",
|
||||||
"legacy/Many.hbm.xml",
|
"legacy/Many.hbm.xml",
|
||||||
"legacy/Simple.hbm.xml" };
|
"legacy/Simple.hbm.xml" };
|
||||||
|
@ -45,16 +45,16 @@ public class ComponentNotNullTest extends LegacyTestCase {
|
||||||
//
|
//
|
||||||
Session s = openSession();
|
Session s = openSession();
|
||||||
Transaction t = s.beginTransaction();
|
Transaction t = s.beginTransaction();
|
||||||
ComponentNotNullMaster master = new ComponentNotNullMaster();
|
ComponentNotNullRoot root = new ComponentNotNullRoot();
|
||||||
ComponentNotNull nullable = new ComponentNotNull();
|
ComponentNotNull nullable = new ComponentNotNull();
|
||||||
ComponentNotNull supercomp = new ComponentNotNull();
|
ComponentNotNull supercomp = new ComponentNotNull();
|
||||||
ComponentNotNull subcomp = new ComponentNotNull();
|
ComponentNotNull subcomp = new ComponentNotNull();
|
||||||
|
|
||||||
master.setNullable(nullable);
|
root.setNullable(nullable);
|
||||||
subcomp.setProp1Subcomp("test");
|
subcomp.setProp1Subcomp("test");
|
||||||
supercomp.setSubcomp(subcomp);
|
supercomp.setSubcomp(subcomp);
|
||||||
master.setSupercomp(supercomp);
|
root.setSupercomp(supercomp);
|
||||||
s.save(master);
|
s.save(root);
|
||||||
t.commit();
|
t.commit();
|
||||||
s.close();
|
s.close();
|
||||||
|
|
||||||
|
@ -63,20 +63,20 @@ public class ComponentNotNullTest extends LegacyTestCase {
|
||||||
s = openSession();
|
s = openSession();
|
||||||
t = s.beginTransaction();
|
t = s.beginTransaction();
|
||||||
|
|
||||||
master = new ComponentNotNullMaster();
|
root = new ComponentNotNullRoot();
|
||||||
nullable = new ComponentNotNull();
|
nullable = new ComponentNotNull();
|
||||||
supercomp = new ComponentNotNull();
|
supercomp = new ComponentNotNull();
|
||||||
subcomp = new ComponentNotNull();
|
subcomp = new ComponentNotNull();
|
||||||
|
|
||||||
master.setNullable(nullable);
|
root.setNullable(nullable);
|
||||||
// do not set property
|
// do not set property
|
||||||
//subcomp.setProp1Subcomp("test");
|
//subcomp.setProp1Subcomp("test");
|
||||||
supercomp.setSubcomp(subcomp);
|
supercomp.setSubcomp(subcomp);
|
||||||
master.setSupercomp(supercomp);
|
root.setSupercomp(supercomp);
|
||||||
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
s.save(master);
|
s.save(root);
|
||||||
t.commit();
|
t.commit();
|
||||||
fail("Inserting not-null null property should fail");
|
fail("Inserting not-null null property should fail");
|
||||||
} catch (PropertyValueException e) {
|
} catch (PropertyValueException e) {
|
||||||
|
@ -90,20 +90,20 @@ public class ComponentNotNullTest extends LegacyTestCase {
|
||||||
s = openSession();
|
s = openSession();
|
||||||
t = s.beginTransaction();
|
t = s.beginTransaction();
|
||||||
|
|
||||||
master = new ComponentNotNullMaster();
|
root = new ComponentNotNullRoot();
|
||||||
nullable = new ComponentNotNull();
|
nullable = new ComponentNotNull();
|
||||||
supercomp = new ComponentNotNull();
|
supercomp = new ComponentNotNull();
|
||||||
subcomp = new ComponentNotNull();
|
subcomp = new ComponentNotNull();
|
||||||
|
|
||||||
master.setNullable(nullable);
|
root.setNullable(nullable);
|
||||||
// do not set supercomp for master
|
// do not set supercomp for root
|
||||||
//subcomp.setProp1Subcomp("test");
|
//subcomp.setProp1Subcomp("test");
|
||||||
//supercomp.setSubcomp(subcomp);
|
//supercomp.setSubcomp(subcomp);
|
||||||
//master.setSupercomp(supercomp);
|
//root.setSupercomp(supercomp);
|
||||||
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
s.save(master);
|
s.save(root);
|
||||||
t.commit();
|
t.commit();
|
||||||
fail("Inserting not-null null property should fail");
|
fail("Inserting not-null null property should fail");
|
||||||
} catch (PropertyValueException e) {
|
} catch (PropertyValueException e) {
|
||||||
|
@ -118,23 +118,23 @@ public class ComponentNotNullTest extends LegacyTestCase {
|
||||||
//composite-element nullable
|
//composite-element nullable
|
||||||
Session s = openSession();
|
Session s = openSession();
|
||||||
Transaction t = s.beginTransaction();
|
Transaction t = s.beginTransaction();
|
||||||
ComponentNotNullMaster master = new ComponentNotNullMaster();
|
ComponentNotNullRoot root = new ComponentNotNullRoot();
|
||||||
ComponentNotNull nullable = new ComponentNotNull();
|
ComponentNotNull nullable = new ComponentNotNull();
|
||||||
ComponentNotNull supercomp = new ComponentNotNull();
|
ComponentNotNull supercomp = new ComponentNotNull();
|
||||||
ComponentNotNull subcomp = new ComponentNotNull();
|
ComponentNotNull subcomp = new ComponentNotNull();
|
||||||
|
|
||||||
master.setNullable(nullable);
|
root.setNullable(nullable);
|
||||||
subcomp.setProp1Subcomp("test");
|
subcomp.setProp1Subcomp("test");
|
||||||
supercomp.setSubcomp(subcomp);
|
supercomp.setSubcomp(subcomp);
|
||||||
master.setSupercomp(supercomp);
|
root.setSupercomp(supercomp);
|
||||||
|
|
||||||
master.setComponents(new ArrayList());
|
root.setComponents(new ArrayList());
|
||||||
ComponentNotNullMaster.ContainerInnerClass cc =
|
ComponentNotNullRoot.ContainerInnerClass cc =
|
||||||
new ComponentNotNullMaster.ContainerInnerClass();
|
new ComponentNotNullRoot.ContainerInnerClass();
|
||||||
master.getComponents().add(cc);
|
root.getComponents().add(cc);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
s.save(master);
|
s.save(root);
|
||||||
t.commit();
|
t.commit();
|
||||||
fail("Inserting not-null many-to-one should fail");
|
fail("Inserting not-null many-to-one should fail");
|
||||||
} catch (PropertyValueException e) {
|
} catch (PropertyValueException e) {
|
||||||
|
@ -148,26 +148,26 @@ public class ComponentNotNullTest extends LegacyTestCase {
|
||||||
s = openSession();
|
s = openSession();
|
||||||
t = s.beginTransaction();
|
t = s.beginTransaction();
|
||||||
|
|
||||||
master = new ComponentNotNullMaster();
|
root = new ComponentNotNullRoot();
|
||||||
nullable = new ComponentNotNull();
|
nullable = new ComponentNotNull();
|
||||||
supercomp = new ComponentNotNull();
|
supercomp = new ComponentNotNull();
|
||||||
subcomp = new ComponentNotNull();
|
subcomp = new ComponentNotNull();
|
||||||
|
|
||||||
master.setNullable(nullable);
|
root.setNullable(nullable);
|
||||||
subcomp.setProp1Subcomp("test");
|
subcomp.setProp1Subcomp("test");
|
||||||
supercomp.setSubcomp(subcomp);
|
supercomp.setSubcomp(subcomp);
|
||||||
master.setSupercomp(supercomp);
|
root.setSupercomp(supercomp);
|
||||||
|
|
||||||
master.setComponentsImplicit(new ArrayList());
|
root.setComponentsImplicit(new ArrayList());
|
||||||
ComponentNotNullMaster.ContainerInnerClass nestedCc =
|
ComponentNotNullRoot.ContainerInnerClass nestedCc =
|
||||||
new ComponentNotNullMaster.ContainerInnerClass();
|
new ComponentNotNullRoot.ContainerInnerClass();
|
||||||
cc =
|
cc =
|
||||||
new ComponentNotNullMaster.ContainerInnerClass();
|
new ComponentNotNullRoot.ContainerInnerClass();
|
||||||
cc.setNested(nestedCc);
|
cc.setNested(nestedCc);
|
||||||
master.getComponentsImplicit().add(cc);
|
root.getComponentsImplicit().add(cc);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
s.save(master);
|
s.save(root);
|
||||||
t.commit();
|
t.commit();
|
||||||
fail("Inserting not-null null property should fail");
|
fail("Inserting not-null null property should fail");
|
||||||
} catch (PropertyValueException e) {
|
} catch (PropertyValueException e) {
|
||||||
|
@ -181,26 +181,26 @@ public class ComponentNotNullTest extends LegacyTestCase {
|
||||||
s = openSession();
|
s = openSession();
|
||||||
t = s.beginTransaction();
|
t = s.beginTransaction();
|
||||||
|
|
||||||
master = new ComponentNotNullMaster();
|
root = new ComponentNotNullRoot();
|
||||||
nullable = new ComponentNotNull();
|
nullable = new ComponentNotNull();
|
||||||
supercomp = new ComponentNotNull();
|
supercomp = new ComponentNotNull();
|
||||||
subcomp = new ComponentNotNull();
|
subcomp = new ComponentNotNull();
|
||||||
|
|
||||||
master.setNullable(nullable);
|
root.setNullable(nullable);
|
||||||
subcomp.setProp1Subcomp("test");
|
subcomp.setProp1Subcomp("test");
|
||||||
supercomp.setSubcomp(subcomp);
|
supercomp.setSubcomp(subcomp);
|
||||||
master.setSupercomp(supercomp);
|
root.setSupercomp(supercomp);
|
||||||
|
|
||||||
master.setComponentsImplicit(new ArrayList());
|
root.setComponentsImplicit(new ArrayList());
|
||||||
nestedCc =
|
nestedCc =
|
||||||
new ComponentNotNullMaster.ContainerInnerClass();
|
new ComponentNotNullRoot.ContainerInnerClass();
|
||||||
cc =
|
cc =
|
||||||
new ComponentNotNullMaster.ContainerInnerClass();
|
new ComponentNotNullRoot.ContainerInnerClass();
|
||||||
cc.setNested(nestedCc);
|
cc.setNested(nestedCc);
|
||||||
nestedCc.setNestedproperty("test");
|
nestedCc.setNestedproperty("test");
|
||||||
master.getComponentsImplicit().add(cc);
|
root.getComponentsImplicit().add(cc);
|
||||||
|
|
||||||
s.save(master);
|
s.save(root);
|
||||||
t.commit();
|
t.commit();
|
||||||
s.close();
|
s.close();
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,7 +13,7 @@ import java.util.Set;
|
||||||
|
|
||||||
public class Detail implements Serializable {
|
public class Detail implements Serializable {
|
||||||
|
|
||||||
private Master master;
|
private Root root;
|
||||||
private int i;
|
private int i;
|
||||||
private Set details = new HashSet();
|
private Set details = new HashSet();
|
||||||
private int x;
|
private int x;
|
||||||
|
@ -25,12 +25,12 @@ public class Detail implements Serializable {
|
||||||
this.x = x;
|
this.x = x;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Master getMaster() {
|
public Root getRoot() {
|
||||||
return master;
|
return root;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setMaster(Master master) {
|
public void setRoot(Root root) {
|
||||||
this.master = master;
|
this.root = root;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getI() {
|
public int getI() {
|
||||||
|
|
|
@ -663,7 +663,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");
|
||||||
|
@ -689,10 +689,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();
|
||||||
|
@ -703,29 +703,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();
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,7 +47,7 @@
|
||||||
|
|
||||||
<class name="org.hibernate.test.legacy.Outer" table="CID_OUT">
|
<class name="org.hibernate.test.legacy.Outer" table="CID_OUT">
|
||||||
<composite-id name="id">
|
<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="AKEY"/>
|
||||||
<column length="10" name="BKEY"/>
|
<column length="10" name="BKEY"/>
|
||||||
<column length="10" name="ONE"/>
|
<column length="10" name="ONE"/>
|
||||||
|
|
|
@ -34,9 +34,9 @@ public class Middle implements Serializable {
|
||||||
if (this == o) return true;
|
if (this == o) return true;
|
||||||
if (!(o instanceof Middle)) return false;
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,11 +43,11 @@ public class MiddleKey implements Serializable {
|
||||||
if (this == o) return true;
|
if (this == o) return true;
|
||||||
if (!(o instanceof MiddleKey)) return false;
|
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 (one != null ? !one.equals(cidMiddleKey.one) : cidMiddleKey.one != null) return false;
|
||||||
if (sup != null ? !sup.equals(cidMasterID.sup) : cidMasterID.sup != null) return false;
|
if (sup != null ? !sup.equals(cidMiddleKey.sup) : cidMiddleKey.sup != null) return false;
|
||||||
if (two != null ? !two.equals(cidMasterID.two) : cidMasterID.two != null) return false;
|
if (two != null ? !two.equals(cidMiddleKey.two) : cidMiddleKey.two != null) return false;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,15 +11,15 @@ import java.io.Serializable;
|
||||||
* @author Stefano Travelli
|
* @author Stefano Travelli
|
||||||
*/
|
*/
|
||||||
public class OuterKey implements Serializable {
|
public class OuterKey implements Serializable {
|
||||||
private Middle master;
|
private Middle root;
|
||||||
private String detailId;
|
private String detailId;
|
||||||
|
|
||||||
public Middle getMaster() {
|
public Middle getRoot() {
|
||||||
return master;
|
return root;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setMaster(Middle master) {
|
public void setRoot(Middle root) {
|
||||||
this.master = master;
|
this.root = root;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getDetailId() {
|
public String getDetailId() {
|
||||||
|
@ -37,14 +37,14 @@ public class OuterKey implements Serializable {
|
||||||
final OuterKey cidDetailID = (OuterKey) o;
|
final OuterKey cidDetailID = (OuterKey) o;
|
||||||
|
|
||||||
if (detailId != null ? !detailId.equals(cidDetailID.detailId) : cidDetailID.detailId != null) return false;
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
int result;
|
int result;
|
||||||
result = (master != null ? master.hashCode() : 0);
|
result = ( root != null ? root.hashCode() : 0);
|
||||||
result = 29 * result + (detailId != null ? detailId.hashCode() : 0);
|
result = 29 * result + (detailId != null ? detailId.hashCode() : 0);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,9 +39,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);
|
||||||
|
@ -58,9 +58,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 componentizeable = 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(componentizeable).enableLike();
|
||||||
|
|
||||||
crit.add(Restrictions.or(Restrictions.not(ex), ex));
|
crit.add(Restrictions.or(Restrictions.not(ex), ex));
|
||||||
|
|
||||||
|
@ -78,18 +78,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 componentizeable = 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(componentizeable).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");
|
componentizeable = getComponentizeable("hibernate", "ORM tool", "fake stuff");
|
||||||
crit = s.createCriteria(Componentizable.class);
|
crit = s.createCriteria(Componentizable.class);
|
||||||
ex = Example.create(master).enableLike()
|
ex = Example.create(componentizeable).enableLike()
|
||||||
.excludeProperty("component.subComponent.subName1");
|
.excludeProperty("component.subComponent.subName1");
|
||||||
crit.add(ex);
|
crit.add(ex);
|
||||||
result = crit.list();
|
result = crit.list();
|
||||||
|
@ -104,12 +104,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 componentizeable = getComponentizeable("hibernate", "ORM tool", "ORM tool1");
|
||||||
s.saveOrUpdate(master);
|
s.saveOrUpdate(componentizeable);
|
||||||
master = getMaster("hibernate", "open source", "open source1");
|
componentizeable = getComponentizeable("hibernate", "open source", "open source1");
|
||||||
s.saveOrUpdate(master);
|
s.saveOrUpdate(componentizeable);
|
||||||
master = getMaster("hibernate", null, null);
|
componentizeable = getComponentizeable("hibernate", null, null);
|
||||||
s.saveOrUpdate(master);
|
s.saveOrUpdate(componentizeable);
|
||||||
t.commit();
|
t.commit();
|
||||||
s.close();
|
s.close();
|
||||||
}
|
}
|
||||||
|
@ -124,19 +124,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 componentizable = 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);
|
componentizable.setComponent(component);
|
||||||
}
|
}
|
||||||
return master;
|
return componentizable;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,9 +4,8 @@
|
||||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
* 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>.
|
* 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;
|
package org.hibernate.test.legacy;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
@ -14,21 +13,21 @@ import java.util.Date;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
public class Master implements Serializable, Named {
|
public class Root implements Serializable, Named {
|
||||||
private Long id;
|
private Long id;
|
||||||
private Master otherMaster;
|
private Root otherRoot;
|
||||||
private Set details = new HashSet();
|
private Set details = new HashSet();
|
||||||
private Set moreDetails = new HashSet();
|
private Set moreDetails = new HashSet();
|
||||||
private Set incoming = new HashSet();
|
private Set incoming = new HashSet();
|
||||||
private Set outgoing = new HashSet();
|
private Set outgoing = new HashSet();
|
||||||
private String name="master";
|
private String name="root";
|
||||||
private Date stamp;
|
private Date stamp;
|
||||||
private int version;
|
private int version;
|
||||||
private BigDecimal bigDecimal = new BigDecimal("1234.123");
|
private BigDecimal bigDecimal = new BigDecimal("1234.123");
|
||||||
private int x;
|
private int x;
|
||||||
private Collection allDetails;
|
private Collection allDetails;
|
||||||
|
|
||||||
public Master() {
|
public Root() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public Long getId() {
|
public Long getId() {
|
||||||
|
@ -63,19 +62,19 @@ public class Master implements Serializable, Named {
|
||||||
details.remove(d);
|
details.remove(d);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addIncoming(Master m) {
|
public void addIncoming(Root m) {
|
||||||
incoming.add(m);
|
incoming.add(m);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removeIncoming(Master m) {
|
public void removeIncoming(Root m) {
|
||||||
incoming.remove(m);
|
incoming.remove(m);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addOutgoing(Master m) {
|
public void addOutgoing(Root m) {
|
||||||
outgoing.add(m);
|
outgoing.add(m);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removeOutgoing(Master m) {
|
public void removeOutgoing(Root m) {
|
||||||
outgoing.remove(m);
|
outgoing.remove(m);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -130,15 +129,15 @@ public class Master implements Serializable, Named {
|
||||||
/**
|
/**
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public Master getOtherMaster() {
|
public Root getOtherRoot() {
|
||||||
return otherMaster;
|
return otherRoot;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param master
|
* @param root
|
||||||
*/
|
*/
|
||||||
public void setOtherMaster(Master master) {
|
public void setOtherRoot(Root root) {
|
||||||
otherMaster = master;
|
otherRoot = root;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
|
@ -11,9 +11,9 @@
|
||||||
|
|
||||||
<hibernate-mapping default-lazy="false">
|
<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>
|
<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"/>
|
<generator class="native"/>
|
||||||
</id>
|
</id>
|
||||||
<version name="version" access="field"/>
|
<version name="version" access="field"/>
|
||||||
|
@ -26,24 +26,24 @@
|
||||||
<property name="x"/>
|
<property name="x"/>
|
||||||
<property name="bigDecimal" column="big_dec" precision="7" scale="3"/>
|
<property name="bigDecimal" column="big_dec" precision="7" scale="3"/>
|
||||||
<set name="details" inverse="true" lazy="true" order-by="i asc">
|
<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"/>
|
<one-to-many class="org.hibernate.test.legacy.Detail"/>
|
||||||
</set>
|
</set>
|
||||||
<set name="moreDetails" cascade="all" lazy="true" order-by="i desc">
|
<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"/>
|
<one-to-many class="org.hibernate.test.legacy.Detail"/>
|
||||||
</set>
|
</set>
|
||||||
<set name="incoming" lazy="true" table="mtm">
|
<set name="incoming" lazy="true" table="mtm">
|
||||||
<key foreign-key="AA" column="outgoingabcdef"/>
|
<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"/>
|
<column name="incomingabcdef" index="IBB"/>
|
||||||
</many-to-many>
|
</many-to-many>
|
||||||
</set>
|
</set>
|
||||||
<set name="outgoing" lazy="true" table="mtm" inverse="true">
|
<set name="outgoing" lazy="true" table="mtm" inverse="true">
|
||||||
<key column="incomingabcdef"/>
|
<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>
|
</set>
|
||||||
<many-to-one name="otherMaster"/>
|
<many-to-one name="otherRoot"/>
|
||||||
<!--query-list name="allDetails" query-ref="all_details"/-->
|
<!--query-list name="allDetails" query-ref="all_details"/-->
|
||||||
</class>
|
</class>
|
||||||
|
|
||||||
|
@ -57,8 +57,8 @@
|
||||||
<property name="i">
|
<property name="i">
|
||||||
<column name="i" unique-key="uk" not-null="true"/>
|
<column name="i" unique-key="uk" not-null="true"/>
|
||||||
</property>
|
</property>
|
||||||
<many-to-one name="master" foreign-key="CC"> <!--not-null="true"-->
|
<many-to-one name="root" foreign-key="CC"> <!--not-null="true"-->
|
||||||
<column name="master_key" unique-key="uk" not-null="true"/>
|
<column name="root_key" unique-key="uk" not-null="true"/>
|
||||||
</many-to-one>
|
</many-to-one>
|
||||||
<!-- <cache timeout="10000" type="readwrite"/> -->
|
<!-- <cache timeout="10000" type="readwrite"/> -->
|
||||||
<set name="subDetails" lazy="true" cascade="all">
|
<set name="subDetails" lazy="true" cascade="all">
|
|
@ -34,11 +34,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",
|
||||||
|
@ -87,15 +87,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 {
|
||||||
|
@ -196,19 +187,19 @@ public class MasterDetailTest extends LegacyTestCase {
|
||||||
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);
|
||||||
|
@ -221,41 +212,41 @@ public class MasterDetailTest extends LegacyTestCase {
|
||||||
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);
|
||||||
|
@ -307,39 +298,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 org.hibernate.dialect.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
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -348,42 +339,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);
|
||||||
|
|
||||||
|
@ -392,25 +383,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();
|
||||||
|
|
||||||
|
@ -418,14 +406,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 );
|
||||||
|
@ -436,38 +424,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) );
|
||||||
|
@ -475,21 +463,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();
|
||||||
}
|
}
|
||||||
|
@ -498,19 +486,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
|
||||||
);
|
);
|
||||||
|
@ -519,18 +507,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();
|
||||||
}
|
}
|
||||||
|
@ -542,11 +530,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);
|
||||||
|
@ -555,11 +543,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();
|
||||||
}
|
}
|
||||||
|
@ -578,13 +566,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 );
|
||||||
|
@ -594,7 +582,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");
|
||||||
|
@ -622,11 +610,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);
|
||||||
|
@ -636,12 +624,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();
|
||||||
}
|
}
|
|
@ -12,6 +12,6 @@
|
||||||
<hibernate-mapping package="org.hibernate.test.fileimport">
|
<hibernate-mapping package="org.hibernate.test.fileimport">
|
||||||
<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>
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
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,2)
|
INSERT INTO dog (id, owner_fk) VALUES (2,2)
|
||||||
INSERT INTO dog (id, master_fk) VALUES (3,3)
|
INSERT INTO dog (id, owner_fk) VALUES (3,3)
|
|
@ -15,7 +15,7 @@ public class DetailSuperclass {
|
||||||
|
|
||||||
private long id;
|
private long id;
|
||||||
|
|
||||||
private List<Master> masters;
|
private List<Root> roots;
|
||||||
|
|
||||||
public DetailSuperclass() {
|
public DetailSuperclass() {
|
||||||
|
|
||||||
|
@ -29,12 +29,12 @@ public class DetailSuperclass {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Master> getMasters() {
|
public List<Root> getRoots() {
|
||||||
return masters;
|
return roots;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setMasters(List<Master> masters) {
|
public void setRoots(List<Root> roots) {
|
||||||
this.masters = masters;
|
this.roots = roots;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,7 +30,7 @@ public class ManyToManyInverseToSuperclassTest extends BaseEnversJPAFunctionalTe
|
||||||
public void initData() {
|
public void initData() {
|
||||||
EntityManager em = getEntityManager();
|
EntityManager em = getEntityManager();
|
||||||
|
|
||||||
Master m1 = new Master();
|
Root m1 = new Root();
|
||||||
DetailSubclass det1 = new DetailSubclass2();
|
DetailSubclass det1 = new DetailSubclass2();
|
||||||
|
|
||||||
// Revision 1
|
// Revision 1
|
||||||
|
@ -38,66 +38,24 @@ public class ManyToManyInverseToSuperclassTest extends BaseEnversJPAFunctionalTe
|
||||||
|
|
||||||
det1.setStr2( "detail 1" );
|
det1.setStr2( "detail 1" );
|
||||||
|
|
||||||
m1.setStr( "master" );
|
m1.setStr( "root" );
|
||||||
m1.setItems( new ArrayList<DetailSubclass>() );
|
m1.setItems( new ArrayList<DetailSubclass>() );
|
||||||
m1.getItems().add( det1 );
|
m1.getItems().add( det1 );
|
||||||
|
|
||||||
det1.setMasters( new ArrayList<Master>() );
|
det1.setRoots( new ArrayList<Root>() );
|
||||||
det1.getMasters().add( m1 );
|
det1.getRoots().add( m1 );
|
||||||
|
|
||||||
em.persist( m1 );
|
em.persist( m1 );
|
||||||
em.getTransaction().commit();
|
em.getTransaction().commit();
|
||||||
m1_id = m1.getId();
|
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
|
@Test
|
||||||
public void testHistoryExists() {
|
public void testHistoryExists() {
|
||||||
Master rev1_1 = getAuditReader().find( Master.class, m1_id, 1 );
|
Root rev1_1 = getAuditReader().find( Root.class, m1_id, 1 );
|
||||||
Master rev1_2 = getAuditReader().find( Master.class, m1_id, 2 );
|
Root rev1_2 = getAuditReader().find( Root.class, m1_id, 2 );
|
||||||
Master rev1_3 = getAuditReader().find( Master.class, m1_id, 3 );
|
Root rev1_3 = getAuditReader().find( Root.class, m1_id, 3 );
|
||||||
Master rev1_4 = getAuditReader().find( Master.class, m1_id, 4 );
|
Root rev1_4 = getAuditReader().find( Root.class, m1_id, 4 );
|
||||||
|
|
||||||
assert (rev1_1 != null);
|
assert (rev1_1 != null);
|
||||||
assert (rev1_2 != null);
|
assert (rev1_2 != null);
|
||||||
|
|
|
@ -11,7 +11,7 @@ import java.util.List;
|
||||||
import org.hibernate.envers.Audited;
|
import org.hibernate.envers.Audited;
|
||||||
|
|
||||||
@Audited
|
@Audited
|
||||||
public class Master {
|
public class Root {
|
||||||
|
|
||||||
private long id;
|
private long id;
|
||||||
|
|
||||||
|
@ -19,7 +19,7 @@ public class Master {
|
||||||
|
|
||||||
private List<DetailSubclass> items;
|
private List<DetailSubclass> items;
|
||||||
|
|
||||||
public Master() {
|
public Root() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,16 +48,16 @@ public class ManyToOneNotInsertable extends BaseEnversJPAFunctionalTestCase {
|
||||||
// Rev 2
|
// Rev 2
|
||||||
em.getTransaction().begin();
|
em.getTransaction().begin();
|
||||||
|
|
||||||
ManyToOneNotInsertableEntity master = new ManyToOneNotInsertableEntity( mto_id1, type_id1, type1 );
|
ManyToOneNotInsertableEntity entity = new ManyToOneNotInsertableEntity( mto_id1, type_id1, type1 );
|
||||||
em.persist( master );
|
em.persist( entity );
|
||||||
|
|
||||||
em.getTransaction().commit();
|
em.getTransaction().commit();
|
||||||
|
|
||||||
// Rev 2
|
// Rev 2
|
||||||
em.getTransaction().begin();
|
em.getTransaction().begin();
|
||||||
|
|
||||||
master = em.find( ManyToOneNotInsertableEntity.class, mto_id1 );
|
entity = em.find( ManyToOneNotInsertableEntity.class, mto_id1 );
|
||||||
master.setNumber( type_id2 );
|
entity.setNumber( type_id2 );
|
||||||
|
|
||||||
em.getTransaction().commit();
|
em.getTransaction().commit();
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,7 +13,7 @@ public class DetailSuperclass {
|
||||||
|
|
||||||
private long id;
|
private long id;
|
||||||
|
|
||||||
private Master parent;
|
private Root parent;
|
||||||
|
|
||||||
public DetailSuperclass() {
|
public DetailSuperclass() {
|
||||||
|
|
||||||
|
@ -27,11 +27,11 @@ public class DetailSuperclass {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Master getParent() {
|
public Root getParent() {
|
||||||
return parent;
|
return parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setParent(Master parent) {
|
public void setParent(Root parent) {
|
||||||
this.parent = parent;
|
this.parent = parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -32,7 +32,7 @@ public class OneToManyInverseToSuperclassTest extends BaseEnversJPAFunctionalTes
|
||||||
public void initData() {
|
public void initData() {
|
||||||
EntityManager em = getEntityManager();
|
EntityManager em = getEntityManager();
|
||||||
|
|
||||||
Master m1 = new Master();
|
Root m1 = new Root();
|
||||||
DetailSubclass det1 = new DetailSubclass2();
|
DetailSubclass det1 = new DetailSubclass2();
|
||||||
DetailSubclass det2 = new DetailSubclass2();
|
DetailSubclass det2 = new DetailSubclass2();
|
||||||
|
|
||||||
|
@ -41,7 +41,7 @@ public class OneToManyInverseToSuperclassTest extends BaseEnversJPAFunctionalTes
|
||||||
|
|
||||||
det1.setStr2( "detail 1" );
|
det1.setStr2( "detail 1" );
|
||||||
|
|
||||||
m1.setStr( "master" );
|
m1.setStr( "root" );
|
||||||
m1.setItems( new ArrayList<DetailSubclass>() );
|
m1.setItems( new ArrayList<DetailSubclass>() );
|
||||||
m1.getItems().add( det1 );
|
m1.getItems().add( det1 );
|
||||||
det1.setParent( m1 );
|
det1.setParent( m1 );
|
||||||
|
@ -53,7 +53,7 @@ public class OneToManyInverseToSuperclassTest extends BaseEnversJPAFunctionalTes
|
||||||
// Revision 2
|
// Revision 2
|
||||||
em.getTransaction().begin();
|
em.getTransaction().begin();
|
||||||
|
|
||||||
m1 = em.find( Master.class, m1_id );
|
m1 = em.find( Root.class, m1_id );
|
||||||
|
|
||||||
det2.setStr2( "detail 2" );
|
det2.setStr2( "detail 2" );
|
||||||
det2.setParent( m1 );
|
det2.setParent( m1 );
|
||||||
|
@ -63,8 +63,8 @@ public class OneToManyInverseToSuperclassTest extends BaseEnversJPAFunctionalTes
|
||||||
// Revision 3
|
// Revision 3
|
||||||
em.getTransaction().begin();
|
em.getTransaction().begin();
|
||||||
|
|
||||||
m1 = em.find( Master.class, m1_id );
|
m1 = em.find( Root.class, m1_id );
|
||||||
m1.setStr( "new master" );
|
m1.setStr( "new root" );
|
||||||
|
|
||||||
det1 = m1.getItems().get( 0 );
|
det1 = m1.getItems().get( 0 );
|
||||||
det1.setStr2( "new detail" );
|
det1.setStr2( "new detail" );
|
||||||
|
@ -82,7 +82,7 @@ public class OneToManyInverseToSuperclassTest extends BaseEnversJPAFunctionalTes
|
||||||
// Revision 4
|
// Revision 4
|
||||||
em.getTransaction().begin();
|
em.getTransaction().begin();
|
||||||
|
|
||||||
m1 = em.find( Master.class, m1_id );
|
m1 = em.find( Root.class, m1_id );
|
||||||
|
|
||||||
det1 = m1.getItems().get( 0 );
|
det1 = m1.getItems().get( 0 );
|
||||||
det1.setParent( null );
|
det1.setParent( null );
|
||||||
|
@ -95,10 +95,10 @@ public class OneToManyInverseToSuperclassTest extends BaseEnversJPAFunctionalTes
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testHistoryExists() {
|
public void testHistoryExists() {
|
||||||
Master rev1_1 = getAuditReader().find( Master.class, m1_id, 1 );
|
Root rev1_1 = getAuditReader().find( Root.class, m1_id, 1 );
|
||||||
Master rev1_2 = getAuditReader().find( Master.class, m1_id, 2 );
|
Root rev1_2 = getAuditReader().find( Root.class, m1_id, 2 );
|
||||||
Master rev1_3 = getAuditReader().find( Master.class, m1_id, 3 );
|
Root rev1_3 = getAuditReader().find( Root.class, m1_id, 3 );
|
||||||
Master rev1_4 = getAuditReader().find( Master.class, m1_id, 4 );
|
Root rev1_4 = getAuditReader().find( Root.class, m1_id, 4 );
|
||||||
|
|
||||||
assert (rev1_1 != null);
|
assert (rev1_1 != null);
|
||||||
assert (rev1_2 != null);
|
assert (rev1_2 != null);
|
||||||
|
|
|
@ -11,7 +11,7 @@ import java.util.List;
|
||||||
import org.hibernate.envers.Audited;
|
import org.hibernate.envers.Audited;
|
||||||
|
|
||||||
@Audited
|
@Audited
|
||||||
public class Master {
|
public class Root {
|
||||||
|
|
||||||
private long id;
|
private long id;
|
||||||
|
|
||||||
|
@ -19,7 +19,7 @@ public class Master {
|
||||||
|
|
||||||
private List<DetailSubclass> items;
|
private List<DetailSubclass> items;
|
||||||
|
|
||||||
public Master() {
|
public Root() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,8 +9,8 @@
|
||||||
<hibernate-mapping>
|
<hibernate-mapping>
|
||||||
|
|
||||||
<class
|
<class
|
||||||
name="org.hibernate.envers.test.integration.manytomany.inverseToSuperclass.Master"
|
name="org.hibernate.envers.test.integration.manytomany.inverseToSuperclass.Root"
|
||||||
table="HIB_MASTER_ENTITY">
|
table="HIB_ROOT_ENTITY">
|
||||||
|
|
||||||
<id name="id" column="ID" type="long">
|
<id name="id" column="ID" type="long">
|
||||||
<generator class="increment" />
|
<generator class="increment" />
|
||||||
|
@ -19,8 +19,8 @@
|
||||||
<property name="str" column="STR" />
|
<property name="str" column="STR" />
|
||||||
|
|
||||||
<bag name="items" lazy="true" cascade="all" access="property" inverse="true"
|
<bag name="items" lazy="true" cascade="all" access="property" inverse="true"
|
||||||
table="HIB_MASTER_DETAIL">
|
table="HIB_ROOT_DETAIL">
|
||||||
<key column="ID_MASTER" />
|
<key column="ID_ROOT" />
|
||||||
<many-to-many
|
<many-to-many
|
||||||
class="org.hibernate.envers.test.integration.manytomany.inverseToSuperclass.DetailSubclass2"
|
class="org.hibernate.envers.test.integration.manytomany.inverseToSuperclass.DetailSubclass2"
|
||||||
column="ID_DETAIL" />
|
column="ID_DETAIL" />
|
||||||
|
@ -36,11 +36,11 @@
|
||||||
</id>
|
</id>
|
||||||
<discriminator column="DISCRIMINATOR" type="string" />
|
<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" />
|
<key column="ID_DETAIL" />
|
||||||
<many-to-many
|
<many-to-many
|
||||||
class="org.hibernate.envers.test.integration.manytomany.inverseToSuperclass.Master"
|
class="org.hibernate.envers.test.integration.manytomany.inverseToSuperclass.Root"
|
||||||
column="ID_MASTER" />
|
column="ID_ROOT" />
|
||||||
</bag>
|
</bag>
|
||||||
|
|
||||||
<subclass
|
<subclass
|
||||||
|
|
|
@ -9,8 +9,8 @@
|
||||||
<hibernate-mapping>
|
<hibernate-mapping>
|
||||||
|
|
||||||
<class
|
<class
|
||||||
name="org.hibernate.envers.test.integration.onetomany.inverseToSuperclass.Master"
|
name="org.hibernate.envers.test.integration.onetomany.inverseToSuperclass.Root"
|
||||||
table="HIB_MASTER_ENTITY">
|
table="HIB_ROOT_ENTITY">
|
||||||
|
|
||||||
<id name="id" column="ID" type="long">
|
<id name="id" column="ID" type="long">
|
||||||
<generator class="increment" />
|
<generator class="increment" />
|
||||||
|
@ -20,7 +20,7 @@
|
||||||
|
|
||||||
<bag name="items" lazy="true" cascade="all" access="property"
|
<bag name="items" lazy="true" cascade="all" access="property"
|
||||||
inverse="true">
|
inverse="true">
|
||||||
<key column="ID_MASTER" />
|
<key column="ID_ROOT" />
|
||||||
<one-to-many
|
<one-to-many
|
||||||
class="org.hibernate.envers.test.integration.onetomany.inverseToSuperclass.DetailSubclass2" />
|
class="org.hibernate.envers.test.integration.onetomany.inverseToSuperclass.DetailSubclass2" />
|
||||||
</bag>
|
</bag>
|
||||||
|
@ -35,8 +35,8 @@
|
||||||
</id>
|
</id>
|
||||||
<discriminator column="DISCRIMINATOR" type="string" />
|
<discriminator column="DISCRIMINATOR" type="string" />
|
||||||
|
|
||||||
<many-to-one name="parent" column="ID_MASTER"
|
<many-to-one name="parent" column="ID_ROOT"
|
||||||
class="org.hibernate.envers.test.integration.onetomany.inverseToSuperclass.Master" />
|
class="org.hibernate.envers.test.integration.onetomany.inverseToSuperclass.Root" />
|
||||||
|
|
||||||
<subclass
|
<subclass
|
||||||
name="org.hibernate.envers.test.integration.onetomany.inverseToSuperclass.DetailSubclass"
|
name="org.hibernate.envers.test.integration.onetomany.inverseToSuperclass.DetailSubclass"
|
||||||
|
|
|
@ -31,6 +31,12 @@
|
||||||
<property name="message" value="Line has leading space characters; indentation should be performed with tabs only." />
|
<property name="message" value="Line has leading space characters; indentation should be performed with tabs only." />
|
||||||
</module>
|
</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="MissingDeprecated" />
|
||||||
|
|
||||||
<module name="MissingOverride" />
|
<module name="MissingOverride" />
|
||||||
|
|
|
@ -15,7 +15,7 @@ There are a number of tenants that make up a good test case as opposed to a poor
|
||||||
|
|
||||||
== Test templates
|
== 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 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].
|
* 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].
|
||||||
|
|
|
@ -86,7 +86,7 @@ public class AccessTypeTest extends CompilationTest {
|
||||||
@TestForIssue(jiraKey = " METAGEN-81")
|
@TestForIssue(jiraKey = " METAGEN-81")
|
||||||
public void testAccessTypeForEmbeddableDeterminedByIdAnnotationInRootEntity() {
|
public void testAccessTypeForEmbeddableDeterminedByIdAnnotationInRootEntity() {
|
||||||
assertPresenceOfFieldInMetamodelFor(
|
assertPresenceOfFieldInMetamodelFor(
|
||||||
Hotel.class, "webmaster",
|
Hotel.class, "webDomainExpert",
|
||||||
"Access type should be inherited position of the @Id field annotation in the root entity"
|
"Access type should be inherited position of the @Id field annotation in the root entity"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,13 +16,13 @@ import javax.persistence.OneToOne;
|
||||||
public class Hotel {
|
public class Hotel {
|
||||||
|
|
||||||
@OneToOne
|
@OneToOne
|
||||||
private User webmaster;
|
private User webDomainExpert;
|
||||||
|
|
||||||
public User getWebmaster() {
|
public User getWebDomainExpert() {
|
||||||
return webmaster;
|
return webDomainExpert;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setWebmaster(User webmaster) {
|
public void setWebDomainExpert(User webDomainExpert) {
|
||||||
this.webmaster = webmaster;
|
this.webDomainExpert = webDomainExpert;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue