Search in sources :

Example 1 with Cfg2JavaTool

use of org.hibernate.tool.hbm2x.Cfg2JavaTool in project jbosstools-hibernate by jbosstools.

the class HibernateMappingExporterExtensionTest method setUp.

@Before
public void setUp() throws Exception {
    hibernateMappingExporterExtension = new HibernateMappingExporterExtension(FACADE_FACTORY, null, null);
    Method setTemplateHelperMethod = AbstractExporter.class.getDeclaredMethod("setTemplateHelper", new Class[] { TemplateHelper.class });
    setTemplateHelperMethod.setAccessible(true);
    TemplateHelper templateHelper = new TemplateHelper();
    templateHelper.init(null, new String[0]);
    setTemplateHelperMethod.invoke(hibernateMappingExporterExtension, new Object[] { templateHelper });
    RootClass persistentClass = new RootClass();
    Table rootTable = new Table();
    rootTable.setName("table");
    persistentClass.setTable(rootTable);
    persistentClass.setEntityName("Bar");
    persistentClass.setClassName("foo.Bar");
    pojoClass = new EntityPOJOClass(persistentClass, new Cfg2JavaTool());
    exportPojoDelegate = (IExportPOJODelegate) Proxy.newProxyInstance(HibernateMappingExporterExtension.class.getClassLoader(), new Class[] { IExportPOJODelegate.class }, new TestInvocationHandler());
}
Also used : RootClass(org.hibernate.mapping.RootClass) EntityPOJOClass(org.hibernate.tool.hbm2x.pojo.EntityPOJOClass) Table(org.hibernate.mapping.Table) TemplateHelper(org.hibernate.tool.hbm2x.TemplateHelper) Method(java.lang.reflect.Method) Cfg2JavaTool(org.hibernate.tool.hbm2x.Cfg2JavaTool) Before(org.junit.Before)

Example 2 with Cfg2JavaTool

use of org.hibernate.tool.hbm2x.Cfg2JavaTool in project jbosstools-hibernate by jbosstools.

the class HibernateMappingExporterExtensionTest method setUp.

@Before
public void setUp() throws Exception {
    hibernateMappingExporterExtension = new HibernateMappingExporterExtension(FACADE_FACTORY, null, null);
    Method setTemplateHelperMethod = AbstractExporter.class.getDeclaredMethod("setTemplateHelper", new Class[] { TemplateHelper.class });
    setTemplateHelperMethod.setAccessible(true);
    TemplateHelper templateHelper = new TemplateHelper();
    templateHelper.init(null, new String[0]);
    setTemplateHelperMethod.invoke(hibernateMappingExporterExtension, new Object[] { templateHelper });
    RootClass persistentClass = new RootClass();
    Table rootTable = new Table();
    rootTable.setName("table");
    persistentClass.setTable(rootTable);
    persistentClass.setEntityName("Bar");
    persistentClass.setClassName("foo.Bar");
    pojoClass = new EntityPOJOClass(persistentClass, new Cfg2JavaTool());
    exportPojoDelegate = (IExportPOJODelegate) Proxy.newProxyInstance(HibernateMappingExporterExtension.class.getClassLoader(), new Class[] { IExportPOJODelegate.class }, new TestInvocationHandler());
}
Also used : RootClass(org.hibernate.mapping.RootClass) EntityPOJOClass(org.hibernate.tool.hbm2x.pojo.EntityPOJOClass) Table(org.hibernate.mapping.Table) TemplateHelper(org.hibernate.tool.hbm2x.TemplateHelper) Method(java.lang.reflect.Method) Cfg2JavaTool(org.hibernate.tool.hbm2x.Cfg2JavaTool) Before(org.junit.Before)

Example 3 with Cfg2JavaTool

use of org.hibernate.tool.hbm2x.Cfg2JavaTool in project jbosstools-hibernate by jbosstools.

the class HibernateMappingExporterExtensionTest method setUp.

@Before
public void setUp() throws Exception {
    hibernateMappingExporterExtension = new HibernateMappingExporterExtension(FACADE_FACTORY, null, null);
    Method setTemplateHelperMethod = AbstractExporter.class.getDeclaredMethod("setTemplateHelper", new Class[] { TemplateHelper.class });
    setTemplateHelperMethod.setAccessible(true);
    TemplateHelper templateHelper = new TemplateHelper();
    templateHelper.init(null, new String[0]);
    setTemplateHelperMethod.invoke(hibernateMappingExporterExtension, new Object[] { templateHelper });
    RootClass persistentClass = new RootClass(null);
    Table rootTable = new Table();
    rootTable.setName("table");
    persistentClass.setTable(rootTable);
    persistentClass.setEntityName("Bar");
    persistentClass.setClassName("foo.Bar");
    pojoClass = new EntityPOJOClass(persistentClass, new Cfg2JavaTool());
    exportPojoDelegate = (IExportPOJODelegate) Proxy.newProxyInstance(HibernateMappingExporterExtension.class.getClassLoader(), new Class[] { IExportPOJODelegate.class }, new TestInvocationHandler());
}
Also used : RootClass(org.hibernate.mapping.RootClass) EntityPOJOClass(org.hibernate.tool.hbm2x.pojo.EntityPOJOClass) Table(org.hibernate.mapping.Table) TemplateHelper(org.hibernate.tool.hbm2x.TemplateHelper) Method(java.lang.reflect.Method) Cfg2JavaTool(org.hibernate.tool.hbm2x.Cfg2JavaTool) Before(org.junit.Before)

Example 4 with Cfg2JavaTool

use of org.hibernate.tool.hbm2x.Cfg2JavaTool in project jbosstools-hibernate by jbosstools.

the class HibernateMappingExporterFacadeTest method testExportPOJO.

@Test
public void testExportPOJO() throws Exception {
    RootClass persistentClass = new RootClass(null);
    Table rootTable = new Table();
    rootTable.setName("FOO");
    persistentClass.setTable(rootTable);
    persistentClass.setEntityName("Foo");
    persistentClass.setClassName("Foo");
    IPOJOClass pojoClass = FACADE_FACTORY.createPOJOClass(new EntityPOJOClass(persistentClass, new Cfg2JavaTool()));
    Map<Object, Object> additionalContext = new HashMap<Object, Object>();
    Cfg2HbmTool c2h = new Cfg2HbmTool();
    additionalContext.put("date", new Date().toString());
    additionalContext.put("version", Version.getDefault().toString());
    additionalContext.put("c2h", c2h);
    hibernateMappingExporter.setOutputDirectory(outputDir);
    Method setTemplateHelperMethod = AbstractExporter.class.getDeclaredMethod("setTemplateHelper", new Class[] { TemplateHelper.class });
    setTemplateHelperMethod.setAccessible(true);
    TemplateHelper templateHelper = new TemplateHelper();
    templateHelper.init(null, new String[0]);
    setTemplateHelperMethod.invoke(hibernateMappingExporter, new Object[] { templateHelper });
    final File fooHbmXml = new File(outputDir, "Foo.hbm.xml");
    Assert.assertFalse(fooHbmXml.exists());
    hibernateMappingExporterFacade.exportPOJO(additionalContext, pojoClass);
    Assert.assertTrue(fooHbmXml.exists());
    fooHbmXml.delete();
    outputDir.delete();
}
Also used : RootClass(org.hibernate.mapping.RootClass) Table(org.hibernate.mapping.Table) IPOJOClass(org.jboss.tools.hibernate.runtime.spi.IPOJOClass) HashMap(java.util.HashMap) TemplateHelper(org.hibernate.tool.hbm2x.TemplateHelper) Method(java.lang.reflect.Method) Date(java.util.Date) EntityPOJOClass(org.hibernate.tool.hbm2x.pojo.EntityPOJOClass) Cfg2HbmTool(org.hibernate.tool.hbm2x.Cfg2HbmTool) Cfg2JavaTool(org.hibernate.tool.hbm2x.Cfg2JavaTool) File(java.io.File) Test(org.junit.Test)

Example 5 with Cfg2JavaTool

use of org.hibernate.tool.hbm2x.Cfg2JavaTool in project jbosstools-hibernate by jbosstools.

the class HibernateMappingExporterExtensionTest method setUp.

@Before
public void setUp() throws Exception {
    hibernateMappingExporterExtension = new HibernateMappingExporterExtension(FACADE_FACTORY, null, null);
    Method setTemplateHelperMethod = AbstractExporter.class.getDeclaredMethod("setTemplateHelper", new Class[] { TemplateHelper.class });
    setTemplateHelperMethod.setAccessible(true);
    TemplateHelper templateHelper = new TemplateHelper();
    templateHelper.init(null, new String[0]);
    setTemplateHelperMethod.invoke(hibernateMappingExporterExtension, new Object[] { templateHelper });
    RootClass persistentClass = new RootClass();
    Table rootTable = new Table();
    rootTable.setName("table");
    persistentClass.setTable(rootTable);
    persistentClass.setEntityName("Bar");
    persistentClass.setClassName("foo.Bar");
    pojoClass = new EntityPOJOClass(persistentClass, new Cfg2JavaTool());
    exportPojoDelegate = (IExportPOJODelegate) Proxy.newProxyInstance(HibernateMappingExporterExtension.class.getClassLoader(), new Class[] { IExportPOJODelegate.class }, new TestInvocationHandler());
}
Also used : RootClass(org.hibernate.mapping.RootClass) EntityPOJOClass(org.hibernate.tool.hbm2x.pojo.EntityPOJOClass) Table(org.hibernate.mapping.Table) TemplateHelper(org.hibernate.tool.hbm2x.TemplateHelper) Method(java.lang.reflect.Method) Cfg2JavaTool(org.hibernate.tool.hbm2x.Cfg2JavaTool) Before(org.junit.Before)

Aggregations

Method (java.lang.reflect.Method)16 RootClass (org.hibernate.mapping.RootClass)16 Table (org.hibernate.mapping.Table)16 Cfg2JavaTool (org.hibernate.tool.hbm2x.Cfg2JavaTool)16 TemplateHelper (org.hibernate.tool.hbm2x.TemplateHelper)16 EntityPOJOClass (org.hibernate.tool.hbm2x.pojo.EntityPOJOClass)16 File (java.io.File)8 Date (java.util.Date)8 HashMap (java.util.HashMap)8 Cfg2HbmTool (org.hibernate.tool.hbm2x.Cfg2HbmTool)8 IPOJOClass (org.jboss.tools.hibernate.runtime.spi.IPOJOClass)8 Before (org.junit.Before)8 Test (org.junit.Test)8