HHH-8712 - Hibernate startup error "HHH015011: Unable to locate static metamodel field"

(cherry picked from commit bf41b43c16)
This commit is contained in:
Steve Ebersole 2015-10-28 21:26:48 -05:00
parent 2ed2319eb6
commit 12ada0ce34
6 changed files with 8 additions and 75 deletions

View File

@ -80,8 +80,8 @@ public interface EntityManagerMessageLogger extends CoreMessageLogger {
URL jarUrl, URL jarUrl,
@Cause Exception e); @Cause Exception e);
@LogMessage(level = ERROR) @LogMessage(level = WARN)
@Message(value = "Unable to locate static metamodel field : %s#%s", id = 15011) @Message(value = "Unable to locate static metamodel field : %s#%s; this may or may not indicate a problem with the static metamodel", id = 15011)
void unableToLocateStaticMetamodelField( void unableToLocateStaticMetamodelField(
String name, String name,
String name2); String name2);

View File

@ -19,6 +19,7 @@ import javax.persistence.metamodel.Attribute;
import javax.persistence.metamodel.IdentifiableType; import javax.persistence.metamodel.IdentifiableType;
import javax.persistence.metamodel.MappedSuperclassType; import javax.persistence.metamodel.MappedSuperclassType;
import javax.persistence.metamodel.SingularAttribute; import javax.persistence.metamodel.SingularAttribute;
import javax.persistence.metamodel.Type;
import org.hibernate.annotations.common.AssertionFailure; import org.hibernate.annotations.common.AssertionFailure;
import org.hibernate.engine.spi.SessionFactoryImplementor; import org.hibernate.engine.spi.SessionFactoryImplementor;
@ -411,7 +412,11 @@ class MetadataContext {
// //
// As a result, in the case of embeddable classes we simply use getField rather than get // As a result, in the case of embeddable classes we simply use getField rather than get
// getDeclaredField // getDeclaredField
final Field field = attribute.getPersistentAttributeType() == Attribute.PersistentAttributeType.EMBEDDED final boolean allowNonDeclaredFieldReference =
attribute.getPersistentAttributeType() == Attribute.PersistentAttributeType.EMBEDDED
|| attribute.getDeclaringType().getPersistenceType() == Type.PersistenceType.EMBEDDABLE;
final Field field = allowNonDeclaredFieldReference
? metamodelClass.getField( name ) ? metamodelClass.getField( name )
: metamodelClass.getDeclaredField( name ); : metamodelClass.getDeclaredField( name );
try { try {

View File

@ -1,17 +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.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<WorkOrderComponentId, Long> lineNumber;
}

View File

@ -1,20 +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.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<WorkOrderComponent, WorkOrderComponentId> id;
public static volatile SingularAttribute<WorkOrderComponent, WorkOrder> workOrder;
}

View File

@ -1,16 +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.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<WorkOrderId, Long> plantId;
public static volatile SingularAttribute<WorkOrderId, String> workOrder;
}

View File

@ -1,19 +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.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<WorkOrder, WorkOrderId> id;
public static volatile PluralAttribute<WorkOrder, Set, WorkOrderComponent> components;
}