HHH-6262 Bind @EmbeddedId

This commit is contained in:
Strong Liu 2011-08-08 14:04:53 +08:00
parent 89991f8610
commit 50ee956d49
7 changed files with 55 additions and 21 deletions

View File

@ -43,7 +43,7 @@ import org.hibernate.metamodel.source.MetaAttributeContext;
*/
public class BasicAttributeBinding
extends AbstractSingularAttributeBinding
implements SingularAttributeBinding, KeyValueBinding {
implements KeyValueBinding {
private String unsavedValue;
private PropertyGeneration generation;

View File

@ -29,7 +29,7 @@ import org.hibernate.persister.collection.CollectionPersister;
/**
* @author Steve Ebersole
*/
public interface PluralAttributeBinding extends AttributeBinding, AssociationAttributeBinding {
public interface PluralAttributeBinding extends AssociationAttributeBinding {
// todo : really it is the element (and/or index) that can be associative not the collection itself...
public CollectionKey getCollectionKey();

View File

@ -295,24 +295,19 @@ public class EntityClass extends ConfiguredClass {
}
if ( !idAnnotations.isEmpty() ) {
if ( idAnnotations.size() == 1 ) {
return IdType.SIMPLE;
}
else {
return IdType.COMPOSED;
}
return idAnnotations.size() == 1 ? IdType.SIMPLE : IdType.COMPOSED;
}
return IdType.NONE;
}
private List<AnnotationInstance> findIdAnnotations(DotName idAnnotationType) {
List<AnnotationInstance> idAnnotationList = new ArrayList<AnnotationInstance>();
if ( getClassInfo().annotations().get( idAnnotationType ) != null ) {
if ( getClassInfo().annotations().containsKey( idAnnotationType ) ) {
idAnnotationList.addAll( getClassInfo().annotations().get( idAnnotationType ) );
}
ConfiguredClass parent = getParent();
while ( parent != null ) {
if ( parent.getClassInfo().annotations().get( idAnnotationType ) != null ) {
if ( parent.getClassInfo().annotations().containsKey( idAnnotationType ) ) {
idAnnotationList.addAll( parent.getClassInfo().annotations().get( idAnnotationType ) );
}
parent = parent.getParent();

View File

@ -25,6 +25,7 @@ package org.hibernate.metamodel.source.annotations.entity;
import org.hibernate.AssertionFailure;
import org.hibernate.EntityMode;
import org.hibernate.cfg.NotYetImplementedException;
import org.hibernate.engine.OptimisticLockStyle;
import org.hibernate.metamodel.binding.Caching;
import org.hibernate.metamodel.source.annotations.attribute.BasicAttribute;
@ -53,17 +54,15 @@ public class RootEntitySourceImpl extends EntitySourceImpl implements RootEntity
return new SimpleIdentifierSourceImpl( attribute, getEntityClass().getAttributeOverrideMap() );
}
case COMPOSED: {
break;
throw new NotYetImplementedException( "Composed ids must still be implemented." );
}
case EMBEDDED: {
break;
throw new NotYetImplementedException( "Embedded ids must still be implemented." );
}
default: {
throw new AssertionFailure( "The root entity needs to specify an identifier" );
}
}
return null; //To change body of implemented methods use File | Settings | File Templates.
}
@Override

View File

@ -0,0 +1,37 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2011, 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.metamodel.source.binder;
/**
* @author Strong Liu
*/
public interface ComponentIdentifierSource extends IdentifierSource {
/**
* Obtain the source descriptor for the identifier attribute.
*
* @return The identifier attribute source.
*/
public ComponentAttributeSource getIdentifierAttributeSource();
}

View File

@ -23,13 +23,22 @@
*/
package org.hibernate.metamodel.source.binder;
import org.hibernate.metamodel.binding.IdGenerator;
/**
* Contract describing source of identifier information for the entity.
*
* @author Steve Ebersole
*/
public interface IdentifierSource {
public static enum Nature {
/**
* Obtain the identifier generator source.
*
* @return The generator source.
*/
IdGenerator getIdentifierGeneratorDescriptor();
public static enum Nature {
/**
* A single, simple identifier. Equivalent of an {@code <id/>} mapping or a single {@code @Id}
* annotation. Indicates the {@link IdentifierSource} is castable to {@link SimpleIdentifierSource}.

View File

@ -38,10 +38,4 @@ public interface SimpleIdentifierSource extends IdentifierSource {
*/
public SingularAttributeSource getIdentifierAttributeSource();
/**
* Obtain the identifier generator source.
*
* @return The generator source.
*/
public IdGenerator getIdentifierGeneratorDescriptor();
}