HHH-4870 - Cannot determine java-type from given member [null]

git-svn-id: https://svn.jboss.org/repos/hibernate/core/trunk@19141 1b8cb986-b30d-0410-93ca-fae66ebed9b2
This commit is contained in:
Steve Ebersole 2010-03-30 19:36:43 +00:00
parent 54d496295e
commit bec1835baf
6 changed files with 84 additions and 21 deletions

View File

@ -57,6 +57,7 @@ import org.hibernate.mapping.Join;
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 @@ public class BinderHelper {
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 );

View File

@ -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;
}
}

View File

@ -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 @@ import org.hibernate.property.PropertyAccessor;
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;
}

View File

@ -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 class IndexBackref extends Property {
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 class IndexBackref extends Property {
public String getEntityName() {
return entityName;
}
public void setEntityName(String entityName) {
this.entityName = entityName;
}

View File

@ -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 @@ public class Property implements Serializable, MetaAttributable {
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();
}

View File

@ -83,9 +83,9 @@ public class AttributeFactory {
*/
@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 @@ public class AttributeFactory {
}
}
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() {