From 2ed2319eb6190bc29860074645726d9c552806fa Mon Sep 17 00:00:00 2001 From: Steve Ebersole Date: Wed, 28 Oct 2015 20:44:05 -0500 Subject: [PATCH] HHH-8712 - Hibernate startup error "HHH015011: Unable to locate static metamodel field" (cherry picked from commit dbb84be8106e9160dad513431d0602f22c567a21) --- .../FunkyExtendedEmbeddedIdTest.java | 5 +++- .../metamodel/attributeInSuper/WorkOrder.java | 24 +++++++++++++++++++ .../attributeInSuper/WorkOrderComponent.java | 9 +++++++ .../WorkOrderComponentId_.java | 17 +++++++++++++ .../attributeInSuper/WorkOrderComponent_.java | 20 ++++++++++++++++ .../attributeInSuper/WorkOrderId_.java | 16 +++++++++++++ .../attributeInSuper/WorkOrder_.java | 19 +++++++++++++++ 7 files changed, 109 insertions(+), 1 deletion(-) create mode 100644 hibernate-entitymanager/src/test/java/org/hibernate/jpa/test/metamodel/attributeInSuper/WorkOrder.java create mode 100644 hibernate-entitymanager/src/test/java/org/hibernate/jpa/test/metamodel/attributeInSuper/WorkOrderComponentId_.java create mode 100644 hibernate-entitymanager/src/test/java/org/hibernate/jpa/test/metamodel/attributeInSuper/WorkOrderComponent_.java create mode 100644 hibernate-entitymanager/src/test/java/org/hibernate/jpa/test/metamodel/attributeInSuper/WorkOrderId_.java create mode 100644 hibernate-entitymanager/src/test/java/org/hibernate/jpa/test/metamodel/attributeInSuper/WorkOrder_.java diff --git a/hibernate-entitymanager/src/test/java/org/hibernate/jpa/test/metamodel/attributeInSuper/FunkyExtendedEmbeddedIdTest.java b/hibernate-entitymanager/src/test/java/org/hibernate/jpa/test/metamodel/attributeInSuper/FunkyExtendedEmbeddedIdTest.java index cf41667a34..c29d7ca195 100644 --- a/hibernate-entitymanager/src/test/java/org/hibernate/jpa/test/metamodel/attributeInSuper/FunkyExtendedEmbeddedIdTest.java +++ b/hibernate-entitymanager/src/test/java/org/hibernate/jpa/test/metamodel/attributeInSuper/FunkyExtendedEmbeddedIdTest.java @@ -23,7 +23,10 @@ public class FunkyExtendedEmbeddedIdTest extends BaseEntityManagerFunctionalTest @Override public Class[] getAnnotatedClasses() { return new Class[] { - WorkOrderComponentId.class, WorkOrderComponent.class, WorkOrderId.class + WorkOrderId.class, + WorkOrder.class, + WorkOrderComponentId.class, + WorkOrderComponent.class }; } diff --git a/hibernate-entitymanager/src/test/java/org/hibernate/jpa/test/metamodel/attributeInSuper/WorkOrder.java b/hibernate-entitymanager/src/test/java/org/hibernate/jpa/test/metamodel/attributeInSuper/WorkOrder.java new file mode 100644 index 0000000000..09c62f5a0b --- /dev/null +++ b/hibernate-entitymanager/src/test/java/org/hibernate/jpa/test/metamodel/attributeInSuper/WorkOrder.java @@ -0,0 +1,24 @@ +/* + * 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 . + */ +package org.hibernate.jpa.test.metamodel.attributeInSuper; + +import java.io.Serializable; +import java.util.Set; +import javax.persistence.CascadeType; +import javax.persistence.EmbeddedId; +import javax.persistence.OneToMany; +import javax.persistence.OrderBy; + +@javax.persistence.Entity +public class WorkOrder implements Serializable { + @EmbeddedId + private WorkOrderId id; + @OneToMany(cascade = CascadeType.ALL, orphanRemoval = true, mappedBy = "workOrder") + @OrderBy("operation, bomItemNumber") + private Set components; + /* other stuffs */ +} \ No newline at end of file diff --git a/hibernate-entitymanager/src/test/java/org/hibernate/jpa/test/metamodel/attributeInSuper/WorkOrderComponent.java b/hibernate-entitymanager/src/test/java/org/hibernate/jpa/test/metamodel/attributeInSuper/WorkOrderComponent.java index 1794b99b92..172156dc5e 100644 --- a/hibernate-entitymanager/src/test/java/org/hibernate/jpa/test/metamodel/attributeInSuper/WorkOrderComponent.java +++ b/hibernate-entitymanager/src/test/java/org/hibernate/jpa/test/metamodel/attributeInSuper/WorkOrderComponent.java @@ -7,6 +7,9 @@ package org.hibernate.jpa.test.metamodel.attributeInSuper; import javax.persistence.EmbeddedId; +import javax.persistence.JoinColumn; +import javax.persistence.JoinColumns; +import javax.persistence.ManyToOne; /** * @author Steve Ebersole @@ -15,4 +18,10 @@ import javax.persistence.EmbeddedId; public class WorkOrderComponent { @EmbeddedId private WorkOrderComponentId id; + @ManyToOne + @JoinColumns({ + @JoinColumn(name = "WORK_ORDER", nullable = false, insertable = false, updatable = false), + @JoinColumn(name = "PLANT_ID", nullable = false, insertable = false, updatable = false) + }) + private WorkOrder workOrder; } diff --git a/hibernate-entitymanager/src/test/java/org/hibernate/jpa/test/metamodel/attributeInSuper/WorkOrderComponentId_.java b/hibernate-entitymanager/src/test/java/org/hibernate/jpa/test/metamodel/attributeInSuper/WorkOrderComponentId_.java new file mode 100644 index 0000000000..9a5e77ace1 --- /dev/null +++ b/hibernate-entitymanager/src/test/java/org/hibernate/jpa/test/metamodel/attributeInSuper/WorkOrderComponentId_.java @@ -0,0 +1,17 @@ +/* + * 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 . + */ +package org.hibernate.jpa.test.metamodel.attributeInSuper; + +import javax.persistence.metamodel.SingularAttribute; +import javax.persistence.metamodel.StaticMetamodel; + +@StaticMetamodel(WorkOrderComponentId.class) +public abstract class WorkOrderComponentId_ extends WorkOrderId_ { + + public static volatile SingularAttribute lineNumber; + +} \ No newline at end of file diff --git a/hibernate-entitymanager/src/test/java/org/hibernate/jpa/test/metamodel/attributeInSuper/WorkOrderComponent_.java b/hibernate-entitymanager/src/test/java/org/hibernate/jpa/test/metamodel/attributeInSuper/WorkOrderComponent_.java new file mode 100644 index 0000000000..8886435300 --- /dev/null +++ b/hibernate-entitymanager/src/test/java/org/hibernate/jpa/test/metamodel/attributeInSuper/WorkOrderComponent_.java @@ -0,0 +1,20 @@ +/* + * 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 . + */ +package org.hibernate.jpa.test.metamodel.attributeInSuper; + +import javax.persistence.metamodel.SingularAttribute; +import javax.persistence.metamodel.StaticMetamodel; + +/** + * @author Steve Ebersole + */ +@StaticMetamodel(WorkOrderComponent.class) +public class WorkOrderComponent_ { + public static volatile SingularAttribute id; + public static volatile SingularAttribute workOrder; + +} diff --git a/hibernate-entitymanager/src/test/java/org/hibernate/jpa/test/metamodel/attributeInSuper/WorkOrderId_.java b/hibernate-entitymanager/src/test/java/org/hibernate/jpa/test/metamodel/attributeInSuper/WorkOrderId_.java new file mode 100644 index 0000000000..bdeaf2451f --- /dev/null +++ b/hibernate-entitymanager/src/test/java/org/hibernate/jpa/test/metamodel/attributeInSuper/WorkOrderId_.java @@ -0,0 +1,16 @@ +/* + * 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 . + */ +package org.hibernate.jpa.test.metamodel.attributeInSuper; + +import javax.persistence.metamodel.SingularAttribute; +import javax.persistence.metamodel.StaticMetamodel; + +@StaticMetamodel(WorkOrderId.class) +public abstract class WorkOrderId_ { + public static volatile SingularAttribute plantId; + public static volatile SingularAttribute workOrder; +} diff --git a/hibernate-entitymanager/src/test/java/org/hibernate/jpa/test/metamodel/attributeInSuper/WorkOrder_.java b/hibernate-entitymanager/src/test/java/org/hibernate/jpa/test/metamodel/attributeInSuper/WorkOrder_.java new file mode 100644 index 0000000000..8bdd84bbd0 --- /dev/null +++ b/hibernate-entitymanager/src/test/java/org/hibernate/jpa/test/metamodel/attributeInSuper/WorkOrder_.java @@ -0,0 +1,19 @@ +/* + * 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 . + */ +package org.hibernate.jpa.test.metamodel.attributeInSuper; + +import java.util.Set; +import javax.persistence.metamodel.PluralAttribute; +import javax.persistence.metamodel.SingularAttribute; +import javax.persistence.metamodel.StaticMetamodel; + +@StaticMetamodel(WorkOrder.class) +public class WorkOrder_ { + public static volatile SingularAttribute id; + public static volatile PluralAttribute components; + +}