Search in sources :

Example 46 with IConfiguration

use of org.jboss.tools.hibernate.runtime.spi.IConfiguration in project jbosstools-hibernate by jbosstools.

the class ServiceImplTest method testNewHQLQueryPlan.

@Test
public void testNewHQLQueryPlan() throws Exception {
    IConfiguration configuration = service.newDefaultConfiguration();
    File testFile = File.createTempFile("test", "tmp");
    testFile.deleteOnExit();
    FileWriter fileWriter = new FileWriter(testFile);
    fileWriter.write(TEST_HBM_STRING);
    fileWriter.close();
    configuration.addFile(testFile);
    ISessionFactory sfi = configuration.buildSessionFactory();
    IHQLQueryPlan queryPlan = service.newHQLQueryPlan("from ServiceImplTest$Foo", true, sfi);
    Assert.assertNotNull(queryPlan);
    Object target = ((IFacade) queryPlan).getTarget();
    Assert.assertNotNull(target);
    Assert.assertTrue(target instanceof HQLQueryPlan);
}
Also used : HQLQueryPlan(org.hibernate.engine.query.spi.HQLQueryPlan) IHQLQueryPlan(org.jboss.tools.hibernate.runtime.spi.IHQLQueryPlan) FileWriter(java.io.FileWriter) ISessionFactory(org.jboss.tools.hibernate.runtime.spi.ISessionFactory) IConfiguration(org.jboss.tools.hibernate.runtime.spi.IConfiguration) IHQLQueryPlan(org.jboss.tools.hibernate.runtime.spi.IHQLQueryPlan) IFacade(org.jboss.tools.hibernate.runtime.common.IFacade) File(java.io.File) Test(org.junit.Test)

Example 47 with IConfiguration

use of org.jboss.tools.hibernate.runtime.spi.IConfiguration in project jbosstools-hibernate by jbosstools.

the class SchemaExportFacadeTest method testCreate.

@Test
public void testCreate() throws Exception {
    String urlString = "jdbc:h2:mem:create_test";
    Connection connection = DriverManager.getConnection(urlString);
    configuration.setProperty(Environment.URL, urlString);
    IConfiguration configurationFacade = FACADE_FACTORY.createConfiguration(configuration);
    SchemaExport schemaExport = new SchemaExport();
    SchemaExportFacadeImpl schemaExportFacade = new SchemaExportFacadeImpl(FACADE_FACTORY, schemaExport);
    schemaExportFacade.setConfiguration(configurationFacade);
    Assert.assertFalse(connection.getMetaData().getTables(null, null, "FOO", null).next());
    schemaExportFacade.create();
    Assert.assertTrue(connection.getMetaData().getTables(null, null, "FOO", null).next());
}
Also used : Connection(java.sql.Connection) IConfiguration(org.jboss.tools.hibernate.runtime.spi.IConfiguration) ISchemaExport(org.jboss.tools.hibernate.runtime.spi.ISchemaExport) SchemaExport(org.hibernate.tool.hbm2ddl.SchemaExport) Test(org.junit.Test)

Example 48 with IConfiguration

use of org.jboss.tools.hibernate.runtime.spi.IConfiguration in project jbosstools-hibernate by jbosstools.

the class ServiceImplTest method testNewHQLQueryPlan.

@Test
public void testNewHQLQueryPlan() throws Exception {
    IConfiguration configuration = service.newDefaultConfiguration();
    configuration.setProperty("hibernate.dialect", "org.hibernate.dialect.H2Dialect");
    File testFile = File.createTempFile("test", "tmp");
    testFile.deleteOnExit();
    FileWriter fileWriter = new FileWriter(testFile);
    fileWriter.write(TEST_HBM_STRING);
    fileWriter.close();
    configuration.addFile(testFile);
    ISessionFactory sfi = configuration.buildSessionFactory();
    IHQLQueryPlan queryPlan = service.newHQLQueryPlan("from ServiceImplTest$Foo", true, sfi);
    Assert.assertNotNull(queryPlan);
    Object target = ((IFacade) queryPlan).getTarget();
    Assert.assertNotNull(target);
    Assert.assertTrue(target instanceof HQLQueryPlan);
}
Also used : HQLQueryPlan(org.hibernate.engine.query.spi.HQLQueryPlan) IHQLQueryPlan(org.jboss.tools.hibernate.runtime.spi.IHQLQueryPlan) FileWriter(java.io.FileWriter) ISessionFactory(org.jboss.tools.hibernate.runtime.spi.ISessionFactory) IConfiguration(org.jboss.tools.hibernate.runtime.spi.IConfiguration) IHQLQueryPlan(org.jboss.tools.hibernate.runtime.spi.IHQLQueryPlan) IFacade(org.jboss.tools.hibernate.runtime.common.IFacade) File(java.io.File) Test(org.junit.Test)

Example 49 with IConfiguration

use of org.jboss.tools.hibernate.runtime.spi.IConfiguration in project jbosstools-hibernate by jbosstools.

the class ServiceImplTest method testNewAnnotationConfiguration.

@Test
public void testNewAnnotationConfiguration() {
    IConfiguration configuration = service.newAnnotationConfiguration();
    Assert.assertNotNull(configuration);
    Object target = ((IFacade) configuration).getTarget();
    Assert.assertNotNull(target);
    Assert.assertTrue(target instanceof Configuration);
}
Also used : Configuration(org.hibernate.cfg.Configuration) JDBCMetaDataConfiguration(org.hibernate.cfg.JDBCMetaDataConfiguration) IConfiguration(org.jboss.tools.hibernate.runtime.spi.IConfiguration) IConfiguration(org.jboss.tools.hibernate.runtime.spi.IConfiguration) IFacade(org.jboss.tools.hibernate.runtime.common.IFacade) Test(org.junit.Test)

Example 50 with IConfiguration

use of org.jboss.tools.hibernate.runtime.spi.IConfiguration in project jbosstools-hibernate by jbosstools.

the class ServiceImplTest method testNewJpaConfiguration.

@Test
public void testNewJpaConfiguration() {
    IConfiguration configuration = service.newJpaConfiguration(null, "test", null);
    Assert.assertNotNull(configuration);
    Object target = ((IFacade) configuration).getTarget();
    Assert.assertNotNull(target);
    Assert.assertTrue(target instanceof Configuration);
}
Also used : Configuration(org.hibernate.cfg.Configuration) JDBCMetaDataConfiguration(org.hibernate.cfg.JDBCMetaDataConfiguration) IConfiguration(org.jboss.tools.hibernate.runtime.spi.IConfiguration) IConfiguration(org.jboss.tools.hibernate.runtime.spi.IConfiguration) IFacade(org.jboss.tools.hibernate.runtime.common.IFacade) Test(org.junit.Test)

Aggregations

IConfiguration (org.jboss.tools.hibernate.runtime.spi.IConfiguration)137 Test (org.junit.Test)72 Configuration (org.hibernate.cfg.Configuration)65 IFacade (org.jboss.tools.hibernate.runtime.common.IFacade)29 JDBCMetaDataConfiguration (org.hibernate.cfg.JDBCMetaDataConfiguration)25 File (java.io.File)19 ConsoleConfiguration (org.hibernate.console.ConsoleConfiguration)17 IPersistentClass (org.jboss.tools.hibernate.runtime.spi.IPersistentClass)16 Properties (java.util.Properties)13 CoreException (org.eclipse.core.runtime.CoreException)10 IReverseEngineeringStrategy (org.jboss.tools.hibernate.runtime.spi.IReverseEngineeringStrategy)10 IJDBCReader (org.jboss.tools.hibernate.runtime.spi.IJDBCReader)9 FileWriter (java.io.FileWriter)8 IOException (java.io.IOException)8 JDBCReader (org.hibernate.cfg.reveng.JDBCReader)8 SimpleValue (org.hibernate.mapping.SimpleValue)8 IProperty (org.jboss.tools.hibernate.runtime.spi.IProperty)8 JavaModelException (org.eclipse.jdt.core.JavaModelException)7 PartInitException (org.eclipse.ui.PartInitException)7 Ejb3Configuration (org.hibernate.ejb.Ejb3Configuration)7