Skip to content

Loading…

Test case for https://hibernate.atlassian.net/browse/HHH-8581 #605

Closed
wants to merge 2 commits into from

2 participants

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Oct 1, 2013
  1. @awallgren
Commits on Oct 2, 2013
  1. @awallgren

    Add @TetForIssue annotation.

    awallgren committed
View
78 hibernate-core/src/test/java/org/hibernate/test/batch/joinedInheritence/Animal.java
@@ -0,0 +1,78 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2012, Red Hat Inc. or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.test.batch.joinedInheritence;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+import javax.persistence.Inheritance;
+import javax.persistence.InheritanceType;
+import javax.persistence.Version;
+import javax.validation.constraints.NotNull;
+
+import org.hibernate.annotations.GenericGenerator;
+
+/**
+ * @author Steve Ebersole
+ */
+@Entity
+@Inheritance( strategy = InheritanceType.JOINED )
+public class Animal {
+ private Long id;
+ private long weight;
+ private Long version;
+
+ @Id
+ @GeneratedValue( generator = "increment" )
+ @GenericGenerator( strategy = "increment", name = "increment" )
+ public Long getId() {
+ return id;
+ }
+
+ public void setId(Long id) {
+ this.id = id;
+ }
+
+ @Column(nullable = false)
+ @NotNull
+ @Version
+ public Long getVersion()
+ {
+ return version;
+ }
+
+ public void setVersion(Long version)
+ {
+ this.version = version;
+ }
+
+ public long getWeight() {
+ return weight;
+ }
+
+ public void setWeight(long weight) {
+ this.weight = weight;
+ }
+}
View
66 ...org/hibernate/test/batch/joinedInheritence/BatchVersionedUpdateOfJoinedHierarchyTest.java
@@ -0,0 +1,66 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2012, Red Hat Inc. or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.test.batch.joinedInheritence;
+
+import org.hibernate.Session;
+import org.hibernate.testing.TestForIssue;
+import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
+
+import org.junit.Test;
+
+@TestForIssue( jiraKey = "HHH-8581" )
+public class BatchVersionedUpdateOfJoinedHierarchyTest
+ extends BaseCoreFunctionalTestCase {
+ @Override
+ protected Class<?>[] getAnnotatedClasses() {
+ return new Class[] { Animal.class, Lion.class, Tiger.class, Zoo.class };
+ }
+
+ @Test
+ public void testUpdateVersionedWithWhereClause() {
+ Session session = openSession();
+ session.beginTransaction();
+ session.createQuery("update versioned Animal set weight = 69 where weight = 0").executeUpdate();
+ session.getTransaction().commit();
+ session.close();
+ }
+
+ @Test
+ public void testUpdateWithWhereClause() {
+ Session session = openSession();
+ session.beginTransaction();
+ session.createQuery("update Animal set weight = 69 where weight = 0").executeUpdate();
+ session.getTransaction().commit();
+ session.close();
+ }
+
+ @Test
+ public void testUpdateVersionedWithoutWhereClause() {
+ Session session = openSession();
+ session.beginTransaction();
+ session.createQuery("update versioned Animal set weight = 69").executeUpdate();
+ session.getTransaction().commit();
+ session.close();
+ }
+}
View
34 hibernate-core/src/test/java/org/hibernate/test/batch/joinedInheritence/Lion.java
@@ -0,0 +1,34 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2012, Red Hat Inc. or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.test.batch.joinedInheritence;
+
+import javax.persistence.Entity;
+
+/**
+ * @author Steve Ebersole
+ */
+@Entity
+public class Lion extends Animal
+{
+}
View
43 hibernate-core/src/test/java/org/hibernate/test/batch/joinedInheritence/Tiger.java
@@ -0,0 +1,43 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2012, Red Hat Inc. or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.test.batch.joinedInheritence;
+
+import javax.persistence.Entity;
+
+/**
+ * @author Steve Ebersole
+ */
+@Entity
+public class Tiger extends Animal
+{
+ private int numberOfStripes;
+
+ public int getNumberOfStripes() {
+ return numberOfStripes;
+ }
+
+ public void setNumberOfStripes(int numberOfStripes) {
+ this.numberOfStripes = numberOfStripes;
+ }
+}
View
97 hibernate-core/src/test/java/org/hibernate/test/batch/joinedInheritence/Zoo.java
@@ -0,0 +1,97 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2012, Red Hat Inc. or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.test.batch.joinedInheritence;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import javax.persistence.Entity;
+import javax.persistence.FetchType;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+import javax.persistence.JoinColumn;
+import javax.persistence.OneToMany;
+
+import org.hibernate.annotations.GenericGenerator;
+
+/**
+ * @author Steve Ebersole
+ */
+@Entity
+public class Zoo {
+ private Long id;
+ private String name;
+ private String city;
+ private Set<Tiger> tigers = new HashSet<Tiger>();
+ private Set<Lion> lions = new HashSet<Lion>();
+
+ @Id
+ @GeneratedValue( generator = "increment" )
+ @GenericGenerator( strategy = "increment", name = "increment" )
+ public Long getId() {
+ return id;
+ }
+
+ public void setId(Long id) {
+ this.id = id;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getCity() {
+ return city;
+ }
+
+ public void setCity(String city) {
+ this.city = city;
+ }
+
+ @OneToMany( fetch = FetchType.EAGER ) // eager so that load-by-id queries include this association
+ @JoinColumn
+ @javax.persistence.OrderBy( "weight" )
+ public Set<Tiger> getTigers() {
+ return tigers;
+ }
+
+ public void setTigers(Set<Tiger> tigers) {
+ this.tigers = tigers;
+ }
+
+ @OneToMany( fetch = FetchType.EAGER ) // eager so that load-by-id queries include this association
+ @JoinColumn
+ @org.hibernate.annotations.OrderBy( clause = "weight" )
+ public Set<Lion> getLions() {
+ return lions;
+ }
+
+ public void setLions(Set<Lion> lions) {
+ this.lions = lions;
+ }
+}
Something went wrong with that request. Please try again.