I am working in Eclipse, using HibernateTools 4.0.0.
I am trying to create a custom JDBCMetaDataDialect that extracts CHECK CONSTRAINTS info from a Firebird database.
Two questions:
1) Where do I set
hibernatetool.metadatadialect so that I can use my custom class during the reverse engineering process?
2) The code below will help me validate that things are setup properly before I begin making an customizations.
It fails to run because of the following exception:
Quote:
11:38:03 [main] DEBUG org.jboss.logging: Logging Provider: org.jboss.logging.Log4jLoggerProvider
11:38:04 [main] INFO hibernate.cfg.Environment: HHH000205: Loaded properties from resource hibernate.properties: {hibernate.connection.username=SYSDBA, hibernate.connection.password=****, hibernate.connection.charSet=utf8, hibernate.dialect=org.hibernate.dialect.FirebirdDialect, hibernate.connection.url=jdbc:firebirdsql:localhost:C:/MyDB.FDB, hibernate.bytecode.use_reflection_optimizer=false, hibernate.connection.driver_class=org.firebirdsql.jdbc.FBDriver, hibernate.current_session_context_class=org.hibernate.context.internal.ThreadLocalSessionContext}
11:38:04 [main] INFO hibernate.cfg.Environment: HHH000021: Bytecode provider name : javassist
11:38:04 [main] INFO hibernate.cfg.Configuration: HHH000043: Configuring from resource: /hibernate.cfg.xml
11:38:04 [main] INFO hibernate.cfg.Configuration: HHH000040: Configuration resource: /hibernate.cfg.xml
11:38:04 [main] INFO hibernate.cfg.Configuration: HHH000041: Configured SessionFactory: null
Exception in thread "main" java.lang.NullPointerException
at org.hibernate.cfg.reveng.dialect.AbstractMetaDataDialect.getConnection(AbstractMetaDataDialect.java:121)
at org.hibernate.cfg.reveng.dialect.AbstractMetaDataDialect.getMetaData(AbstractMetaDataDialect.java:60)
at org.hibernate.cfg.reveng.dialect.AbstractMetaDataDialect.caseForSearch(AbstractMetaDataDialect.java:163)
at org.hibernate.cfg.reveng.dialect.JDBCMetaDataDialect.getColumns(JDBCMetaDataDialect.java:94)
at com.ttinc.db.FirebirdMetaDataDialect.getColumns(FirebirdMetaDataDialect.java:15)
at com.ttinc.db.FirebirdMetaDataDialect.main(FirebirdMetaDataDialect.java:60)
Here's my code:
Code:
package com.foo.db;
import java.util.Iterator;
import org.hibernate.cfg.Configuration;
import org.hibernate.cfg.Settings;
import org.hibernate.cfg.reveng.dialect.JDBCMetaDataDialect;
import org.hibernate.service.ServiceRegistry;
import org.hibernate.service.ServiceRegistryBuilder;
public class FirebirdMetaDataDialect extends JDBCMetaDataDialect
{
@Override
public Iterator getColumns(final String xcatalog, final String xschema, final String xtable, String xcolumn)
{
return super.getColumns(xcatalog, xschema, xtable, xcolumn);
}
@SuppressWarnings("javadoc")
public static void main(String[] args)
{
FirebirdMetaDataDialect firebirdMetaDataDialect = new FirebirdMetaDataDialect();
ServiceRegistryBuilder serviceRegistryBuilder = new ServiceRegistryBuilder();
Configuration cfg = new Configuration().configure();
ServiceRegistry serviceRegistry = serviceRegistryBuilder.applySettings(cfg.getProperties()).buildServiceRegistry();
Settings settings = cfg.buildSettings(serviceRegistry);
String catalog = settings.getDefaultCatalogName();
String schema = settings.getDefaultSchemaName();
String table = "MyTable";
String column = "MyColumn";
firebirdMetaDataDialect.getColumns(catalog, schema, table, column);
}
}