下面列出了怎么用org.hibernate.id.SelectGenerator的API类实例代码及写法,或者点击链接到github查看源代码。
/**
* Constructs a new DefaultIdentifierGeneratorFactory.
*/
@SuppressWarnings("deprecation")
public DefaultIdentifierGeneratorFactory() {
register( "uuid2", UUIDGenerator.class );
register( "guid", GUIDGenerator.class ); // can be done with UUIDGenerator + strategy
register( "uuid", UUIDHexGenerator.class ); // "deprecated" for new use
register( "uuid.hex", UUIDHexGenerator.class ); // uuid.hex is deprecated
register( "assigned", Assigned.class );
register( "identity", IdentityGenerator.class );
register( "select", SelectGenerator.class );
register( "sequence", SequenceStyleGenerator.class );
register( "seqhilo", SequenceHiLoGenerator.class );
register( "increment", IncrementGenerator.class );
register( "foreign", ForeignGenerator.class );
register( "sequence-identity", SequenceIdentityGenerator.class );
register( "enhanced-sequence", SequenceStyleGenerator.class );
register( "enhanced-table", TableGenerator.class );
}
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 );
}