HHH-7450 component

This commit is contained in:
Strong Liu 2012-07-16 20:38:03 +08:00
parent 347398aad5
commit f100b3de03
3 changed files with 95 additions and 39 deletions

View File

@ -28,12 +28,19 @@ import java.util.List;
import org.hibernate.cfg.NotYetImplementedException;
import org.hibernate.internal.jaxb.mapping.hbm.ComponentSourceElement;
import org.hibernate.internal.jaxb.mapping.hbm.JaxbAnyElement;
import org.hibernate.internal.jaxb.mapping.hbm.JaxbArrayElement;
import org.hibernate.internal.jaxb.mapping.hbm.JaxbBagElement;
import org.hibernate.internal.jaxb.mapping.hbm.JaxbComponentElement;
import org.hibernate.internal.jaxb.mapping.hbm.JaxbDynamicComponentElement;
import org.hibernate.internal.jaxb.mapping.hbm.JaxbListElement;
import org.hibernate.internal.jaxb.mapping.hbm.JaxbManyToManyElement;
import org.hibernate.internal.jaxb.mapping.hbm.JaxbManyToOneElement;
import org.hibernate.internal.jaxb.mapping.hbm.JaxbMapElement;
import org.hibernate.internal.jaxb.mapping.hbm.JaxbOneToManyElement;
import org.hibernate.internal.jaxb.mapping.hbm.JaxbOneToOneElement;
import org.hibernate.internal.jaxb.mapping.hbm.JaxbPrimitiveArrayElement;
import org.hibernate.internal.jaxb.mapping.hbm.JaxbPropertyElement;
import org.hibernate.internal.jaxb.mapping.hbm.JaxbSetElement;
import org.hibernate.internal.util.Value;
import org.hibernate.metamodel.spi.binding.SingularAttributeBinding;
import org.hibernate.metamodel.spi.source.AttributeSource;
@ -75,36 +82,7 @@ public abstract class AbstractComponentAttributeSourceImpl extends AbstractHbmSo
}
protected abstract List<AttributeSource> buildAttributeSources();
protected AttributeSource buildAttributeSource(Object attributeElement) {
if ( JaxbPropertyElement.class.isInstance( attributeElement ) ) {
return buildPropertyAttributeSource( (JaxbPropertyElement) attributeElement );
}
else if ( JaxbComponentElement.class.isInstance( attributeElement ) ) {
return buildComponentAttributeSource( (JaxbComponentElement) attributeElement );
}
else if ( JaxbManyToOneElement.class.isInstance( attributeElement ) ) {
return buildManyToOneAttributeSource( (JaxbManyToOneElement) attributeElement );
}
else if ( JaxbOneToOneElement.class.isInstance( attributeElement ) ) {
return buildOneToOneAttributeSource( (JaxbOneToOneElement) attributeElement );
}
else if ( JaxbAnyElement.class.isInstance( attributeElement ) ) {
return buildAnyAttributeSource( (JaxbAnyElement) attributeElement );
}
else if ( JaxbOneToManyElement.class.isInstance( attributeElement ) ) {
return buildOneToManyAttributeSource( (JaxbOneToManyElement) attributeElement );
}
else if ( JaxbManyToManyElement.class.isInstance( attributeElement ) ) {
return buildManyToManyAttributeSource( (JaxbManyToManyElement) attributeElement );
}
throw new UnexpectedAttributeSourceTypeException(
"Encountered an unanticipated AttributeSource type : " + attributeElement.getClass().getName()
);
}
protected SingularAttributeSource buildPropertyAttributeSource(JaxbPropertyElement attributeElement) {
protected SingularAttributeSource buildAttributeSource(JaxbPropertyElement attributeElement) {
return new PropertyAttributeSourceImpl(
sourceMappingDocument(),
attributeElement,
@ -113,7 +91,7 @@ public abstract class AbstractComponentAttributeSourceImpl extends AbstractHbmSo
);
}
protected AttributeSource buildComponentAttributeSource(JaxbComponentElement attributeElement) {
protected AttributeSource buildAttributeSource(JaxbComponentElement attributeElement) {
return new ComponentAttributeSourceImpl(
sourceMappingDocument(),
attributeElement,
@ -122,8 +100,11 @@ public abstract class AbstractComponentAttributeSourceImpl extends AbstractHbmSo
naturalIdMutability
);
}
protected AttributeSource buildManyToOneAttributeSource(JaxbManyToOneElement attributeElement) {
protected AttributeSource buildAttributeSource(JaxbDynamicComponentElement attributeElement){
// todo : implement
throw new NotYetImplementedException();
}
protected AttributeSource buildAttributeSource(JaxbManyToOneElement attributeElement) {
return new ManyToOneAttributeSourceImpl(
sourceMappingDocument(),
JaxbManyToOneElement.class.cast( attributeElement ),
@ -132,25 +113,51 @@ public abstract class AbstractComponentAttributeSourceImpl extends AbstractHbmSo
);
}
protected AttributeSource buildOneToOneAttributeSource(JaxbOneToOneElement attributeElement) {
protected AttributeSource buildAttributeSource(JaxbOneToOneElement attributeElement) {
// todo : implement
throw new NotYetImplementedException();
}
protected AttributeSource buildAnyAttributeSource(JaxbAnyElement attributeElement) {
protected AttributeSource buildAttributeSource(JaxbAnyElement attributeElement) {
// todo : implement
throw new NotYetImplementedException();
}
protected AttributeSource buildOneToManyAttributeSource(JaxbOneToManyElement attributeElement) {
protected AttributeSource buildAttributeSource(JaxbOneToManyElement attributeElement) {
// todo : implement
throw new NotYetImplementedException();
}
protected AttributeSource buildManyToManyAttributeSource(JaxbManyToManyElement attributeElement) {
protected AttributeSource buildAttributeSource(JaxbManyToManyElement attributeElement) {
// todo : implement
throw new NotYetImplementedException();
}
// todo duplicated with org.hibernate.metamodel.internal.source.hbm.AbstractEntitySourceImpl
protected AttributeSource buildAttributeSource(JaxbMapElement attributeElement){
// todo : implement
throw new NotYetImplementedException();
}
protected AttributeSource buildAttributeSource(JaxbSetElement attributeElement) {
// todo : implement
throw new NotYetImplementedException();
}
protected AttributeSource buildAttributeSource(JaxbListElement attributeElement) {
// todo : implement
throw new NotYetImplementedException();
}
protected AttributeSource buildAttributeSource(JaxbBagElement attributeElement) {
// todo : implement
throw new NotYetImplementedException();
}
protected AttributeSource buildAttributeSource(JaxbArrayElement attributeElement) {
// todo : implement
throw new NotYetImplementedException();
}
protected AttributeSource buildAttributeSource(JaxbPrimitiveArrayElement attributeElement) {
// todo : implement
throw new NotYetImplementedException();
}
protected ComponentSourceElement componentSourceElement() {
return componentSourceElement;

View File

@ -27,7 +27,18 @@ import java.util.ArrayList;
import java.util.List;
import org.hibernate.EntityMode;
import org.hibernate.internal.jaxb.mapping.hbm.JaxbAnyElement;
import org.hibernate.internal.jaxb.mapping.hbm.JaxbArrayElement;
import org.hibernate.internal.jaxb.mapping.hbm.JaxbBagElement;
import org.hibernate.internal.jaxb.mapping.hbm.JaxbComponentElement;
import org.hibernate.internal.jaxb.mapping.hbm.JaxbDynamicComponentElement;
import org.hibernate.internal.jaxb.mapping.hbm.JaxbListElement;
import org.hibernate.internal.jaxb.mapping.hbm.JaxbManyToOneElement;
import org.hibernate.internal.jaxb.mapping.hbm.JaxbMapElement;
import org.hibernate.internal.jaxb.mapping.hbm.JaxbOneToOneElement;
import org.hibernate.internal.jaxb.mapping.hbm.JaxbPrimitiveArrayElement;
import org.hibernate.internal.jaxb.mapping.hbm.JaxbPropertyElement;
import org.hibernate.internal.jaxb.mapping.hbm.JaxbSetElement;
import org.hibernate.internal.jaxb.mapping.hbm.JaxbTuplizerElement;
import org.hibernate.internal.util.StringHelper;
import org.hibernate.mapping.PropertyGeneration;
@ -56,8 +67,41 @@ class ComponentAttributeSourceImpl extends AbstractComponentAttributeSourceImpl
@Override
protected List<AttributeSource> buildAttributeSources() {
List<AttributeSource> attributeSources = new ArrayList<AttributeSource>();
for ( Object attributeElement : componentElement().getPropertyOrManyToOneOrOneToOne() ) {
attributeSources.add( buildAttributeSource( attributeElement ) );
for(final JaxbPropertyElement element : componentElement().getProperty()){
attributeSources.add( buildAttributeSource( element ) );
}
for(final JaxbManyToOneElement element : componentElement().getManyToOne()){
attributeSources.add( buildAttributeSource( element ) );
}
for(final JaxbOneToOneElement element: componentElement().getOneToOne()){
attributeSources.add( buildAttributeSource( element ) );
}
for(final JaxbComponentElement element: componentElement().getComponent()){
attributeSources.add( buildAttributeSource( element ) );
}
for(final JaxbDynamicComponentElement element: componentElement().getDynamicComponent()){
attributeSources.add( buildAttributeSource(element) );
}
for(final JaxbAnyElement element: componentElement().getAny()){
attributeSources.add( buildAttributeSource( element ) );
}
for(final JaxbMapElement element: componentElement().getMap()){
attributeSources.add( buildAttributeSource( element ) );
}
for(final JaxbSetElement element: componentElement().getSet()){
attributeSources.add( buildAttributeSource( element ) );
}
for(final JaxbListElement element: componentElement().getList()){
attributeSources.add( buildAttributeSource( element ) );
}
for(final JaxbBagElement element: componentElement().getBag()){
attributeSources.add( buildAttributeSource( element ) );
}
for(final JaxbArrayElement element: componentElement().getArray()){
attributeSources.add( buildAttributeSource( element ) );
}
for(final JaxbPrimitiveArrayElement element: componentElement().getPrimitiveArray()){
attributeSources.add( buildAttributeSource( element ) );
}
return attributeSources;
}

View File

@ -506,6 +506,11 @@ arbitrary number of queries, and import declarations of arbitrary classes.
<xs:element name="tuplizer" minOccurs="0" maxOccurs="unbounded" type="tuplizer-element"/>
<xs:element name="parent" minOccurs="0" type="parent-element"/>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:annotation>
<xs:appinfo>
<simplify:as-element-property/>
</xs:appinfo>
</xs:annotation>
<xs:element name="property" type="property-element"/>
<xs:element name="many-to-one" type="many-to-one-element"/>
<xs:element name="one-to-one" type="one-to-one-element"/>