Java Code Examples for org.hibernate.mapping.RootClass#setEmbeddedIdentifier()
The following examples show how to use
org.hibernate.mapping.RootClass#setEmbeddedIdentifier() .
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: ModelBinder.java From lams with GNU General Public License v2.0 | 5 votes |
private void finishBindingCompositeIdentifier( MappingDocument sourceDocument, RootClass rootEntityDescriptor, CompositeIdentifierSource identifierSource, Component cid, String propertyName) { if ( propertyName == null ) { rootEntityDescriptor.setEmbeddedIdentifier( cid.isEmbedded() ); if ( cid.isEmbedded() ) { // todo : what is the implication of this? cid.setDynamic( !rootEntityDescriptor.hasPojoRepresentation() ); /* * Property prop = new Property(); prop.setName("id"); * prop.setPropertyAccessorName("embedded"); prop.setValue(id); * entity.setIdentifierProperty(prop); */ } } else { Property prop = new Property(); prop.setValue( cid ); bindProperty( sourceDocument, ( (IdentifierSourceAggregatedComposite) identifierSource ).getIdentifierAttributeSource(), prop ); rootEntityDescriptor.setIdentifierProperty( prop ); rootEntityDescriptor.setDeclaredIdentifierProperty( prop ); } makeIdentifier( sourceDocument, identifierSource.getIdentifierGeneratorDescriptor(), null, cid ); }
Example 2
Source File: HbmBinder.java From cacheonix-core with GNU Lesser General Public License v2.1 | 5 votes |
private static void bindCompositeId(Element idNode, RootClass entity, Mappings mappings, java.util.Map inheritedMetas) throws MappingException { String propertyName = idNode.attributeValue( "name" ); Component id = new Component( entity ); entity.setIdentifier( id ); bindCompositeId( idNode, id, entity, propertyName, mappings, inheritedMetas ); if ( propertyName == null ) { entity.setEmbeddedIdentifier( id.isEmbedded() ); if ( id.isEmbedded() ) { // todo : what is the implication of this? id.setDynamic( !entity.hasPojoRepresentation() ); /* * Property prop = new Property(); prop.setName("id"); * prop.setPropertyAccessorName("embedded"); prop.setValue(id); * entity.setIdentifierProperty(prop); */ } } else { Property prop = new Property(); prop.setValue( id ); bindProperty( idNode, prop, mappings, inheritedMetas ); entity.setIdentifierProperty( prop ); } makeIdentifier( idNode, id, mappings ); }
Example 3
Source File: PropertyBinder.java From lams with GNU General Public License v2.0 | 4 votes |
private Property bind(Property prop) { if (isId) { final RootClass rootClass = ( RootClass ) holder.getPersistentClass(); //if an xToMany, it as to be wrapped today. //FIXME this pose a problem as the PK is the class instead of the associated class which is not really compliant with the spec if ( isXToMany || entityBinder.wrapIdsInEmbeddedComponents() ) { Component identifier = (Component) rootClass.getIdentifier(); if (identifier == null) { identifier = AnnotationBinder.createComponent( holder, new PropertyPreloadedData(null, null, null), true, false, buildingContext ); rootClass.setIdentifier( identifier ); identifier.setNullValue( "undefined" ); rootClass.setEmbeddedIdentifier( true ); rootClass.setIdentifierMapper( identifier ); } //FIXME is it good enough? identifier.addProperty( prop ); } else { rootClass.setIdentifier( ( KeyValue ) getValue() ); if (embedded) { rootClass.setEmbeddedIdentifier( true ); } else { rootClass.setIdentifierProperty( prop ); final org.hibernate.mapping.MappedSuperclass superclass = BinderHelper.getMappedSuperclassOrNull( declaringClass, inheritanceStatePerClass, buildingContext ); if (superclass != null) { superclass.setDeclaredIdentifierProperty(prop); } else { //we know the property is on the actual entity rootClass.setDeclaredIdentifierProperty( prop ); } } } } else { holder.addProperty( prop, columns, declaringClass ); } return prop; }