org.hibernate.id.Configurable Java Examples
The following examples show how to use
org.hibernate.id.Configurable.
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: ForgotPasswordServlet.java From lams with GNU General Public License v2.0 | 6 votes |
/** * Generates the unique key used for the forgot password request * * @return a unique key * @throws HibernateException * @throws FileUtilException * @throws IOException */ public static String generateUniqueKey() throws HibernateException { Properties props = new Properties(); IdentifierGenerator uuidGen = new UUIDGenerator(); ((Configurable) uuidGen).configure(StringType.INSTANCE, props, null); return ((String) uuidGen.generate(null, null)).toLowerCase(); }
Example #2
Source File: ReactiveIdentifierGeneratorFactory.java From hibernate-reactive with GNU Lesser General Public License v2.1 | 5 votes |
private static IdentifierGenerator augmentWithReactiveGenerator(IdentifierGenerator generator, Type type, Properties params, ServiceRegistryImplementor serviceRegistry) { ReactiveIdentifierGenerator<?> reactiveGenerator; if (generator instanceof SequenceStyleGenerator) { DatabaseStructure structure = ((SequenceStyleGenerator) generator).getDatabaseStructure(); if (structure instanceof TableStructure) { reactiveGenerator = new TableReactiveIdentifierGenerator(true); } else if (structure instanceof SequenceStructure) { reactiveGenerator = new SequenceReactiveIdentifierGenerator(); } else { throw new IllegalStateException("unknown structure type"); } } else if (generator instanceof TableGenerator) { reactiveGenerator = new TableReactiveIdentifierGenerator(false); } else if (generator instanceof SequenceGenerator) { reactiveGenerator = new SequenceReactiveIdentifierGenerator(); } else if (generator instanceof SelectGenerator) { //TODO: this is easy to fix! throw new HibernateException("SelectGenerator is not yet supported in Hibernate Reactive"); } else { //nothing to do return generator; } ((Configurable) reactiveGenerator).configure( type, params, serviceRegistry ); return new ReactiveGeneratorWrapper<>( reactiveGenerator, generator ); }
Example #3
Source File: DefaultIdentifierGeneratorFactory.java From lams with GNU General Public License v2.0 | 5 votes |
@Override public IdentifierGenerator createIdentifierGenerator(String strategy, Type type, Properties config) { try { Class clazz = getIdentifierGeneratorClass( strategy ); IdentifierGenerator identifierGenerator = ( IdentifierGenerator ) clazz.newInstance(); if ( identifierGenerator instanceof Configurable ) { ( ( Configurable ) identifierGenerator ).configure( type, config, serviceRegistry ); } return identifierGenerator; } catch ( Exception e ) { final String entityName = config.getProperty( IdentifierGenerator.ENTITY_NAME ); throw new MappingException( String.format( "Could not instantiate id generator [entity-name=%s]", entityName ), e ); } }
Example #4
Source File: FileUtil.java From lams with GNU General Public License v2.0 | 5 votes |
public static String generateUniqueContentFolderID() { IdentifierGenerator uuidGen = new UUIDGenerator(); ((Configurable) uuidGen).configure(StringType.INSTANCE, new Properties(), null); // Serializable generate(SharedSessionContractImplementor session, Object object) // lowercase to resolve OS issues return ((String) uuidGen.generate(null, null)).toLowerCase(); }
Example #5
Source File: UniqueIdGenerator.java From unitime with Apache License 2.0 | 5 votes |
public void configure(Type type, Properties params, Dialect d) throws MappingException { if (getGenerator() instanceof Configurable) { if (params.getProperty("schema") == null && sDefaultSchema != null) params.setProperty("schema", sDefaultSchema); if (params.get("identifier_normalizer") == null && sNormalizer != null) params.put("identifier_normalizer", sNormalizer); ((Configurable)getGenerator()).configure(type, params, d); } }