-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Creating a customized JDBCMetaDataDialect
PostPosted: Thu Dec 08, 2016 12:46 pm 
Newbie

Joined: Thu Oct 18, 2012 6:07 pm
Posts: 3
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);
   }
}


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.