Re-enabled additional tests

This commit is contained in:
Andrea Boriero 2020-06-18 17:09:44 +01:00
parent ead64b3ec9
commit 47eee7cfe4
81 changed files with 536 additions and 464 deletions

View File

@ -5,7 +5,7 @@
* 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>.
*/
package org.hibernate.test.annotations.cascade;
package org.hibernate.orm.test.annotations.cascade;
import java.util.ArrayList;

View File

@ -4,7 +4,7 @@
* 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>.
*/
package org.hibernate.test.annotations.cascade;
package org.hibernate.orm.test.annotations.cascade;
import java.util.HashSet;
import java.util.Set;

View File

@ -4,7 +4,7 @@
* 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>.
*/
package org.hibernate.test.annotations.cascade;
package org.hibernate.orm.test.annotations.cascade;
import javax.persistence.CascadeType;
import javax.persistence.Entity;

View File

@ -4,7 +4,7 @@
* 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>.
*/
package org.hibernate.test.annotations.cascade;
package org.hibernate.orm.test.annotations.cascade;
import java.io.Serializable;
import javax.persistence.Column;

View File

@ -4,7 +4,7 @@
* 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>.
*/
package org.hibernate.test.annotations.cascade;
package org.hibernate.orm.test.annotations.cascade;
import java.io.Serializable;
import java.util.Collections;

View File

@ -6,7 +6,7 @@
*/
//$Id$
package org.hibernate.test.annotations.cascade;
package org.hibernate.orm.test.annotations.cascade;
import java.util.Collection;
import javax.persistence.Column;
import javax.persistence.Entity;

View File

@ -4,7 +4,7 @@
* 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>.
*/
package org.hibernate.test.annotations.cascade;
package org.hibernate.orm.test.annotations.cascade;
import java.util.HashSet;

View File

@ -4,7 +4,7 @@
* 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>.
*/
package org.hibernate.test.annotations.cascade;
package org.hibernate.orm.test.annotations.cascade;
import java.util.Set;
import javax.persistence.CascadeType;

View File

@ -4,7 +4,7 @@
* 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>.
*/
package org.hibernate.test.annotations.cascade;
package org.hibernate.orm.test.annotations.cascade;
import java.io.Serializable;
import javax.persistence.Column;

View File

@ -4,7 +4,7 @@
* 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>.
*/
package org.hibernate.test.annotations.cascade;
package org.hibernate.orm.test.annotations.cascade;
import java.io.Serializable;
import javax.persistence.CascadeType;

View File

@ -6,7 +6,7 @@
*/
//$Id$
package org.hibernate.test.annotations.cascade;
package org.hibernate.orm.test.annotations.cascade;
import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;

View File

@ -4,7 +4,7 @@
* 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>.
*/
package org.hibernate.test.annotations.cascade.circle.identity;
package org.hibernate.orm.test.annotations.cascade.circle.identity;
/**
* No Documentation

View File

@ -4,7 +4,7 @@
* 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>.
*/
package org.hibernate.test.annotations.cascade.circle.identity;
package org.hibernate.orm.test.annotations.cascade.circle.identity;
import java.io.Serializable;
import java.util.Date;

View File

@ -4,7 +4,7 @@
* 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>.
*/
package org.hibernate.test.annotations.cascade.circle.identity;
package org.hibernate.orm.test.annotations.cascade.circle.identity;
/**
* No Documentation

View File

@ -4,7 +4,7 @@
* 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>.
*/
package org.hibernate.test.annotations.cascade.circle.identity;
package org.hibernate.orm.test.annotations.cascade.circle.identity;
/**
* No Documentation

View File

@ -4,7 +4,7 @@
* 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>.
*/
package org.hibernate.test.annotations.cascade.circle.identity;
package org.hibernate.orm.test.annotations.cascade.circle.identity;
import org.junit.Test;

View File

@ -4,7 +4,7 @@
* 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>.
*/
package org.hibernate.test.annotations.cascade.circle.identity;
package org.hibernate.orm.test.annotations.cascade.circle.identity;
/**
* No Documentation

View File

@ -4,7 +4,7 @@
* 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>.
*/
package org.hibernate.test.annotations.cascade.circle.identity;
package org.hibernate.orm.test.annotations.cascade.circle.identity;
/**
* No Documentation

View File

@ -4,7 +4,7 @@
* 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>.
*/
package org.hibernate.test.annotations.cascade.circle.identity;
package org.hibernate.orm.test.annotations.cascade.circle.identity;
/**
* No Documentation

View File

@ -4,7 +4,7 @@
* 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>.
*/
package org.hibernate.test.annotations.cascade.circle.identity;
package org.hibernate.orm.test.annotations.cascade.circle.identity;
/**
* No Documentation

View File

@ -4,7 +4,7 @@
* 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>.
*/
package org.hibernate.test.annotations.cascade.circle.identity;
package org.hibernate.orm.test.annotations.cascade.circle.identity;
/**
* No Documentation

View File

@ -4,7 +4,7 @@
* 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>.
*/
package org.hibernate.test.annotations.cascade.circle.sequence;
package org.hibernate.orm.test.annotations.cascade.circle.sequence;
/**
* No Documentation

View File

@ -4,7 +4,7 @@
* 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>.
*/
package org.hibernate.test.annotations.cascade.circle.sequence;
package org.hibernate.orm.test.annotations.cascade.circle.sequence;
import java.io.Serializable;
import java.util.Date;

View File

@ -4,7 +4,7 @@
* 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>.
*/
package org.hibernate.test.annotations.cascade.circle.sequence;
package org.hibernate.orm.test.annotations.cascade.circle.sequence;
/**
* No Documentation
@ -27,7 +27,7 @@ public class B extends AbstractEntity {
@javax.persistence.ManyToOne(cascade = {
javax.persistence.CascadeType.MERGE, javax.persistence.CascadeType.PERSIST, javax.persistence.CascadeType.REFRESH}
, optional = false)
private org.hibernate.test.annotations.cascade.circle.sequence.A a;
private org.hibernate.orm.test.annotations.cascade.circle.sequence.A a;
/**
* No documentation
@ -46,11 +46,11 @@ public class B extends AbstractEntity {
this.cCollection = parameter;
}
public org.hibernate.test.annotations.cascade.circle.sequence.A getA() {
public org.hibernate.orm.test.annotations.cascade.circle.sequence.A getA() {
return a;
}
public void setA(org.hibernate.test.annotations.cascade.circle.sequence.A parameter) {
public void setA(org.hibernate.orm.test.annotations.cascade.circle.sequence.A parameter) {
this.a = parameter;
}

View File

@ -4,7 +4,7 @@
* 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>.
*/
package org.hibernate.test.annotations.cascade.circle.sequence;
package org.hibernate.orm.test.annotations.cascade.circle.sequence;
/**
* No Documentation
@ -19,7 +19,7 @@ public class C extends AbstractEntity {
@javax.persistence.ManyToOne(cascade = {
javax.persistence.CascadeType.MERGE, javax.persistence.CascadeType.PERSIST, javax.persistence.CascadeType.REFRESH}
, optional = false)
private org.hibernate.test.annotations.cascade.circle.sequence.A a;
private org.hibernate.orm.test.annotations.cascade.circle.sequence.A a;
/**
* No documentation
@ -35,13 +35,13 @@ public class C extends AbstractEntity {
@javax.persistence.ManyToOne(cascade = {
javax.persistence.CascadeType.MERGE, javax.persistence.CascadeType.PERSIST, javax.persistence.CascadeType.REFRESH}
, optional = false)
private org.hibernate.test.annotations.cascade.circle.sequence.B b;
private org.hibernate.orm.test.annotations.cascade.circle.sequence.B b;
public org.hibernate.test.annotations.cascade.circle.sequence.A getA() {
public org.hibernate.orm.test.annotations.cascade.circle.sequence.A getA() {
return a;
}
public void setA(org.hibernate.test.annotations.cascade.circle.sequence.A parameter) {
public void setA(org.hibernate.orm.test.annotations.cascade.circle.sequence.A parameter) {
this.a = parameter;
}
@ -53,11 +53,11 @@ public class C extends AbstractEntity {
this.g = parameter;
}
public org.hibernate.test.annotations.cascade.circle.sequence.B getB() {
public org.hibernate.orm.test.annotations.cascade.circle.sequence.B getB() {
return b;
}
public void setB(org.hibernate.test.annotations.cascade.circle.sequence.B parameter) {
public void setB(org.hibernate.orm.test.annotations.cascade.circle.sequence.B parameter) {
this.b = parameter;
}
}

View File

@ -4,7 +4,7 @@
* 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>.
*/
package org.hibernate.test.annotations.cascade.circle.sequence;
package org.hibernate.orm.test.annotations.cascade.circle.sequence;
import org.junit.Test;

View File

@ -4,7 +4,7 @@
* 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>.
*/
package org.hibernate.test.annotations.cascade.circle.sequence;
package org.hibernate.orm.test.annotations.cascade.circle.sequence;
/**
* No Documentation
@ -19,7 +19,7 @@ public class D extends AbstractEntity {
@javax.persistence.ManyToMany(cascade = {
javax.persistence.CascadeType.MERGE, javax.persistence.CascadeType.PERSIST, javax.persistence.CascadeType.REFRESH}
)
private java.util.Set<org.hibernate.test.annotations.cascade.circle.sequence.A> aCollection = new java.util.HashSet<org.hibernate.test.annotations.cascade.circle.sequence.A>();
private java.util.Set<org.hibernate.orm.test.annotations.cascade.circle.sequence.A> aCollection = new java.util.HashSet<org.hibernate.orm.test.annotations.cascade.circle.sequence.A>();
/**
* No documentation
@ -29,12 +29,12 @@ public class D extends AbstractEntity {
)
private java.util.Set<E> eCollection = new java.util.HashSet<E>();
public java.util.Set<org.hibernate.test.annotations.cascade.circle.sequence.A> getACollection() {
public java.util.Set<org.hibernate.orm.test.annotations.cascade.circle.sequence.A> getACollection() {
return aCollection;
}
public void setACollection(
java.util.Set<org.hibernate.test.annotations.cascade.circle.sequence.A> parameter) {
java.util.Set<org.hibernate.orm.test.annotations.cascade.circle.sequence.A> parameter) {
this.aCollection = parameter;
}

View File

@ -4,7 +4,7 @@
* 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>.
*/
package org.hibernate.test.annotations.cascade.circle.sequence;
package org.hibernate.orm.test.annotations.cascade.circle.sequence;
/**
* No Documentation

View File

@ -4,7 +4,7 @@
* 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>.
*/
package org.hibernate.test.annotations.cascade.circle.sequence;
package org.hibernate.orm.test.annotations.cascade.circle.sequence;
/**
* No Documentation
@ -19,7 +19,7 @@ public class F extends AbstractEntity {
@javax.persistence.OneToMany(cascade = {
javax.persistence.CascadeType.MERGE, javax.persistence.CascadeType.PERSIST, javax.persistence.CascadeType.REFRESH}
, mappedBy = "f")
private java.util.Set<org.hibernate.test.annotations.cascade.circle.sequence.B> bCollection = new java.util.HashSet<org.hibernate.test.annotations.cascade.circle.sequence.B>();
private java.util.Set<org.hibernate.orm.test.annotations.cascade.circle.sequence.B> bCollection = new java.util.HashSet<org.hibernate.orm.test.annotations.cascade.circle.sequence.B>();
/**
* No documentation
@ -29,12 +29,12 @@ public class F extends AbstractEntity {
)
private H h;
public java.util.Set<org.hibernate.test.annotations.cascade.circle.sequence.B> getBCollection() {
public java.util.Set<org.hibernate.orm.test.annotations.cascade.circle.sequence.B> getBCollection() {
return bCollection;
}
public void setBCollection(
java.util.Set<org.hibernate.test.annotations.cascade.circle.sequence.B> parameter) {
java.util.Set<org.hibernate.orm.test.annotations.cascade.circle.sequence.B> parameter) {
this.bCollection = parameter;
}

View File

@ -4,7 +4,7 @@
* 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>.
*/
package org.hibernate.test.annotations.cascade.circle.sequence;
package org.hibernate.orm.test.annotations.cascade.circle.sequence;
/**
* No Documentation
@ -19,14 +19,14 @@ public class G extends AbstractEntity {
@javax.persistence.OneToMany(cascade = {
javax.persistence.CascadeType.MERGE, javax.persistence.CascadeType.PERSIST, javax.persistence.CascadeType.REFRESH}
, mappedBy = "g")
private java.util.Set<org.hibernate.test.annotations.cascade.circle.sequence.C> cCollection = new java.util.HashSet<org.hibernate.test.annotations.cascade.circle.sequence.C>();
private java.util.Set<org.hibernate.orm.test.annotations.cascade.circle.sequence.C> cCollection = new java.util.HashSet<org.hibernate.orm.test.annotations.cascade.circle.sequence.C>();
public java.util.Set<org.hibernate.test.annotations.cascade.circle.sequence.C> getCCollection() {
public java.util.Set<org.hibernate.orm.test.annotations.cascade.circle.sequence.C> getCCollection() {
return cCollection;
}
public void setCCollection(
java.util.Set<org.hibernate.test.annotations.cascade.circle.sequence.C> parameter) {
java.util.Set<org.hibernate.orm.test.annotations.cascade.circle.sequence.C> parameter) {
this.cCollection = parameter;
}
}

View File

@ -4,7 +4,7 @@
* 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>.
*/
package org.hibernate.test.annotations.cascade.circle.sequence;
package org.hibernate.orm.test.annotations.cascade.circle.sequence;
/**
* No Documentation
@ -19,13 +19,13 @@ public class H extends AbstractEntity {
@javax.persistence.OneToOne(cascade = {
javax.persistence.CascadeType.MERGE, javax.persistence.CascadeType.PERSIST, javax.persistence.CascadeType.REFRESH}
)
private org.hibernate.test.annotations.cascade.circle.sequence.G g;
private org.hibernate.orm.test.annotations.cascade.circle.sequence.G g;
public org.hibernate.test.annotations.cascade.circle.sequence.G getG() {
public org.hibernate.orm.test.annotations.cascade.circle.sequence.G getG() {
return g;
}
public void setG(org.hibernate.test.annotations.cascade.circle.sequence.G parameter) {
public void setG(org.hibernate.orm.test.annotations.cascade.circle.sequence.G parameter) {
this.g = parameter;
}
}

View File

@ -4,7 +4,7 @@
* 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>.
*/
package org.hibernate.test.annotations.cascade.multicircle.nonjpa.identity;
package org.hibernate.orm.test.annotations.cascade.multicircle.jpa.identity;
import java.io.Serializable;
import java.util.Date;

View File

@ -4,7 +4,7 @@
* 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>.
*/
package org.hibernate.test.annotations.cascade.multicircle.jpa.identity;
package org.hibernate.orm.test.annotations.cascade.multicircle.jpa.identity;
/**
* No Documentation

View File

@ -4,7 +4,7 @@
* 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>.
*/
package org.hibernate.test.annotations.cascade.multicircle.jpa.identity;
package org.hibernate.orm.test.annotations.cascade.multicircle.jpa.identity;
import java.util.Set;

View File

@ -4,7 +4,7 @@
* 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>.
*/
package org.hibernate.test.annotations.cascade.multicircle.jpa.identity;
package org.hibernate.orm.test.annotations.cascade.multicircle.jpa.identity;
/**
* No Documentation

View File

@ -4,7 +4,7 @@
* 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>.
*/
package org.hibernate.test.annotations.cascade.multicircle.jpa.identity;
package org.hibernate.orm.test.annotations.cascade.multicircle.jpa.identity;
/**
* No Documentation

View File

@ -4,7 +4,7 @@
* 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>.
*/
package org.hibernate.test.annotations.cascade.multicircle.jpa.identity;
package org.hibernate.orm.test.annotations.cascade.multicircle.jpa.identity;
/**
* No Documentation

View File

@ -4,7 +4,7 @@
* 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>.
*/
package org.hibernate.test.annotations.cascade.multicircle.jpa.identity;
package org.hibernate.orm.test.annotations.cascade.multicircle.jpa.identity;
/**
* No Documentation

View File

@ -4,7 +4,7 @@
* 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>.
*/
package org.hibernate.test.annotations.cascade.multicircle.jpa.identity;
package org.hibernate.orm.test.annotations.cascade.multicircle.jpa.identity;
import junit.framework.Assert;
import org.junit.After;

View File

@ -4,7 +4,7 @@
* 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>.
*/
package org.hibernate.test.annotations.cascade.multicircle.nonjpa.sequence;
package org.hibernate.orm.test.annotations.cascade.multicircle.jpa.sequence;
import java.io.Serializable;
import java.util.Date;

View File

@ -4,7 +4,7 @@
* 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>.
*/
package org.hibernate.test.annotations.cascade.multicircle.jpa.sequence;
package org.hibernate.orm.test.annotations.cascade.multicircle.jpa.sequence;
/**
* No Documentation
@ -19,7 +19,7 @@ public class B extends AbstractEntity {
@javax.persistence.OneToMany(cascade = {
javax.persistence.CascadeType.MERGE, javax.persistence.CascadeType.PERSIST, javax.persistence.CascadeType.REFRESH}
, mappedBy = "b")
private java.util.Set<G> gCollection = new java.util.HashSet<org.hibernate.test.annotations.cascade.multicircle.jpa.sequence.G>();
private java.util.Set<G> gCollection = new java.util.HashSet<org.hibernate.orm.test.annotations.cascade.multicircle.jpa.sequence.G>();
/**

View File

@ -4,7 +4,7 @@
* 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>.
*/
package org.hibernate.test.annotations.cascade.multicircle.jpa.sequence;
package org.hibernate.orm.test.annotations.cascade.multicircle.jpa.sequence;
import java.util.Set;

View File

@ -4,7 +4,7 @@
* 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>.
*/
package org.hibernate.test.annotations.cascade.multicircle.jpa.sequence;
package org.hibernate.orm.test.annotations.cascade.multicircle.jpa.sequence;
/**
* No Documentation

View File

@ -4,7 +4,7 @@
* 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>.
*/
package org.hibernate.test.annotations.cascade.multicircle.nonjpa.sequence;
package org.hibernate.orm.test.annotations.cascade.multicircle.jpa.sequence;
/**
* No Documentation

View File

@ -4,7 +4,7 @@
* 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>.
*/
package org.hibernate.test.annotations.cascade.multicircle.jpa.sequence;
package org.hibernate.orm.test.annotations.cascade.multicircle.jpa.sequence;
/**
* No Documentation

View File

@ -4,7 +4,7 @@
* 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>.
*/
package org.hibernate.test.annotations.cascade.multicircle.jpa.sequence;
package org.hibernate.orm.test.annotations.cascade.multicircle.jpa.sequence;
/**
* No Documentation

View File

@ -4,7 +4,7 @@
* 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>.
*/
package org.hibernate.test.annotations.cascade.multicircle.jpa.sequence;
package org.hibernate.orm.test.annotations.cascade.multicircle.jpa.sequence;
import org.hibernate.Session;

View File

@ -4,7 +4,7 @@
* 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>.
*/
package org.hibernate.test.annotations.cascade.multicircle.jpa.identity;
package org.hibernate.orm.test.annotations.cascade.multicircle.nonjpa.identity;
import java.io.Serializable;
import java.util.Date;

View File

@ -4,7 +4,7 @@
* 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>.
*/
package org.hibernate.test.annotations.cascade.multicircle.nonjpa.identity;
package org.hibernate.orm.test.annotations.cascade.multicircle.nonjpa.identity;
@javax.persistence.Entity
public class EntityB extends AbstractEntity {

View File

@ -4,7 +4,7 @@
* 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>.
*/
package org.hibernate.test.annotations.cascade.multicircle.nonjpa.identity;
package org.hibernate.orm.test.annotations.cascade.multicircle.nonjpa.identity;
import java.util.Set;

View File

@ -4,7 +4,7 @@
* 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>.
*/
package org.hibernate.test.annotations.cascade.multicircle.nonjpa.identity;
package org.hibernate.orm.test.annotations.cascade.multicircle.nonjpa.identity;
/**
* No Documentation

View File

@ -4,7 +4,7 @@
* 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>.
*/
package org.hibernate.test.annotations.cascade.multicircle.nonjpa.identity;
package org.hibernate.orm.test.annotations.cascade.multicircle.nonjpa.identity;
/**
* No Documentation

View File

@ -4,7 +4,7 @@
* 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>.
*/
package org.hibernate.test.annotations.cascade.multicircle.nonjpa.identity;
package org.hibernate.orm.test.annotations.cascade.multicircle.nonjpa.identity;
/**
* No Documentation

View File

@ -4,7 +4,7 @@
* 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>.
*/
package org.hibernate.test.annotations.cascade.multicircle.nonjpa.identity;
package org.hibernate.orm.test.annotations.cascade.multicircle.nonjpa.identity;
/**
* No Documentation

View File

@ -4,7 +4,7 @@
* 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>.
*/
package org.hibernate.test.annotations.cascade.multicircle.nonjpa.identity;
package org.hibernate.orm.test.annotations.cascade.multicircle.nonjpa.identity;
import junit.framework.Assert;
import org.junit.After;

View File

@ -4,7 +4,7 @@
* 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>.
*/
package org.hibernate.test.annotations.cascade.multicircle.jpa.sequence;
package org.hibernate.orm.test.annotations.cascade.multicircle.nonjpa.sequence;
import java.io.Serializable;
import java.util.Date;

View File

@ -4,7 +4,7 @@
* 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>.
*/
package org.hibernate.test.annotations.cascade.multicircle.nonjpa.sequence;
package org.hibernate.orm.test.annotations.cascade.multicircle.nonjpa.sequence;
@javax.persistence.Entity
public class B extends AbstractEntity {

View File

@ -4,7 +4,7 @@
* 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>.
*/
package org.hibernate.test.annotations.cascade.multicircle.nonjpa.sequence;
package org.hibernate.orm.test.annotations.cascade.multicircle.nonjpa.sequence;
import java.util.Set;

View File

@ -4,7 +4,7 @@
* 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>.
*/
package org.hibernate.test.annotations.cascade.multicircle.nonjpa.sequence;
package org.hibernate.orm.test.annotations.cascade.multicircle.nonjpa.sequence;
/**
* No Documentation

View File

@ -4,7 +4,7 @@
* 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>.
*/
package org.hibernate.test.annotations.cascade.multicircle.jpa.sequence;
package org.hibernate.orm.test.annotations.cascade.multicircle.nonjpa.sequence;
/**
* No Documentation

View File

@ -4,7 +4,7 @@
* 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>.
*/
package org.hibernate.test.annotations.cascade.multicircle.nonjpa.sequence;
package org.hibernate.orm.test.annotations.cascade.multicircle.nonjpa.sequence;
/**
* No Documentation

View File

@ -4,7 +4,7 @@
* 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>.
*/
package org.hibernate.test.annotations.cascade.multicircle.nonjpa.sequence;
package org.hibernate.orm.test.annotations.cascade.multicircle.nonjpa.sequence;
/**
* No Documentation

View File

@ -4,7 +4,7 @@
* 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>.
*/
package org.hibernate.test.annotations.cascade.multicircle.nonjpa.sequence;
package org.hibernate.orm.test.annotations.cascade.multicircle.nonjpa.sequence;
import org.hibernate.Session;

View File

@ -4,7 +4,7 @@
* 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>.
*/
package org.hibernate.test.keymanytoone.bidir.component;
package org.hibernate.orm.test.keymanytoone.bidir.component;
import java.util.ArrayList;
import java.util.Collection;

View File

@ -18,7 +18,7 @@
association.
-->
<hibernate-mapping package="org.hibernate.test.keymanytoone.bidir.component">
<hibernate-mapping package="org.hibernate.orm.test.keymanytoone.bidir.component">
<class name="Customer" table="COMP_LAZY_KM2O_CUST">
<id name="id" column="ID" type="long">

View File

@ -0,0 +1,111 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* 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>.
*/
package org.hibernate.orm.test.keymanytoone.bidir.component;
import java.util.List;
import org.hibernate.stat.spi.StatisticsImplementor;
import org.hibernate.testing.orm.junit.DomainModel;
import org.hibernate.testing.orm.junit.SessionFactory;
import org.hibernate.testing.orm.junit.SessionFactoryScope;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
/**
* @author Steve Ebersole
*/
@DomainModel(xmlMappings = {
"org/hibernate/orm/test/keymanytoone/bidir/component/EagerCollectionLazyKeyManyToOneMapping.hbm.xml"
})
@SessionFactory(generateStatistics = true)
public class EagerCollectionLazyKeyManyToOneTest {
@AfterEach
public void tearDown(SessionFactoryScope scope) {
scope.inTransaction(
session -> {
List<Customer> customers = session.createQuery( "from Customer" ).list();
customers.forEach(
customer -> session.delete( customer )
);
}
);
}
@Test
public void testQueryingOnMany2One(SessionFactoryScope scope) {
Customer cust = new Customer( "Acme, Inc." );
Order order = new Order( new Order.Id( cust, 1 ) );
cust.getOrders().add( order );
scope.inTransaction(
session -> {
session.save( cust );
}
);
scope.inTransaction(
session -> {
List results = session.createQuery( "from Order o where o.id.customer.name = :name" )
.setParameter( "name", cust.getName() )
.list();
assertEquals( 1, results.size() );
}
);
}
@Test
public void testSaveCascadedToKeyManyToOne(SessionFactoryScope scope) {
// test cascading a save to an association with a key-many-to-one which refers to a
// just saved entity
StatisticsImplementor statistics = scope.getSessionFactory().getStatistics();
scope.inTransaction(
session -> {
Customer cust = new Customer( "Acme, Inc." );
Order order = new Order( new Order.Id( cust, 1 ) );
cust.getOrders().add( order );
statistics.clear();
session.save( cust );
session.flush();
assertEquals( 2, statistics.getEntityInsertCount() );
}
);
}
@Test
public void testLoadingStrategies(SessionFactoryScope scope) {
Customer customer = new Customer( "Acme, Inc." );
Order order = new Order( new Order.Id( customer, 1 ) );
customer.getOrders().add( order );
scope.inTransaction(
session -> session.save( customer )
);
scope.inTransaction(
session -> {
Customer cust = session.get( Customer.class, customer.getId() );
assertEquals( 1, cust.getOrders().size() );
session.clear();
cust = (Customer) session.createQuery( "from Customer" ).uniqueResult();
assertEquals( 1, cust.getOrders().size() );
session.clear();
cust = (Customer) session.createQuery( "from Customer c join fetch c.orders" ).uniqueResult();
assertEquals( 1, cust.getOrders().size() );
session.clear();
}
);
}
}

View File

@ -4,17 +4,14 @@
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
package org.hibernate.test.keymanytoone.bidir.component;
package org.hibernate.orm.test.keymanytoone.bidir.component;
import java.util.List;
import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery;
import org.hibernate.HibernateException;
import org.hibernate.Session;
import org.hibernate.boot.Metadata;
import org.hibernate.boot.registry.BootstrapServiceRegistryBuilder;
import org.hibernate.cfg.Configuration;
import org.hibernate.cfg.Environment;
import org.hibernate.engine.spi.SessionFactoryImplementor;
import org.hibernate.event.internal.DefaultLoadEventListener;
import org.hibernate.event.service.spi.EventListenerRegistry;
@ -23,35 +20,31 @@ import org.hibernate.event.spi.LoadEvent;
import org.hibernate.event.spi.LoadEventListener;
import org.hibernate.integrator.spi.Integrator;
import org.hibernate.service.spi.SessionFactoryServiceRegistry;
import org.hibernate.stat.spi.StatisticsImplementor;
import org.hibernate.testing.TestForIssue;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
import org.junit.Test;
import org.hibernate.testing.orm.junit.DomainModel;
import org.hibernate.testing.orm.junit.ServiceRegistry;
import org.hibernate.testing.orm.junit.SessionFactory;
import org.hibernate.testing.orm.junit.SessionFactoryScope;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.fail;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
/**
* @author Steve Ebersole
*/
@SuppressWarnings( {"unchecked"})
public class EagerKeyManyToOneTest extends BaseCoreFunctionalTestCase {
@Override
public String[] getMappings() {
return new String[] { "keymanytoone/bidir/component/EagerMapping.hbm.xml" };
}
@DomainModel(xmlMappings = {
"org/hibernate/orm/test/keymanytoone/bidir/component/EagerMapping.hbm.xml"
})
@SessionFactory(generateStatistics = true)
@ServiceRegistry(integrators = EagerKeyManyToOneTest.CustomLoadIntegrator.class)
public class EagerKeyManyToOneTest {
@Override
public void configure(Configuration cfg) {
super.configure( cfg );
cfg.setProperty( Environment.GENERATE_STATISTICS, "true" );
}
@Override
protected void prepareBootstrapRegistryBuilder(BootstrapServiceRegistryBuilder builder) {
super.prepareBootstrapRegistryBuilder( builder );
builder.applyIntegrator(
new Integrator() {
public static class CustomLoadIntegrator implements Integrator {
@Override
public void integrate(
Metadata metadata,
@ -72,33 +65,44 @@ public class EagerKeyManyToOneTest extends BaseCoreFunctionalTestCase {
SessionFactoryImplementor sessionFactory, SessionFactoryServiceRegistry serviceRegistry) {
}
}
@AfterEach
public void tearDown(SessionFactoryScope scope) {
scope.inTransaction(
session -> {
List<Customer> customers = session.createQuery( "from Customer" ).list();
customers.forEach(
customer -> session.delete( customer )
);
}
);
}
@Test
public void testSaveCascadedToKeyManyToOne() {
sessionFactory().getStatistics().clear();
public void testSaveCascadedToKeyManyToOne(SessionFactoryScope scope) {
StatisticsImplementor statistics = scope.getSessionFactory().getStatistics();
statistics.clear();
// test cascading a save to an association with a key-many-to-one which refers to a
// just saved entity
inTransaction(
scope.inTransaction(
s -> {
Customer cust = new Customer( "Acme, Inc." );
Order order = new Order( new Order.Id( cust, 1 ) );
cust.getOrders().add( order );
s.save( cust );
s.flush();
assertEquals( 2, sessionFactory().getStatistics().getEntityInsertCount() );
s.delete( cust );
assertEquals( 2, statistics.getEntityInsertCount() );
}
);
}
@Test
public void testLoadingStrategies() {
sessionFactory().getStatistics().clear();
public void testLoadingStrategies(SessionFactoryScope scope) {
StatisticsImplementor statistics = scope.getSessionFactory().getStatistics();
statistics.clear();
inTransaction(
scope.inTransaction(
s -> {
Customer cust = new Customer( "Acme, Inc." );
Order order = new Order( new Order.Id( cust, 1 ) );
@ -107,7 +111,7 @@ public class EagerKeyManyToOneTest extends BaseCoreFunctionalTestCase {
}
);
inTransaction(
scope.inTransaction(
s -> {
Customer cust = (Customer) s.createQuery( "from Customer" ).uniqueResult();
assertEquals( 1, cust.getOrders().size() );
@ -117,7 +121,8 @@ public class EagerKeyManyToOneTest extends BaseCoreFunctionalTestCase {
assertEquals( 1, cust.getOrders().size() );
s.clear();
cust = ( Customer ) s.createQuery( "from Customer c join fetch c.orders as o join fetch o.id.customer" ).uniqueResult();
cust = (Customer) s.createQuery( "from Customer c join fetch c.orders as o join fetch o.id.customer" )
.uniqueResult();
assertEquals( 1, cust.getOrders().size() );
s.clear();
@ -127,16 +132,15 @@ public class EagerKeyManyToOneTest extends BaseCoreFunctionalTestCase {
cust = s.createQuery( criteria ).uniqueResult();
assertEquals( 1, cust.getOrders().size() );
s.clear();
s.delete( cust );
}
);
}
@Test
@TestForIssue(jiraKey = "HHH-2277")
public void testLoadEntityWithEagerFetchingToKeyManyToOneReferenceBackToSelf() {
sessionFactory().getStatistics().clear();
public void testLoadEntityWithEagerFetchingToKeyManyToOneReferenceBackToSelf(SessionFactoryScope scope) {
StatisticsImplementor statistics = scope.getSessionFactory().getStatistics();
statistics.clear();
// long winded method name to say that this is a test specifically for HHH-2277 ;)
// essentially we have a bidirectional association where one side of the
@ -150,26 +154,23 @@ public class EagerKeyManyToOneTest extends BaseCoreFunctionalTestCase {
// into the persistence context for the association with the
// composite key because we are in the process of trying to build
// the composite-id instance
Session s = openSession();
s.beginTransaction();
Customer cust = new Customer( "Acme, Inc." );
Order order = new Order( new Order.Id( cust, 1 ) );
cust.getOrders().add( order );
s.save( cust );
s.getTransaction().commit();
s.close();
Customer customer = new Customer( "Acme, Inc." );
Order order = new Order( new Order.Id( customer, 1 ) );
customer.getOrders().add( order );
scope.inTransaction(
session -> session.save( customer )
);
s = openSession();
s.beginTransaction();
scope.inTransaction(
session -> {
try {
cust = ( Customer ) s.get( Customer.class, cust.getId() );
session.get( Customer.class, customer.getId() );
}
catch (OverflowCondition overflow) {
fail( "get()/load() caused overflow condition" );
}
s.delete( cust );
s.getTransaction().commit();
s.close();
}
);
}
private static class OverflowCondition extends RuntimeException {
@ -177,6 +178,7 @@ public class EagerKeyManyToOneTest extends BaseCoreFunctionalTestCase {
private static class CustomLoadListener extends DefaultLoadEventListener {
private int internalLoadCount = 0;
@Override
public void onLoad(LoadEvent event, LoadType loadType) throws HibernateException {
if ( LoadEventListener.INTERNAL_LOAD_EAGER.getName().equals( loadType.getName() ) ) {

View File

@ -18,7 +18,7 @@
association.
-->
<hibernate-mapping package="org.hibernate.test.keymanytoone.bidir.component">
<hibernate-mapping package="org.hibernate.orm.test.keymanytoone.bidir.component">
<class name="Customer" table="COMP_LAZY_KM2O_CUST">
<id name="id" column="ID" type="long">
@ -38,7 +38,7 @@
</composite-id>
<set name="items" table="COMP_LAZY_KM2O_ITEM">
<key>
<column name="CUST_ID"/>
<column name="CUSTOMER_ID"/>
<column name="ORDER_NUM"/>
</key>
<element type="string" column="ITEM_DESC" />

View File

@ -0,0 +1,110 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* 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>.
*/
package org.hibernate.orm.test.keymanytoone.bidir.component;
import java.util.List;
import org.hibernate.stat.spi.StatisticsImplementor;
import org.hibernate.testing.orm.junit.DomainModel;
import org.hibernate.testing.orm.junit.SessionFactory;
import org.hibernate.testing.orm.junit.SessionFactoryScope;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
/**
* @author Steve Ebersole
*/
@DomainModel(xmlMappings = {
"org/hibernate/orm/test/keymanytoone/bidir/component/LazyMapping.hbm.xml"
})
@SessionFactory(generateStatistics = true)
public class LazyKeyManyToOneTest {
@AfterEach
public void tearDown(SessionFactoryScope scope) {
scope.inTransaction(
session -> {
List<Customer> customers = session.createQuery( "from Customer" ).list();
customers.forEach(
customer -> session.delete( customer )
);
}
);
}
@Test
public void testQueryingOnMany2One(SessionFactoryScope scope) {
Customer cust = new Customer( "Acme, Inc." );
Order order = new Order( new Order.Id( cust, 1 ) );
cust.getOrders().add( order );
scope.inTransaction(
session -> session.save( cust )
);
scope.inTransaction(
session -> {
List results = session.createQuery( "from Order o where o.id.customer.name = :name" )
.setParameter( "name", cust.getName() )
.list();
assertEquals( 1, results.size() );
}
);
}
@Test
public void testSaveCascadedToKeyManyToOne(SessionFactoryScope scope) {
// test cascading a save to an association with a key-many-to-one which refers to a
// just saved entity
StatisticsImplementor statistics = scope.getSessionFactory().getStatistics();
scope.inTransaction(
session -> {
Customer cust = new Customer( "Acme, Inc." );
Order order = new Order( new Order.Id( cust, 1 ) );
cust.getOrders().add( order );
statistics.clear();
session.save( cust );
session.flush();
assertEquals( 2, statistics.getEntityInsertCount() );
}
);
}
@Test
public void testLoadingStrategies(SessionFactoryScope scope) {
Customer customer = new Customer( "Acme, Inc." );
Order order = new Order( new Order.Id( customer, 1 ) );
customer.getOrders().add( order );
scope.inTransaction(
session -> session.save( customer )
);
scope.inTransaction(
session -> {
Customer cust = session.get( Customer.class, customer.getId() );
assertEquals( 1, cust.getOrders().size() );
session.clear();
cust = (Customer) session.createQuery( "from Customer" ).uniqueResult();
assertEquals( 1, cust.getOrders().size() );
session.clear();
cust = (Customer) session.createQuery( "from Customer c join fetch c.orders" ).uniqueResult();
assertEquals( 1, cust.getOrders().size() );
session.clear();
}
);
}
}

View File

@ -18,7 +18,7 @@
association.
-->
<hibernate-mapping package="org.hibernate.test.keymanytoone.bidir.component">
<hibernate-mapping package="org.hibernate.orm.test.keymanytoone.bidir.component">
<class name="Customer" table="COMP_LAZY_KM2O_CUST">
<id name="id" column="ID" type="long">

View File

@ -4,7 +4,7 @@
* 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>.
*/
package org.hibernate.test.keymanytoone.bidir.component;
package org.hibernate.orm.test.keymanytoone.bidir.component;
import java.io.Serializable;
import java.util.HashSet;
import java.util.Set;

View File

@ -4,7 +4,7 @@
* 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>.
*/
package org.hibernate.test.keymanytoone.unidir.ondelete;
package org.hibernate.orm.test.keymanytoone.unidir.ondelete;
import java.io.Serializable;

View File

@ -0,0 +1,91 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* 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>.
*/
package org.hibernate.orm.test.keymanytoone.unidir.ondelete;
import org.hibernate.testing.TestForIssue;
import org.hibernate.testing.orm.junit.DialectFeatureChecks;
import org.hibernate.testing.orm.junit.DomainModel;
import org.hibernate.testing.orm.junit.RequiresDialectFeature;
import org.hibernate.testing.orm.junit.SessionFactory;
import org.hibernate.testing.orm.junit.SessionFactoryScope;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
/**
* @author Lukasz Antoniak (lukasz dot antoniak at gmail dot com)
*/
@RequiresDialectFeature(feature = DialectFeatureChecks.SupportsCascadeDeleteCheck.class)
@DomainModel(xmlMappings = {
"org/hibernate/orm/test/keymanytoone/unidir/ondelete/Mapping.hbm.xml"
})
@SessionFactory
public class KeyManyToOneCascadeDeleteTest {
@Test
@TestForIssue(jiraKey = "HHH-7807")
public void testComponentCascadeRemoval(SessionFactoryScope scope) {
scope.inSession(
session -> {
Customer customer = new Customer( "Lukasz" );
Order order1 = new Order( new Order.Id( customer, 1L ) );
order1.setItem( "laptop" );
Order order2 = new Order( new Order.Id( customer, 2L ) );
order2.setItem( "printer" );
session.getTransaction().begin();
try {
session.save( customer );
session.save( order1 );
session.save( order2 );
session.getTransaction().commit();
}
catch (Exception e) {
if ( session.getTransaction().isActive() ) {
session.getTransaction().rollback();
}
throw e;
}
// Removing customer cascades to associated orders.
session.getTransaction().begin();
try {
customer = session.get( Customer.class, customer.getId() );
session.delete( customer );
session.getTransaction().commit();
}
catch (Exception e) {
if ( session.getTransaction().isActive() ) {
session.getTransaction().rollback();
}
throw e;
}
session.getTransaction().begin();
try {
assertEquals(
"0",
session.createQuery( "select count(*) from Customer" )
.uniqueResult()
.toString()
);
assertEquals(
"0",
session.createQuery( "select count(*) from Order" ).uniqueResult().toString()
);
session.getTransaction().commit();
}
catch (Exception e) {
if ( session.getTransaction().isActive() ) {
session.getTransaction().rollback();
}
throw e;
}
}
);
}
}

View File

@ -16,7 +16,7 @@
of the composition is a foreign-key to another entity.
-->
<hibernate-mapping package="org.hibernate.test.keymanytoone.unidir.ondelete">
<hibernate-mapping package="org.hibernate.orm.test.keymanytoone.unidir.ondelete">
<class name="Customer" table="CUSTOMERS">
<id name="id" column="ID" type="long">

View File

@ -4,7 +4,7 @@
* 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>.
*/
package org.hibernate.test.keymanytoone.unidir.ondelete;
package org.hibernate.orm.test.keymanytoone.unidir.ondelete;
import java.io.Serializable;

View File

@ -1,110 +0,0 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* 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>.
*/
package org.hibernate.test.keymanytoone.bidir.component;
import java.util.List;
import org.hibernate.Session;
import org.hibernate.cfg.Configuration;
import org.hibernate.cfg.Environment;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
/**
* @author Steve Ebersole
*/
public class EagerCollectionLazyKeyManyToOneTest extends BaseCoreFunctionalTestCase {
@Override
public String[] getMappings() {
return new String[] { "keymanytoone/bidir/component/EagerCollectionLazyKeyManyToOneMapping.hbm.xml" };
}
@Override
public void configure(Configuration cfg) {
super.configure( cfg );
cfg.setProperty( Environment.GENERATE_STATISTICS, "true" );
}
@Test
public void testQueryingOnMany2One() {
Session s = openSession();
s.beginTransaction();
Customer cust = new Customer( "Acme, Inc." );
Order order = new Order( new Order.Id( cust, 1 ) );
cust.getOrders().add( order );
s.save( cust );
s.getTransaction().commit();
s.close();
s = openSession();
s.beginTransaction();
List results = s.createQuery( "from Order o where o.id.customer.name = :name" )
.setParameter( "name", cust.getName() )
.list();
assertEquals( 1, results.size() );
s.getTransaction().commit();
s.close();
s = openSession();
s.beginTransaction();
s.delete( cust );
s.getTransaction().commit();
s.close();
}
@Test
public void testSaveCascadedToKeyManyToOne() {
// test cascading a save to an association with a key-many-to-one which refers to a
// just saved entity
Session s = openSession();
s.beginTransaction();
Customer cust = new Customer( "Acme, Inc." );
Order order = new Order( new Order.Id( cust, 1 ) );
cust.getOrders().add( order );
sessionFactory().getStatistics().clear();
s.save( cust );
s.flush();
assertEquals( 2, sessionFactory().getStatistics().getEntityInsertCount() );
s.delete( cust );
s.getTransaction().commit();
s.close();
}
@Test
public void testLoadingStrategies() {
Session s = openSession();
s.beginTransaction();
Customer cust = new Customer( "Acme, Inc." );
Order order = new Order( new Order.Id( cust, 1 ) );
cust.getOrders().add( order );
s.save( cust );
s.getTransaction().commit();
s.close();
s = openSession();
s.beginTransaction();
cust = ( Customer ) s.get( Customer.class, cust.getId() );
assertEquals( 1, cust.getOrders().size() );
s.clear();
cust = ( Customer ) s.createQuery( "from Customer" ).uniqueResult();
assertEquals( 1, cust.getOrders().size() );
s.clear();
cust = ( Customer ) s.createQuery( "from Customer c join fetch c.orders" ).uniqueResult();
assertEquals( 1, cust.getOrders().size() );
s.clear();
s.delete( cust );
s.getTransaction().commit();
s.close();
}
}

View File

@ -1,109 +0,0 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* 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>.
*/
package org.hibernate.test.keymanytoone.bidir.component;
import java.util.List;
import org.junit.Test;
import org.hibernate.Session;
import org.hibernate.cfg.Configuration;
import org.hibernate.cfg.Environment;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
import static org.junit.Assert.assertEquals;
/**
* @author Steve Ebersole
*/
public class LazyKeyManyToOneTest extends BaseCoreFunctionalTestCase {
@Override
public String[] getMappings() {
return new String[] { "keymanytoone/bidir/component/LazyMapping.hbm.xml" };
}
@Override
public void configure(Configuration cfg) {
super.configure( cfg );
cfg.setProperty( Environment.GENERATE_STATISTICS, "true" );
}
@Test
public void testQueryingOnMany2One() {
Session s = openSession();
s.beginTransaction();
Customer cust = new Customer( "Acme, Inc." );
Order order = new Order( new Order.Id( cust, 1 ) );
cust.getOrders().add( order );
s.save( cust );
s.getTransaction().commit();
s.close();
s = openSession();
s.beginTransaction();
List results = s.createQuery( "from Order o where o.id.customer.name = :name" )
.setParameter( "name", cust.getName() )
.list();
assertEquals( 1, results.size() );
s.getTransaction().commit();
s.close();
s = openSession();
s.beginTransaction();
s.delete( cust );
s.getTransaction().commit();
s.close();
}
@Test
public void testSaveCascadedToKeyManyToOne() {
// test cascading a save to an association with a key-many-to-one which refers to a
// just saved entity
Session s = openSession();
s.beginTransaction();
Customer cust = new Customer( "Acme, Inc." );
Order order = new Order( new Order.Id( cust, 1 ) );
cust.getOrders().add( order );
sessionFactory().getStatistics().clear();
s.save( cust );
s.flush();
assertEquals( 2, sessionFactory().getStatistics().getEntityInsertCount() );
s.delete( cust );
s.getTransaction().commit();
s.close();
}
@Test
public void testLoadingStrategies() {
Session s = openSession();
s.beginTransaction();
Customer cust = new Customer( "Acme, Inc." );
Order order = new Order( new Order.Id( cust, 1 ) );
cust.getOrders().add( order );
s.save( cust );
s.getTransaction().commit();
s.close();
s = openSession();
s.beginTransaction();
cust = ( Customer ) s.get( Customer.class, cust.getId() );
assertEquals( 1, cust.getOrders().size() );
s.clear();
cust = ( Customer ) s.createQuery( "from Customer" ).uniqueResult();
assertEquals( 1, cust.getOrders().size() );
s.clear();
cust = ( Customer ) s.createQuery( "from Customer c join fetch c.orders" ).uniqueResult();
assertEquals( 1, cust.getOrders().size() );
s.clear();
s.delete( cust );
s.getTransaction().commit();
s.close();
}
}

View File

@ -1,58 +0,0 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* 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>.
*/
package org.hibernate.test.keymanytoone.unidir.ondelete;
import org.hibernate.Session;
import org.junit.Assert;
import org.junit.Test;
import org.hibernate.testing.DialectChecks;
import org.hibernate.testing.RequiresDialectFeature;
import org.hibernate.testing.TestForIssue;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
/**
* @author Lukasz Antoniak (lukasz dot antoniak at gmail dot com)
*/
@RequiresDialectFeature(DialectChecks.SupportsCascadeDeleteCheck.class)
public class KeyManyToOneCascadeDeleteTest extends BaseCoreFunctionalTestCase {
@Override
public String[] getMappings() {
return new String[] { "keymanytoone/unidir/ondelete/Mapping.hbm.xml" };
}
@Test
@TestForIssue( jiraKey = "HHH-7807" )
public void testComponentCascadeRemoval() {
Session session = openSession();
session.getTransaction().begin();
Customer customer = new Customer( "Lukasz" );
Order order1 = new Order( new Order.Id( customer, 1L ) );
order1.setItem( "laptop" );
Order order2 = new Order( new Order.Id( customer, 2L ) );
order2.setItem( "printer" );
session.save( customer );
session.save( order1 );
session.save( order2 );
session.getTransaction().commit();
// Removing customer cascades to associated orders.
session.getTransaction().begin();
customer = (Customer) session.get( Customer.class, customer.getId() );
session.delete( customer );
session.getTransaction().commit();
session.getTransaction().begin();
Assert.assertEquals( "0", session.createQuery( "select count(*) from Customer" ).uniqueResult().toString() );
Assert.assertEquals( "0", session.createQuery( "select count(*) from Order" ).uniqueResult().toString() );
session.getTransaction().commit();
session.close();
}
}

View File

@ -14,6 +14,7 @@ import java.lang.annotation.Target;
import org.hibernate.boot.registry.StandardServiceInitiator;
import org.hibernate.engine.spi.SessionFactoryImplementor;
import org.hibernate.integrator.spi.Integrator;
import org.hibernate.service.spi.ServiceContributor;
/**
@ -76,6 +77,8 @@ public @interface ServiceRegistry {
Class<? extends StandardServiceInitiator>[] initiators() default {};
Class<? extends Integrator>[] integrators() default {};
Service[] services() default {};
Setting[] settings() default {};

View File

@ -6,11 +6,15 @@
*/
package org.hibernate.testing.orm.junit;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import org.hibernate.boot.registry.BootstrapServiceRegistryBuilder;
import org.hibernate.boot.registry.StandardServiceInitiator;
import org.hibernate.boot.registry.StandardServiceRegistry;
import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
import org.hibernate.integrator.spi.Integrator;
import org.hibernate.service.spi.ServiceContributor;
import org.junit.jupiter.api.extension.AfterAllCallback;
@ -51,9 +55,10 @@ public class ServiceRegistryExtension
final ExtensionContext.Store store = locateExtensionStore( testInstance, context );
ServiceRegistryScopeImpl scope = (ServiceRegistryScopeImpl) store.get( REGISTRY_KEY );
ServiceRegistryScopeImpl existingScope = (ServiceRegistryScopeImpl) store.get( REGISTRY_KEY );
if ( scope == null ) {
if ( existingScope == null ) {
final ServiceRegistryScopeImpl scope = new ServiceRegistryScopeImpl( );
log.debugf( "Creating ServiceRegistryScope - %s", context.getDisplayName() );
final ServiceRegistryProducer producer;
@ -75,22 +80,34 @@ public class ServiceRegistryExtension
if ( serviceRegistryAnnWrapper.isPresent() ) {
final ServiceRegistry serviceRegistryAnn = serviceRegistryAnnWrapper.get();
configureServices( serviceRegistryAnn, ssrb );
configureIntegrators(serviceRegistryAnn, scope);
}
return ssrb.build();
};
}
scope = new ServiceRegistryScopeImpl( producer );
scope.createRegistry(producer);
locateExtensionStore( testInstance, context ).put( REGISTRY_KEY, scope );
if ( testInstance instanceof ServiceRegistryScopeAware ) {
( (ServiceRegistryScopeAware) testInstance ).injectServiceRegistryScope( scope );
}
return scope;
}
return scope;
return existingScope;
}
private static void configureIntegrators(
ServiceRegistry serviceRegistryAnn,
final ServiceRegistryScopeImpl serviceRegistryScope) {
for ( Class<? extends Integrator> integrator : serviceRegistryAnn.integrators() ) {
serviceRegistryScope.applyIntegrator( integrator );
}
}
private static void configureServices(ServiceRegistry serviceRegistryAnn, StandardServiceRegistryBuilder ssrb) {
@ -154,21 +171,32 @@ public class ServiceRegistryExtension
}
private static class ServiceRegistryScopeImpl implements ServiceRegistryScope, ExtensionContext.Store.CloseableResource {
private final ServiceRegistryProducer producer;
private ServiceRegistryProducer producer;
private StandardServiceRegistry registry;
private boolean active = true;
private List<Class<? extends Integrator>> integrators = new ArrayList<>();
public ServiceRegistryScopeImpl(ServiceRegistryProducer producer) {
this.producer = producer;
public ServiceRegistryScopeImpl() {
this.registry = createRegistry();
}
private StandardServiceRegistry createRegistry() {
public StandardServiceRegistry createRegistry(ServiceRegistryProducer producer) {
this.producer = producer;
verifyActive();
BootstrapServiceRegistryBuilder bootstrapServiceRegistryBuilder = new BootstrapServiceRegistryBuilder().enableAutoClose();
integrators.forEach(
integrator -> {
try {
bootstrapServiceRegistryBuilder.applyIntegrator( integrator.newInstance() );
}
catch (Exception e) {
throw new RuntimeException( "Could not configure BootstrapServiceRegistryBuilder", e );
}
}
);
final StandardServiceRegistryBuilder ssrb = new StandardServiceRegistryBuilder();
final StandardServiceRegistryBuilder ssrb = new StandardServiceRegistryBuilder(bootstrapServiceRegistryBuilder.build());
// we will close it ourselves explicitly.
ssrb.disableAutoClose();
@ -181,12 +209,16 @@ public class ServiceRegistryExtension
}
}
public void applyIntegrator(Class<? extends Integrator> integrator) {
integrators.add( integrator );
}
@Override
public StandardServiceRegistry getRegistry() {
verifyActive();
if ( registry == null ) {
registry = createRegistry();
registry = createRegistry( producer );
}
return registry;

View File

@ -85,7 +85,6 @@ public class SessionFactoryExtension
producer = model -> {
try {
final SessionFactoryBuilder sessionFactoryBuilder = model.getSessionFactoryBuilder();
if ( StringHelper.isNotEmpty( sessionFactoryConfig.sessionFactoryName() ) ) {
sessionFactoryBuilder.applyName( sessionFactoryConfig.sessionFactoryName() );
}
@ -156,6 +155,7 @@ public class SessionFactoryExtension
final StandardServiceRegistry serviceRegistry = model.getMetadataBuildingOptions().getServiceRegistry();
SchemaManagementToolCoordinator.process(
model,
serviceRegistry,