@Test public void testMashallAttributeWithNullGenerationTiming() throws Exception { JaxbHbmHibernateMapping hm = new JaxbHbmHibernateMapping(); JaxbHbmRootEntityType clazz = new JaxbHbmRootEntityType(); JaxbHbmSimpleIdType id = new JaxbHbmSimpleIdType(); JaxbHbmBasicAttributeType att = new JaxbHbmBasicAttributeType(); att.setName( "attributeName" ); clazz.getAttributes().add( att ); clazz.setId( id ); hm.getClazz().add( clazz ); XmlBindingChecker.checkValidGeneration( hm ); }
public EntityHierarchySourceImpl(RootEntitySourceImpl rootEntitySource) { this.rootEntitySource = rootEntitySource; this.rootEntitySource.injectHierarchy( this ); this.identifierSource = interpretIdentifierSource( rootEntitySource ); this.versionAttributeSource = interpretVersionSource( rootEntitySource ); this.discriminatorSource = interpretDiscriminatorSource( rootEntitySource ); this.multiTenancySource = interpretMultiTenancySource( rootEntitySource ); this.caching = Helper.createCaching( entityElement().getCache() ); this.naturalIdCaching = Helper.createNaturalIdCaching( rootEntitySource.jaxbEntityMapping().getNaturalIdCache() ); collectedEntityNames.add( rootEntitySource.getEntityNamingSource().getEntityName() ); }
protected RootEntitySourceImpl( MappingDocument sourceMappingDocument, JaxbHbmRootEntityType entityElement) { super( sourceMappingDocument, entityElement ); this.primaryTable = Helper.createTableSource( sourceMappingDocument(), entityElement, this, entityElement.getRowid(), entityElement.getComment(), entityElement.getCheck() ); afterInstantiation(); }
private JaxbHbmHibernateMapping generateXml(boolean includeEntityMode) throws Exception { JaxbHbmHibernateMapping hm = new JaxbHbmHibernateMapping(); JaxbHbmRootEntityType clazz = new JaxbHbmRootEntityType(); JaxbHbmTuplizerType tuplizer = new JaxbHbmTuplizerType(); tuplizer.setClazz( DynamicMapEntityTuplizer.class.getCanonicalName() ); if ( includeEntityMode ) { tuplizer.setEntityMode( EntityMode.MAP ); } clazz.getTuplizer().add( tuplizer ); JaxbHbmSimpleIdType id = new JaxbHbmSimpleIdType(); clazz.setId( id ); hm.getClazz().add( clazz ); return hm; } }
jaxbHbmManyToOneTypeOptional = mappingDocument.getDocumentRoot().getClazz() .stream() .filter( (JaxbHbmRootEntityType entityType) -> childClass.equals( entityType.getName() ) ) .flatMap( jaxbHbmRootEntityType -> jaxbHbmRootEntityType.getAttributes().stream() ) .filter( attribute -> attribute instanceof JaxbHbmManyToOneType &&
for ( Object attribute : rootEntitySource.jaxbEntityMapping().getCompositeId().getKeyPropertyOrKeyManyToOne() ) { if ( JaxbHbmCompositeKeyBasicAttributeType.class.isInstance( attribute ) ) { attributeSources.add(
private static IdentifierSource interpretIdentifierSource(RootEntitySourceImpl rootEntitySource) { if ( rootEntitySource.jaxbEntityMapping().getId() == null && rootEntitySource.jaxbEntityMapping().getCompositeId() == null ) { throw new MappingException( String.format( if ( rootEntitySource.jaxbEntityMapping().getId() != null ) { return new IdentifierSourceSimpleImpl( rootEntitySource ); if ( StringHelper.isEmpty( rootEntitySource.jaxbEntityMapping().getCompositeId().getName() ) ) { if ( rootEntitySource.jaxbEntityMapping().getCompositeId().isMapped() && StringHelper.isEmpty( rootEntitySource.jaxbEntityMapping().getCompositeId().getClazz() ) ) { throw new MappingException( "mapped composite identifier must name component class to use.", if ( rootEntitySource.jaxbEntityMapping().getCompositeId().isMapped() ) { throw new MappingException( "cannot combine mapped=\"true\" with specified name",
/** * Create an instance of {@link JaxbHbmRootEntityType } * */ public JaxbHbmRootEntityType createJaxbHbmRootEntityType() { return new JaxbHbmRootEntityType(); }
@Override public String getDiscriminatorMatchValue() { return jaxbEntityMapping().getDiscriminatorValue(); }
public IdentifierSourceSimpleImpl(RootEntitySourceImpl rootEntitySource) { final JaxbHbmRootEntityType jaxbEntityMapping = rootEntitySource.jaxbEntityMapping(); this.attribute = new SingularIdentifierAttributeSourceImpl( rootEntitySource.sourceMappingDocument(), rootEntitySource, jaxbEntityMapping.getId() ); this.generatorDefinition = EntityHierarchySourceImpl.interpretGeneratorDefinition( rootEntitySource.sourceMappingDocument(), rootEntitySource.getEntityNamingSource(), rootEntitySource.jaxbEntityMapping().getId().getGenerator() ); this.unsavedValue = jaxbEntityMapping.getId().getUnsavedValue(); this.toolingHintContext = Helper.collectToolingHints( rootEntitySource.getToolingHintContext(), jaxbEntityMapping.getId() ); }
private FilterSource[] buildFilterSources() { //todo for now, i think all EntityElement should support this. if ( JaxbHbmRootEntityType.class.isInstance( jaxbEntityMapping() ) ) { final JaxbHbmRootEntityType jaxbClassElement = (JaxbHbmRootEntityType) jaxbEntityMapping(); final int size = jaxbClassElement.getFilter().size(); if ( size == 0 ) { return NO_FILTER_SOURCES; } FilterSource[] results = new FilterSource[size]; for ( int i = 0; i < size; i++ ) { JaxbHbmFilterType element = jaxbClassElement.getFilter().get( i ); results[i] = new FilterSourceImpl( sourceMappingDocument(), element ); } return results; } else { return NO_FILTER_SOURCES; } }
private static DiscriminatorSource interpretDiscriminatorSource(final RootEntitySourceImpl rootEntitySource) { final JaxbHbmEntityDiscriminatorType jaxbDiscriminatorMapping = rootEntitySource.jaxbEntityMapping().getDiscriminator();
jaxbHbmManyToOneTypeOptional = mappingDocument.getDocumentRoot().getClazz() .stream() .filter( (JaxbHbmRootEntityType entityType) -> childClass.equals( entityType.getName() ) ) .flatMap( jaxbHbmRootEntityType -> jaxbHbmRootEntityType.getAttributes().stream() ) .filter( attribute -> attribute instanceof JaxbHbmManyToOneType &&
public IdentifierSourceAggregatedCompositeImpl(final RootEntitySourceImpl rootEntitySource) { final EmbeddedAttributeMappingAdapterAggregatedCompositeId compositeIdAdapter = new EmbeddedAttributeMappingAdapterAggregatedCompositeId( rootEntitySource ); this.attributeSource = new SingularAttributeSourceAggregatedCompositeIdentifierImpl( rootEntitySource.sourceMappingDocument(), compositeIdAdapter ); this.generatorDefinition = EntityHierarchySourceImpl.interpretGeneratorDefinition( rootEntitySource.sourceMappingDocument(), rootEntitySource.getEntityNamingSource(), rootEntitySource.jaxbEntityMapping().getCompositeId().getGenerator() ); this.toolingHintContext = Helper.collectToolingHints( rootEntitySource.getToolingHintContext(), rootEntitySource.jaxbEntityMapping().getCompositeId() ); }
private static IdentifierSource interpretIdentifierSource(RootEntitySourceImpl rootEntitySource) { if ( rootEntitySource.jaxbEntityMapping().getId() == null && rootEntitySource.jaxbEntityMapping().getCompositeId() == null ) { throw new MappingException( String.format( if ( rootEntitySource.jaxbEntityMapping().getId() != null ) { return new IdentifierSourceSimpleImpl( rootEntitySource ); if ( StringHelper.isEmpty( rootEntitySource.jaxbEntityMapping().getCompositeId().getName() ) ) { if ( rootEntitySource.jaxbEntityMapping().getCompositeId().isMapped() && StringHelper.isEmpty( rootEntitySource.jaxbEntityMapping().getCompositeId().getClazz() ) ) { throw new MappingException( "mapped composite identifier must name component class to use.", if ( rootEntitySource.jaxbEntityMapping().getCompositeId().isMapped() ) { throw new MappingException( "cannot combine mapped=\"true\" with specified name",
/** * Create an instance of {@link JaxbHbmRootEntityType } * */ public JaxbHbmRootEntityType createJaxbHbmRootEntityType() { return new JaxbHbmRootEntityType(); }
@Override public String getDiscriminatorMatchValue() { return jaxbEntityMapping().getDiscriminatorValue(); }
public IdentifierSourceSimpleImpl(RootEntitySourceImpl rootEntitySource) { final JaxbHbmRootEntityType jaxbEntityMapping = rootEntitySource.jaxbEntityMapping(); this.attribute = new SingularIdentifierAttributeSourceImpl( rootEntitySource.sourceMappingDocument(), rootEntitySource, jaxbEntityMapping.getId() ); this.generatorDefinition = EntityHierarchySourceImpl.interpretGeneratorDefinition( rootEntitySource.sourceMappingDocument(), rootEntitySource.getEntityNamingSource(), rootEntitySource.jaxbEntityMapping().getId().getGenerator() ); this.unsavedValue = jaxbEntityMapping.getId().getUnsavedValue(); this.toolingHintContext = Helper.collectToolingHints( rootEntitySource.getToolingHintContext(), jaxbEntityMapping.getId() ); }
private FilterSource[] buildFilterSources() { //todo for now, i think all EntityElement should support this. if ( JaxbHbmRootEntityType.class.isInstance( jaxbEntityMapping() ) ) { final JaxbHbmRootEntityType jaxbClassElement = (JaxbHbmRootEntityType) jaxbEntityMapping(); final int size = jaxbClassElement.getFilter().size(); if ( size == 0 ) { return NO_FILTER_SOURCES; } FilterSource[] results = new FilterSource[size]; for ( int i = 0; i < size; i++ ) { JaxbHbmFilterType element = jaxbClassElement.getFilter().get( i ); results[i] = new FilterSourceImpl( sourceMappingDocument(), element ); } return results; } else { return NO_FILTER_SOURCES; } }
private static DiscriminatorSource interpretDiscriminatorSource(final RootEntitySourceImpl rootEntitySource) { final JaxbHbmEntityDiscriminatorType jaxbDiscriminatorMapping = rootEntitySource.jaxbEntityMapping().getDiscriminator();