Author: steve.ebersole(a)jboss.com
Date: 2010-03-29 21:37:23 -0400 (Mon, 29 Mar 2010)
New Revision: 19137
Modified:
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/metamodel/AttributeFactory.java
Log:
HHH-4870 - Cannot determine java-type from given member [null]
Modified:
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/metamodel/AttributeFactory.java
===================================================================
---
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/metamodel/AttributeFactory.java 2010-03-30
01:05:18 UTC (rev 19136)
+++
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/metamodel/AttributeFactory.java 2010-03-30
01:37:23 UTC (rev 19137)
@@ -83,9 +83,12 @@
*/
@SuppressWarnings({ "unchecked" })
public <X, Y> AttributeImplementor<X, Y>
buildAttribute(AbstractManagedType<X> ownerType, Property property) {
+ if ( isVirtual( property, ownerType ) ) {
+ // hide virtual properties (fabricated by Hibernate) from the JPA metamodel.
+ log.trace( "Skipping virtual property {}({})",
ownerType.getJavaType().getName(), property.getName() );
+ return null;
+ }
log.trace( "Building attribute [{}.{}]", ownerType.getJavaType().getName(),
property.getName() );
- //a back ref is a virtual property created by Hibernate, let's hide it from the JPA
model.
- if ( property.isBackRef() ) return null;
final AttributeContext<X> attributeContext = wrap( ownerType, property );
final AttributeMetadata<X,Y> attributeMetadata =
determineAttributeMetadata( attributeContext, NORMAL_MEMBER_RESOLVER );
@@ -111,6 +114,12 @@
}
}
+ private <X> boolean isVirtual(Property property, AbstractManagedType<X>
ownerType) {
+ // back-refs and embedded components are considered virtual
+ return property.isBackRef()
+ || ( property.isComposite() && ( (Component) property.getValue()
).isEmbedded() );
+ }
+
private <X> AttributeContext<X> wrap(final AbstractManagedType<X>
ownerType, final Property property) {
return new AttributeContext<X>() {
public AbstractManagedType<X> getOwnerType() {
Show replies by date