org.hibernate.id.factory.IdentifierGeneratorFactory Java Examples
The following examples show how to use
org.hibernate.id.factory.IdentifierGeneratorFactory.
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: Component.java From lams with GNU General Public License v2.0 | 6 votes |
@Override public IdentifierGenerator createIdentifierGenerator( IdentifierGeneratorFactory identifierGeneratorFactory, Dialect dialect, String defaultCatalog, String defaultSchema, RootClass rootClass) throws MappingException { if ( builtIdentifierGenerator == null ) { builtIdentifierGenerator = buildIdentifierGenerator( identifierGeneratorFactory, dialect, defaultCatalog, defaultSchema, rootClass ); } return builtIdentifierGenerator; }
Example #2
Source File: PrevalidatedQuarkusMetadata.java From quarkus with Apache License 2.0 | 4 votes |
@Override @Deprecated public IdentifierGeneratorFactory getIdentifierGeneratorFactory() { return metadata.getIdentifierGeneratorFactory(); }
Example #3
Source File: KeyValue.java From lams with GNU General Public License v2.0 | 4 votes |
public IdentifierGenerator createIdentifierGenerator( IdentifierGeneratorFactory identifierGeneratorFactory, Dialect dialect, String defaultCatalog, String defaultSchema, RootClass rootClass) throws MappingException;
Example #4
Source File: Component.java From lams with GNU General Public License v2.0 | 4 votes |
private IdentifierGenerator buildIdentifierGenerator( IdentifierGeneratorFactory identifierGeneratorFactory, Dialect dialect, String defaultCatalog, String defaultSchema, RootClass rootClass) throws MappingException { final boolean hasCustomGenerator = ! DEFAULT_ID_GEN_STRATEGY.equals( getIdentifierGeneratorStrategy() ); if ( hasCustomGenerator ) { return super.createIdentifierGenerator( identifierGeneratorFactory, dialect, defaultCatalog, defaultSchema, rootClass ); } final Class entityClass = rootClass.getMappedClass(); final Class attributeDeclarer; // what class is the declarer of the composite pk attributes CompositeNestedGeneratedValueGenerator.GenerationContextLocator locator; // IMPL NOTE : See the javadoc discussion on CompositeNestedGeneratedValueGenerator wrt the // various scenarios for which we need to account here if ( rootClass.getIdentifierMapper() != null ) { // we have the @IdClass / <composite-id mapped="true"/> case attributeDeclarer = resolveComponentClass(); } else if ( rootClass.getIdentifierProperty() != null ) { // we have the "@EmbeddedId" / <composite-id name="idName"/> case attributeDeclarer = resolveComponentClass(); } else { // we have the "straight up" embedded (again the hibernate term) component identifier attributeDeclarer = entityClass; } locator = new StandardGenerationContextLocator( rootClass.getEntityName() ); final CompositeNestedGeneratedValueGenerator generator = new CompositeNestedGeneratedValueGenerator( locator ); Iterator itr = getPropertyIterator(); while ( itr.hasNext() ) { final Property property = (Property) itr.next(); if ( property.getValue().isSimpleValue() ) { final SimpleValue value = (SimpleValue) property.getValue(); if ( DEFAULT_ID_GEN_STRATEGY.equals( value.getIdentifierGeneratorStrategy() ) ) { // skip any 'assigned' generators, they would have been handled by // the StandardGenerationContextLocator continue; } final IdentifierGenerator valueGenerator = value.createIdentifierGenerator( identifierGeneratorFactory, dialect, defaultCatalog, defaultSchema, rootClass ); generator.addGeneratedValuePlan( new ValueGenerationPlan( valueGenerator, injector( property, attributeDeclarer ) ) ); } } return generator; }
Example #5
Source File: SimpleValue.java From lams with GNU General Public License v2.0 | 4 votes |
@Override public IdentifierGenerator createIdentifierGenerator( IdentifierGeneratorFactory identifierGeneratorFactory, Dialect dialect, String defaultCatalog, String defaultSchema, RootClass rootClass) throws MappingException { if ( identifierGenerator != null ) { return identifierGenerator; } Properties params = new Properties(); //if the hibernate-mapping did not specify a schema/catalog, use the defaults //specified by properties - but note that if the schema/catalog were specified //in hibernate-mapping, or as params, they will already be initialized and //will override the values set here (they are in identifierGeneratorProperties) if ( defaultSchema!=null ) { params.setProperty(PersistentIdentifierGenerator.SCHEMA, defaultSchema); } if ( defaultCatalog!=null ) { params.setProperty(PersistentIdentifierGenerator.CATALOG, defaultCatalog); } //pass the entity-name, if not a collection-id if (rootClass!=null) { params.setProperty( IdentifierGenerator.ENTITY_NAME, rootClass.getEntityName() ); params.setProperty( IdentifierGenerator.JPA_ENTITY_NAME, rootClass.getJpaEntityName() ); } //init the table here instead of earlier, so that we can get a quoted table name //TODO: would it be better to simply pass the qualified table name, instead of // splitting it up into schema/catalog/table names String tableName = getTable().getQuotedName(dialect); params.setProperty( PersistentIdentifierGenerator.TABLE, tableName ); //pass the column name (a generated id almost always has a single column) String columnName = ( (Column) getColumnIterator().next() ).getQuotedName(dialect); params.setProperty( PersistentIdentifierGenerator.PK, columnName ); if (rootClass!=null) { StringBuilder tables = new StringBuilder(); Iterator iter = rootClass.getIdentityTables().iterator(); while ( iter.hasNext() ) { Table table= (Table) iter.next(); tables.append( table.getQuotedName(dialect) ); if ( iter.hasNext() ) { tables.append(", "); } } params.setProperty( PersistentIdentifierGenerator.TABLES, tables.toString() ); } else { params.setProperty( PersistentIdentifierGenerator.TABLES, tableName ); } if (identifierGeneratorProperties!=null) { params.putAll(identifierGeneratorProperties); } // TODO : we should pass along all settings once "config lifecycle" is hashed out... final ConfigurationService cs = metadata.getMetadataBuildingOptions().getServiceRegistry() .getService( ConfigurationService.class ); params.put( AvailableSettings.PREFER_POOLED_VALUES_LO, cs.getSetting( AvailableSettings.PREFER_POOLED_VALUES_LO, StandardConverters.BOOLEAN, false ) ); if ( cs.getSettings().get( AvailableSettings.PREFERRED_POOLED_OPTIMIZER ) != null ) { params.put( AvailableSettings.PREFERRED_POOLED_OPTIMIZER, cs.getSettings().get( AvailableSettings.PREFERRED_POOLED_OPTIMIZER ) ); } identifierGeneratorFactory.setDialect( dialect ); identifierGenerator = identifierGeneratorFactory.createIdentifierGenerator( identifierGeneratorStrategy, getType(), params ); return identifierGenerator; }
Example #6
Source File: SimpleValue.java From lams with GNU General Public License v2.0 | 4 votes |
public boolean isIdentityColumn(IdentifierGeneratorFactory identifierGeneratorFactory, Dialect dialect) { identifierGeneratorFactory.setDialect( dialect ); return IdentityGenerator.class.isAssignableFrom(identifierGeneratorFactory.getIdentifierGeneratorClass( identifierGeneratorStrategy )); }
Example #7
Source File: SessionFactoryDelegatingImpl.java From lams with GNU General Public License v2.0 | 4 votes |
@Override public IdentifierGeneratorFactory getIdentifierGeneratorFactory() { return delegate.getIdentifierGeneratorFactory(); }
Example #8
Source File: SessionFactoryImpl.java From lams with GNU General Public License v2.0 | 4 votes |
public IdentifierGeneratorFactory getIdentifierGeneratorFactory() { return null; }
Example #9
Source File: AbstractDelegatingMetadata.java From lams with GNU General Public License v2.0 | 4 votes |
@Override public IdentifierGeneratorFactory getIdentifierGeneratorFactory() { return delegate.getIdentifierGeneratorFactory(); }
Example #10
Source File: InFlightMetadataCollectorImpl.java From lams with GNU General Public License v2.0 | 4 votes |
@Override public IdentifierGeneratorFactory getIdentifierGeneratorFactory() { return identifierGeneratorFactory; }
Example #11
Source File: MetadataImpl.java From lams with GNU General Public License v2.0 | 4 votes |
@Override public IdentifierGeneratorFactory getIdentifierGeneratorFactory() { return identifierGeneratorFactory; }
Example #12
Source File: SessionFactoryWrapper.java From lemon with Apache License 2.0 | 4 votes |
public IdentifierGeneratorFactory getIdentifierGeneratorFactory() { return sessionFactoryImplementor.getIdentifierGeneratorFactory(); }
Example #13
Source File: Mapping.java From lams with GNU General Public License v2.0 | 2 votes |
/** * Allow access to the id generator factory, though this is only needed/allowed from configuration. * * @return Access to the identifier generator factory * * @deprecated temporary solution */ @Deprecated public IdentifierGeneratorFactory getIdentifierGeneratorFactory();
Example #14
Source File: KeyValue.java From lams with GNU General Public License v2.0 | votes |
public boolean isIdentityColumn(IdentifierGeneratorFactory identifierGeneratorFactory, Dialect dialect);