Java Code Examples for org.hibernate.mapping.Property#setPropertyAccessorName()
The following examples show how to use
org.hibernate.mapping.Property#setPropertyAccessorName() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: HibernatePropertyParser.java From mPaaS with Apache License 2.0 | 6 votes |
/** * 构造Hibernate的Property */ private Property buildProperty(MetaProperty property, HibernatePropertyFeature feature, PersistentClass pclazz) { Property prop = new Property(); prop.setName(property.getName()); if (property.isDynamic()) { prop.setPropertyAccessorName( DynamicPropertyAccessStrategy.class.getName()); } else { prop.setPropertyAccessorName( ExtendPropertyAccessStrategy.class.getName()); } prop.setValueGenerationStrategy(NoValueGeneration.INSTANCE); prop.setLazy(property.isLazy()); prop.setOptional(property.isNotNull()); return prop; }
Example 2
Source File: BinderHelper.java From lams with GNU General Public License v2.0 | 6 votes |
/** * create a property copy reusing the same value */ public static Property shallowCopy(Property property) { Property clone = new Property(); clone.setCascade( property.getCascade() ); clone.setInsertable( property.isInsertable() ); clone.setLazy( property.isLazy() ); clone.setName( property.getName() ); clone.setNaturalIdentifier( property.isNaturalIdentifier() ); clone.setOptimisticLocked( property.isOptimisticLocked() ); clone.setOptional( property.isOptional() ); clone.setPersistentClass( property.getPersistentClass() ); clone.setPropertyAccessorName( property.getPropertyAccessorName() ); clone.setSelectable( property.isSelectable() ); clone.setUpdateable( property.isUpdateable() ); clone.setValue( property.getValue() ); return clone; }
Example 3
Source File: PropertyBinder.java From lams with GNU General Public License v2.0 | 4 votes |
public Property makeProperty() { validateMake(); LOG.debugf( "Building property %s", name ); Property prop = new Property(); prop.setName( name ); prop.setValue( value ); prop.setLazy( lazy ); prop.setLazyGroup( lazyGroup ); prop.setCascade( cascade ); prop.setPropertyAccessorName( accessType.getType() ); if ( property != null ) { prop.setValueGenerationStrategy( determineValueGenerationStrategy( property ) ); if ( property.isAnnotationPresent( AttributeAccessor.class ) ) { final AttributeAccessor accessor = property.getAnnotation( AttributeAccessor.class ); prop.setPropertyAccessorName( accessor.value() ); } } NaturalId naturalId = property != null ? property.getAnnotation( NaturalId.class ) : null; if ( naturalId != null ) { if ( ! entityBinder.isRootEntity() ) { throw new AnnotationException( "@NaturalId only valid on root entity (or its @MappedSuperclasses)" ); } if ( ! naturalId.mutable() ) { updatable = false; } prop.setNaturalIdentifier( true ); } // HHH-4635 -- needed for dialect-specific property ordering Lob lob = property != null ? property.getAnnotation( Lob.class ) : null; prop.setLob( lob != null ); prop.setInsertable( insertable ); prop.setUpdateable( updatable ); // this is already handled for collections in CollectionBinder... if ( Collection.class.isInstance( value ) ) { prop.setOptimisticLocked( ( (Collection) value ).isOptimisticLocked() ); } else { final OptimisticLock lockAnn = property != null ? property.getAnnotation( OptimisticLock.class ) : null; if ( lockAnn != null ) { //TODO this should go to the core as a mapping validation checking if ( lockAnn.excluded() && ( property.isAnnotationPresent( javax.persistence.Version.class ) || property.isAnnotationPresent( Id.class ) || property.isAnnotationPresent( EmbeddedId.class ) ) ) { throw new AnnotationException( "@OptimisticLock.exclude=true incompatible with @Id, @EmbeddedId and @Version: " + StringHelper.qualify( holder.getPath(), name ) ); } } final boolean isOwnedValue = !isToOneValue( value ) || insertable; // && updatable as well??? final boolean includeInOptimisticLockChecks = ( lockAnn != null ) ? ! lockAnn.excluded() : isOwnedValue; prop.setOptimisticLocked( includeInOptimisticLockChecks ); } LOG.tracev( "Cascading {0} with {1}", name, cascade ); this.mappingProperty = prop; return prop; }
Example 4
Source File: ModelBinder.java From lams with GNU General Public License v2.0 | 4 votes |
private void bindNonAggregatedCompositeEntityIdentifier( MappingDocument mappingDocument, EntityHierarchySourceImpl hierarchySource, RootClass rootEntityDescriptor) { final IdentifierSourceNonAggregatedComposite identifierSource = (IdentifierSourceNonAggregatedComposite) hierarchySource.getIdentifierSource(); final Component cid = new Component( mappingDocument, rootEntityDescriptor ); cid.setKey( true ); rootEntityDescriptor.setIdentifier( cid ); final String idClassName = extractIdClassName( identifierSource ); bindComponent( mappingDocument, hierarchySource.getRoot().getAttributeRoleBase().append( "<id>" ).getFullPath(), identifierSource.getEmbeddableSource(), cid, idClassName, rootEntityDescriptor.getClassName(), null, idClassName == null, false, null ); if ( idClassName != null ) { // we also need to bind the "id mapper". ugh, terrible name. Basically we need to // create a virtual (embedded) composite for the non-aggregated attributes on the entity // itself. final Component mapper = new Component( mappingDocument, rootEntityDescriptor ); bindComponent( mappingDocument, hierarchySource.getRoot().getAttributeRoleBase().append( ID_MAPPER_PATH_PART ).getFullPath(), identifierSource.getEmbeddableSource(), mapper, rootEntityDescriptor.getClassName(), null, null, true, false, null ); rootEntityDescriptor.setIdentifierMapper(mapper); Property property = new Property(); property.setName( PropertyPath.IDENTIFIER_MAPPER_PROPERTY ); property.setUpdateable( false ); property.setInsertable( false ); property.setValue( mapper ); property.setPropertyAccessorName( "embedded" ); rootEntityDescriptor.addProperty( property ); } finishBindingCompositeIdentifier( mappingDocument, rootEntityDescriptor, identifierSource, cid, null ); }
Example 5
Source File: ModelBinder.java From lams with GNU General Public License v2.0 | 4 votes |
private void bindProperty( MappingDocument mappingDocument, AttributeSource propertySource, Property property) { property.setName( propertySource.getName() ); if ( StringHelper.isNotEmpty( propertySource.getXmlNodeName() ) ) { DeprecationLogger.DEPRECATION_LOGGER.logDeprecationOfDomEntityModeSupport(); } property.setPropertyAccessorName( StringHelper.isNotEmpty( propertySource.getPropertyAccessorName() ) ? propertySource.getPropertyAccessorName() : mappingDocument.getMappingDefaults().getImplicitPropertyAccessorName() ); if ( propertySource instanceof CascadeStyleSource ) { final CascadeStyleSource cascadeStyleSource = (CascadeStyleSource) propertySource; property.setCascade( StringHelper.isNotEmpty( cascadeStyleSource.getCascadeStyleName() ) ? cascadeStyleSource.getCascadeStyleName() : mappingDocument.getMappingDefaults().getImplicitCascadeStyleName() ); } property.setOptimisticLocked( propertySource.isIncludedInOptimisticLocking() ); if ( propertySource.isSingular() ) { final SingularAttributeSource singularAttributeSource = (SingularAttributeSource) propertySource; property.setInsertable( singularAttributeSource.isInsertable() ); property.setUpdateable( singularAttributeSource.isUpdatable() ); // NOTE : Property#is refers to whether a property is lazy via bytecode enhancement (not proxies) property.setLazy( singularAttributeSource.isBytecodeLazy() ); final GenerationTiming generationTiming = singularAttributeSource.getGenerationTiming(); if ( generationTiming == GenerationTiming.ALWAYS || generationTiming == GenerationTiming.INSERT ) { // we had generation specified... // HBM only supports "database generated values" property.setValueGenerationStrategy( new GeneratedValueGeneration( generationTiming ) ); // generated properties can *never* be insertable... if ( property.isInsertable() ) { log.debugf( "Property [%s] specified %s generation, setting insertable to false : %s", propertySource.getName(), generationTiming.name(), mappingDocument.getOrigin() ); property.setInsertable( false ); } // properties generated on update can never be updatable... if ( property.isUpdateable() && generationTiming == GenerationTiming.ALWAYS ) { log.debugf( "Property [%s] specified ALWAYS generation, setting updateable to false : %s", propertySource.getName(), mappingDocument.getOrigin() ); property.setUpdateable( false ); } } } property.setMetaAttributes( propertySource.getToolingHintContext().getMetaAttributeMap() ); if ( log.isDebugEnabled() ) { final StringBuilder message = new StringBuilder() .append( "Mapped property: " ) .append( propertySource.getName() ) .append( " -> [" ); final Iterator itr = property.getValue().getColumnIterator(); while ( itr.hasNext() ) { message.append( ( (Selectable) itr.next() ).getText() ); if ( itr.hasNext() ) { message.append( ", " ); } } message.append( "]" ); log.debug( message.toString() ); } }
Example 6
Source File: HbmBinder.java From cacheonix-core with GNU Lesser General Public License v2.1 | 4 votes |
public static void bindCompositeId(Element node, Component component, PersistentClass persistentClass, String propertyName, Mappings mappings, java.util.Map inheritedMetas) throws MappingException { component.setKey( true ); String path = StringHelper.qualify( persistentClass.getEntityName(), propertyName == null ? "id" : propertyName ); bindComponent( node, component, persistentClass.getClassName(), propertyName, path, false, node.attribute( "class" ) == null && propertyName == null, mappings, inheritedMetas, false ); if ( "true".equals( node.attributeValue("mapped") ) ) { if ( propertyName!=null ) { throw new MappingException("cannot combine mapped=\"true\" with specified name"); } Component mapper = new Component(persistentClass); bindComponent( node, mapper, persistentClass.getClassName(), null, path, false, true, mappings, inheritedMetas, true ); persistentClass.setIdentifierMapper(mapper); Property property = new Property(); property.setName("_identifierMapper"); property.setNodeName("id"); property.setUpdateable(false); property.setInsertable(false); property.setValue(mapper); property.setPropertyAccessorName( "embedded" ); persistentClass.addProperty(property); } }