Author: steve.ebersole(a)jboss.com
Date: 2010-03-30 15:36:43 -0400 (Tue, 30 Mar 2010)
New Revision: 19141
Added:
core/trunk/annotations/src/main/java/org/hibernate/mapping/SyntheticProperty.java
Modified:
core/trunk/annotations/src/main/java/org/hibernate/cfg/BinderHelper.java
core/trunk/core/src/main/java/org/hibernate/mapping/Backref.java
core/trunk/core/src/main/java/org/hibernate/mapping/IndexBackref.java
core/trunk/core/src/main/java/org/hibernate/mapping/Property.java
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/annotations/src/main/java/org/hibernate/cfg/BinderHelper.java
===================================================================
--- core/trunk/annotations/src/main/java/org/hibernate/cfg/BinderHelper.java 2010-03-30
13:15:29 UTC (rev 19140)
+++ core/trunk/annotations/src/main/java/org/hibernate/cfg/BinderHelper.java 2010-03-30
19:36:43 UTC (rev 19141)
@@ -57,6 +57,7 @@
import org.hibernate.mapping.PersistentClass;
import org.hibernate.mapping.Property;
import org.hibernate.mapping.SimpleValue;
+import org.hibernate.mapping.SyntheticProperty;
import org.hibernate.mapping.Table;
import org.hibernate.mapping.ToOne;
import org.hibernate.mapping.Value;
@@ -156,9 +157,10 @@
clone.setInsertable( false );
clone.setUpdateable( false );
clone.setNaturalIdentifier( false );
+ clone.setGeneration( property.getGeneration() );
embeddedComp.addProperty( clone );
}
- synthProp = new Property();
+ synthProp = new SyntheticProperty();
synthProp.setName( syntheticPropertyName );
synthProp.setNodeName( syntheticPropertyName );
synthProp.setPersistentClass( ownerEntity );
Added: core/trunk/annotations/src/main/java/org/hibernate/mapping/SyntheticProperty.java
===================================================================
--- core/trunk/annotations/src/main/java/org/hibernate/mapping/SyntheticProperty.java
(rev 0)
+++
core/trunk/annotations/src/main/java/org/hibernate/mapping/SyntheticProperty.java 2010-03-30
19:36:43 UTC (rev 19141)
@@ -0,0 +1,37 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2010, 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.mapping;
+
+/**
+ * Models a property which does not actually exist in the model. It is created by
Hibernate during
+ * the metamodel binding process.
+ *
+ * @author Steve Ebersole
+ */
+public class SyntheticProperty extends Property {
+ @Override
+ public boolean isSynthetic() {
+ return true;
+ }
+}
Modified: core/trunk/core/src/main/java/org/hibernate/mapping/Backref.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/mapping/Backref.java 2010-03-30 13:15:29
UTC (rev 19140)
+++ core/trunk/core/src/main/java/org/hibernate/mapping/Backref.java 2010-03-30 19:36:43
UTC (rev 19141)
@@ -1,10 +1,10 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
- * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * Copyright (c) 2010, 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 Middleware LLC.
+ * 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
@@ -20,7 +20,6 @@
* Free Software Foundation, Inc.
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
- *
*/
package org.hibernate.mapping;
@@ -33,13 +32,25 @@
public class Backref extends Property {
private String collectionRole;
private String entityName;
-
+
+ /**
+ * {@inheritDoc}
+ */
public boolean isBackRef() {
return true;
}
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean isSynthetic() {
+ return true;
+ }
+
public String getCollectionRole() {
return collectionRole;
}
+
public void setCollectionRole(String collectionRole) {
this.collectionRole = collectionRole;
}
Modified: core/trunk/core/src/main/java/org/hibernate/mapping/IndexBackref.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/mapping/IndexBackref.java 2010-03-30
13:15:29 UTC (rev 19140)
+++ core/trunk/core/src/main/java/org/hibernate/mapping/IndexBackref.java 2010-03-30
19:36:43 UTC (rev 19141)
@@ -1,10 +1,10 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
- * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * Copyright (c) 2010, 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 Middleware LLC.
+ * 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
@@ -20,7 +20,6 @@
* Free Software Foundation, Inc.
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
- *
*/
package org.hibernate.mapping;
@@ -37,9 +36,18 @@
public boolean isBackRef() {
return true;
}
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean isSynthetic() {
+ return true;
+ }
+
public String getCollectionRole() {
return collectionRole;
}
+
public void setCollectionRole(String collectionRole) {
this.collectionRole = collectionRole;
}
@@ -55,6 +63,7 @@
public String getEntityName() {
return entityName;
}
+
public void setEntityName(String entityName) {
this.entityName = entityName;
}
Modified: core/trunk/core/src/main/java/org/hibernate/mapping/Property.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/mapping/Property.java 2010-03-30 13:15:29
UTC (rev 19140)
+++ core/trunk/core/src/main/java/org/hibernate/mapping/Property.java 2010-03-30 19:36:43
UTC (rev 19141)
@@ -1,10 +1,10 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
- * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * Copyright (c) 2010, 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 Middleware LLC.
+ * 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
@@ -20,7 +20,6 @@
* Free Software Foundation, Inc.
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
- *
*/
package org.hibernate.mapping;
@@ -63,11 +62,22 @@
private java.util.Map metaAttributes;
private PersistentClass persistentClass;
private boolean naturalIdentifier;
-
+
public boolean isBackRef() {
return false;
}
+ /**
+ * Does this property represent a synthetic property? A synthetic property is one we
create during
+ * metamodel binding to represent a collection of columns but which does not represent a
property
+ * physically available on the entity.
+ *
+ * @return True if synthetic; false otherwise.
+ */
+ public boolean isSynthetic() {
+ return false;
+ }
+
public Type getType() throws MappingException {
return value.getType();
}
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
13:15:29 UTC (rev 19140)
+++
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/metamodel/AttributeFactory.java 2010-03-30
19:36:43 UTC (rev 19141)
@@ -83,9 +83,9 @@
*/
@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() );
+ if ( property.isSynthetic() ) {
+ // hide synthetic/virtual properties (fabricated by Hibernate) from the JPA
metamodel.
+ log.trace( "Skipping synthetic property {}({})",
ownerType.getJavaType().getName(), property.getName() );
return null;
}
log.trace( "Building attribute [{}.{}]", ownerType.getJavaType().getName(),
property.getName() );
@@ -114,12 +114,6 @@
}
}
- 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() {