use of org.hibernate.mapping.PersistentClass in project jbosstools-hibernate by jbosstools.
the class ConfigurationFacadeTest method testReadFromJDBC.
@Test
public void testReadFromJDBC() throws Exception {
Connection connection = DriverManager.getConnection("jdbc:h2:mem:test");
Statement statement = connection.createStatement();
statement.execute("CREATE TABLE FOO(id int primary key, bar varchar(255))");
JDBCMetaDataConfiguration jdbcMdCfg = new JDBCMetaDataConfiguration();
jdbcMdCfg.setProperty("hibernate.connection.url", "jdbc:h2:mem:test");
configurationFacade = FACADE_FACTORY.createConfiguration(jdbcMdCfg);
Iterator<?> iterator = jdbcMdCfg.getClassMappings();
Assert.assertFalse(iterator.hasNext());
configurationFacade.readFromJDBC();
iterator = jdbcMdCfg.getClassMappings();
PersistentClass persistentClass = (PersistentClass) iterator.next();
Assert.assertEquals("Foo", persistentClass.getClassName());
statement.execute("DROP TABLE FOO");
connection.close();
}
use of org.hibernate.mapping.PersistentClass in project jbosstools-hibernate by jbosstools.
the class FacadeFactoryTest method testCreatePersistentClass.
@Test
public void testCreatePersistentClass() {
PersistentClass persistentClass = new RootClass(null);
IPersistentClass facade = facadeFactory.createPersistentClass(persistentClass);
Assert.assertSame(persistentClass, ((IFacade) facade).getTarget());
}
use of org.hibernate.mapping.PersistentClass in project jbosstools-hibernate by jbosstools.
the class FacadeFactoryTest method testCreatePersistentClass.
@Test
public void testCreatePersistentClass() {
PersistentClass persistentClass = new RootClass();
IPersistentClass facade = facadeFactory.createPersistentClass(persistentClass);
Assert.assertSame(persistentClass, ((IFacade) facade).getTarget());
}
use of org.hibernate.mapping.PersistentClass in project jbosstools-hibernate by jbosstools.
the class Cfg2HbmToolFacadeTest method testGetPersistentClassTag.
@Test
public void testGetPersistentClassTag() {
PersistentClass target = new RootClass();
IPersistentClass persistentClass = new AbstractPersistentClassFacade(FACADE_FACTORY, target) {
};
Assert.assertEquals("class", cfg2HbmToolFacade.getTag(persistentClass));
}
use of org.hibernate.mapping.PersistentClass in project jbosstools-hibernate by jbosstools.
the class ConfigurationFacadeTest method testAddClass.
@Test
public void testAddClass() {
PersistentClass persistentClass = new RootClass(null);
persistentClass.setEntityName("Foo");
IPersistentClass persistentClassFacade = FACADE_FACTORY.createPersistentClass(persistentClass);
Assert.assertNull(configurationFacade.getClassMapping("Foo"));
configurationFacade = FACADE_FACTORY.createConfiguration(configuration);
configurationFacade.addClass(persistentClassFacade);
Assert.assertEquals(persistentClassFacade, configurationFacade.getClassMapping("Foo"));
}
Aggregations