use of org.hibernate.boot.internal.BootstrapContextImpl in project jbosstools-hibernate by jbosstools.
the class EntityMetamodelFacadeTest method createFooBarModel.
private EntityMetamodel createFooBarModel() {
StandardServiceRegistryBuilder builder = new StandardServiceRegistryBuilder();
builder.applySetting(AvailableSettings.DIALECT, MockDialect.class.getName());
builder.applySetting(AvailableSettings.CONNECTION_PROVIDER, MockConnectionProvider.class.getName());
StandardServiceRegistry serviceRegistry = builder.build();
MetadataBuildingOptionsImpl metadataBuildingOptions = new MetadataBuildingOptionsImpl(serviceRegistry);
BootstrapContextImpl bootstrapContext = new BootstrapContextImpl(serviceRegistry, metadataBuildingOptions);
metadataBuildingOptions.setBootstrapContext(bootstrapContext);
InFlightMetadataCollector inFlightMetadataCollector = new InFlightMetadataCollectorImpl(bootstrapContext, metadataBuildingOptions);
MetadataBuildingContext metadataBuildingContext = new MetadataBuildingContextRootImpl(bootstrapContext, metadataBuildingOptions, inFlightMetadataCollector);
PersistentClass persistentClass = createPersistentClass(metadataBuildingContext);
MetadataSources metadataSources = new MetadataSources(serviceRegistry);
SessionFactoryImplementor sessionFactoryImplementor = (SessionFactoryImplementor) metadataSources.buildMetadata().buildSessionFactory();
return new EntityMetamodel(persistentClass, null, sessionFactoryImplementor) {
private static final long serialVersionUID = 1L;
@Override
public EntityTuplizer getTuplizer() {
return (EntityTuplizer) Proxy.newProxyInstance(FACADE_FACTORY.getClassLoader(), new Class[] { EntityTuplizer.class }, new TestInvocationHandler());
}
@Override
public Integer getPropertyIndexOrNull(String id) {
methodName = "getPropertyIndexOrNull";
arguments = new Object[] { id };
return INDEX;
}
};
}
use of org.hibernate.boot.internal.BootstrapContextImpl in project jbosstools-hibernate by jbosstools.
the class ColumnFacadeTest method createMetadataBuildingContext.
private MetadataBuildingContext createMetadataBuildingContext() {
StandardServiceRegistryBuilder builder = new StandardServiceRegistryBuilder();
builder.applySetting(AvailableSettings.DIALECT, MockDialect.class.getName());
builder.applySetting(AvailableSettings.CONNECTION_PROVIDER, MockConnectionProvider.class.getName());
StandardServiceRegistry serviceRegistry = builder.build();
MetadataBuildingOptionsImpl metadataBuildingOptions = new MetadataBuildingOptionsImpl(serviceRegistry);
BootstrapContextImpl bootstrapContext = new BootstrapContextImpl(serviceRegistry, metadataBuildingOptions);
metadataBuildingOptions.setBootstrapContext(bootstrapContext);
InFlightMetadataCollector inFlightMetadataCollector = new InFlightMetadataCollectorImpl(bootstrapContext, metadataBuildingOptions);
return new MetadataBuildingContextRootImpl(bootstrapContext, metadataBuildingOptions, inFlightMetadataCollector);
}
use of org.hibernate.boot.internal.BootstrapContextImpl in project jbosstools-hibernate by jbosstools.
the class FacadeFactoryTest method testCreateHQLQueryPlan.
@Test
public void testCreateHQLQueryPlan() {
final Collection<PersistentClass> entityBindings = new ArrayList<PersistentClass>();
final StandardServiceRegistryBuilder standardServiceRegistryBuilder = new StandardServiceRegistryBuilder();
standardServiceRegistryBuilder.applySetting(AvailableSettings.DIALECT, MockDialect.class.getName());
standardServiceRegistryBuilder.applySetting(AvailableSettings.CONNECTION_PROVIDER, MockConnectionProvider.class.getName());
final StandardServiceRegistry serviceRegistry = standardServiceRegistryBuilder.build();
final MetadataSources metadataSources = new MetadataSources(serviceRegistry);
final MetadataImplementor metadata = (MetadataImplementor) metadataSources.buildMetadata();
Table t = new Table("FOO");
Column c = new Column("foo");
t.addColumn(c);
PrimaryKey key = new PrimaryKey(t);
key.addColumn(c);
t.setPrimaryKey(key);
@SuppressWarnings("deprecation") SimpleValue sv = new SimpleValue(metadata);
sv.setNullValue("null");
sv.setTypeName(Integer.class.getName());
sv.setTable(t);
sv.addColumn(c);
final RootClass rc = new RootClass(null);
rc.setEntityName("foo");
rc.setJpaEntityName("foo");
rc.setIdentifier(sv);
rc.setTable(t);
rc.setOptimisticLockStyle(OptimisticLockStyle.NONE);
entityBindings.add(rc);
MetadataImplementor wrapper = (MetadataImplementor) Proxy.newProxyInstance(facadeFactory.getClassLoader(), new Class[] { MetadataImplementor.class }, new InvocationHandler() {
@Override
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
if ("getEntityBinding".equals(method.getName()) && args != null && args.length == 1 && "foo".equals(args[0])) {
return rc;
} else if ("getEntityBindings".equals(method.getName())) {
return entityBindings;
}
return method.invoke(metadata, args);
}
});
MetadataBuildingOptions mbo = new MetadataBuilderImpl.MetadataBuildingOptionsImpl(serviceRegistry);
BootstrapContext bc = new BootstrapContextImpl(serviceRegistry, mbo);
SessionFactoryImpl sfi = new SessionFactoryImpl(wrapper, new SessionFactoryOptionsBuilder(serviceRegistry, bc), HQLQueryPlan::new);
Map<String, Filter> filters = Collections.emptyMap();
HQLQueryPlan hqlQueryPlan = new HQLQueryPlan("from foo", false, filters, sfi);
IHQLQueryPlan facade = facadeFactory.createHQLQueryPlan(hqlQueryPlan);
assertSame(hqlQueryPlan, ((IFacade) facade).getTarget());
}
use of org.hibernate.boot.internal.BootstrapContextImpl in project jbosstools-hibernate by jbosstools.
the class EntityMetamodelFacadeTest method createFooBarModel.
private EntityMetamodel createFooBarModel() {
StandardServiceRegistryBuilder builder = new StandardServiceRegistryBuilder();
builder.applySetting(AvailableSettings.DIALECT, MockDialect.class.getName());
builder.applySetting(AvailableSettings.CONNECTION_PROVIDER, MockConnectionProvider.class.getName());
StandardServiceRegistry serviceRegistry = builder.build();
MetadataBuildingOptionsImpl metadataBuildingOptions = new MetadataBuildingOptionsImpl(serviceRegistry);
BootstrapContextImpl bootstrapContext = new BootstrapContextImpl(serviceRegistry, metadataBuildingOptions);
metadataBuildingOptions.setBootstrapContext(bootstrapContext);
InFlightMetadataCollector inFlightMetadataCollector = new InFlightMetadataCollectorImpl(bootstrapContext, metadataBuildingOptions);
MetadataBuildingContext metadataBuildingContext = new MetadataBuildingContextRootImpl(bootstrapContext, metadataBuildingOptions, inFlightMetadataCollector);
PersisterCreationContext persisterCreationContext = createPersisterCreationContext(serviceRegistry, bootstrapContext);
PersistentClass persistentClass = createPersistentClass(metadataBuildingContext);
return new EntityMetamodel(persistentClass, null, persisterCreationContext) {
private static final long serialVersionUID = 1L;
@Override
public EntityTuplizer getTuplizer() {
return (EntityTuplizer) Proxy.newProxyInstance(FACADE_FACTORY.getClassLoader(), new Class[] { EntityTuplizer.class }, new TestInvocationHandler());
}
@Override
public Integer getPropertyIndexOrNull(String id) {
methodName = "getPropertyIndexOrNull";
arguments = new Object[] { id };
return INDEX;
}
};
}
use of org.hibernate.boot.internal.BootstrapContextImpl in project jbosstools-hibernate by jbosstools.
the class ClassMetadataFacadeTest method setupFooBarPersister.
private ClassMetadata setupFooBarPersister() {
StandardServiceRegistryBuilder builder = new StandardServiceRegistryBuilder();
builder.applySetting(AvailableSettings.DIALECT, MockDialect.class.getName());
builder.applySetting(AvailableSettings.CONNECTION_PROVIDER, MockConnectionProvider.class.getName());
StandardServiceRegistry serviceRegistry = builder.build();
MetadataBuildingOptionsImpl metadataBuildingOptions = new MetadataBuildingOptionsImpl(serviceRegistry);
BootstrapContextImpl bootstrapContext = new BootstrapContextImpl(serviceRegistry, metadataBuildingOptions);
metadataBuildingOptions.setBootstrapContext(bootstrapContext);
InFlightMetadataCollector inFlightMetadataCollector = new InFlightMetadataCollectorImpl(bootstrapContext, metadataBuildingOptions);
MetadataBuildingContext metadataBuildingContext = new MetadataBuildingContextRootImpl("JBoss Tools", bootstrapContext, metadataBuildingOptions, inFlightMetadataCollector);
AbstractEntityPersister result = new TestEntityPersister(createPersistentClass(metadataBuildingContext), createPersisterCreationContext(serviceRegistry, bootstrapContext));
return result;
}
Aggregations