-->
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.  [ 3 posts ] 
Author Message
 Post subject: Reverse Engineer Uppercase PostgreSQL DB (jira HBX-1000)
PostPosted: Fri Aug 06, 2010 12:24 pm 
Newbie

Joined: Fri Aug 06, 2010 12:06 pm
Posts: 2
Hi,

First of all I would like to mention that this is my first post in this forum, I hope that this question is posted in the right place. I have tried finding a solution for my problem, but it either doesn't exist, or my limited brain can't manage to figure out how to do it (I strongly hope it is the latter).

We're evaluating the hibernate reverse engineering feature of the JBoss Tools to automatically build ejb entity beans out of a existing PostgreSQL database with around 100 tables.
Our problem is that we can't read tables that contain uppercase letters (see HBX-1000).
The solution/workaround in jira doesn't quite work for us because we don't have the entities/mapping-files yet. Does anybody know of a way to access postgresql uppercase tables? Or does anybody know which files we have to change in hibernate to make this work (PostgreSQLDialect.java)?

Thanks in advance!


Top
 Profile  
 
 Post subject: Re: Reverse Engineer Uppercase PostgreSQL DB (jira HBX-1000)
PostPosted: Tue Aug 10, 2010 3:23 am 
Newbie

Joined: Tue Aug 10, 2010 1:57 am
Posts: 2
I am also looking for using upper case characters in table names Hibernate Tools can't access the table structures any more. Hibernate Configuration shows the tables, but when I want to see the columns, it doesn't show anything. If any one have idea then pleas mention here .

_________________
live casino games


Top
 Profile  
 
 Post subject: Re: Reverse Engineer Uppercase PostgreSQL DB (jira HBX-1000)
PostPosted: Tue Aug 10, 2010 9:27 am 
Newbie

Joined: Fri Aug 06, 2010 12:06 pm
Posts: 2
I found a solutions thats working for us.

You can find this also here:

Those are the steps I took:
First I implemented my own MetaDataDialect:
Code:
package com.example;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.hibernate.cfg.reveng.dialect.JDBCMetaDataDialect;
import org.hibernate.cfg.reveng.dialect.MetaDataDialect;

/**
* A implementation of the {@link MetaDataDialect} for the PostgreSQL Database.
* This is basically a wrapper around {@link JDBCMetaDataDialect} to provide case sensitive
* access to postgresql databases.
*
* @see <a href="http://opensource.atlassian.com/projects/hibernate/browse/HBX-1000">HBX-1000</a>
*/

public class PostgreSQLMetaDialect extends JDBCMetaDataDialect {

   private static final Log log = LogFactory.getLog(PostgreSQLMetaDialect.class);
   
   /*
    * (non-Javadoc)
    * @see org.hibernate.cfg.reveng.dialect.AbstractMetaDataDialect#needQuote(java.lang.String)
    */
   public boolean needQuote(String name) {      
      log.debug("needQuote(" + name +")");
      if(null != name && 0 != name.compareTo(name.toUpperCase())) {
         return true;
      } else {
         return super.needQuote(name);
      }
   }
}


Then I added the following to my hibernate.cfg.xml:

Code:
hibernatetool.metadatadialect=com.example.PostgreSQLMetaDialect


Thats basically it.

Notes:

  • If youre using JBoss Seam Tools you can add the hibernatetool.metadatadialect to the file hibernate-console.properties which is generated with each new seam project.
  • Don't forget to include the com.example.PostgreSQLMetaDialect in your Java Build Path (Properties->Java Build Path).


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

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.