Hello,
  I try integrate any database explorer and hibernate tools
I want, for example, that choose object (table,views ) from explorer
and call hibernate reverse engineering  wizard.
I use sqlexplorer (patched), but I will try webtools when M4 be out (April 22)

I have any request from tools 

1) I need new method (or replace current) in JDBCFilter :

boolean acceptTableName(String catalogName,String schemaName,String tableName);

and call to this method when/except call acceptTableName(String name)

I export extension point in sqlexplorer and define popupMenu like this 
(I add in org.hibernate.eclipse.console plugin;TableNode class is from 
sqlexplorer)
...
 <extension
         point="org.eclipse.ui.popupMenus">
      <objectContribution
            objectClass="net.java.sqlexplorer.dbviewer.model.TableNode"
            id="net.java.sqlexplorer.hibernate.wizard">
         <action
               label="Hibernate Artifact Generator Wizard"
               class="org.hibernate.reveng.ArtifactGeneratorAction"
               menubarPath="additions"
               id="net.java.sqlexplorer.hibernate.item">
         </action>
      </objectContribution>
 </extension>
...
ArtifactGeneratorAction call ArtifactGeneratorWizard like this :
...
public void run() {
 wizard = new ArtifactGeneratorWizard();
 IWorkbench workbench = PlatformUI.getWorkbench();
 wizard.init(workbench, (IStructuredSelection) selection);
 dialog = new WizardDialog(workbench.getActiveWorkbenchWindow()
   .getShell(), wizard);
 dialog.open();
}
...

this is screenshoot http://www.snpe.co.yu/artifactwizard.png

Hibernate Artifact Generator Wizard call ArtifactGeneratorWizard from console 
plugin with next change 
 (line 244 change is only JDBCFilter#acceptTableName):

public Object execute() {
  cfg.readFromJDBC(new JDBCFilter() {
   public boolean acceptTableName(String name) {
      if (selection == null
       || !(selection instanceof IStructuredSelection))
        return !name.startsWith("BIN$"); // oracle hack    
      else {
       IStructuredSelection structuredSelection = (IStructuredSelection) 
selection;
       for (Iterator iter = structuredSelection
         .iterator(); iter.hasNext();) {
        Object object = iter.next();
        String tableName = null;
        String schemaName = null;
        String catalogName = null;
        if (object instanceof TableNode) {
         TableNode node = (TableNode) object;
         tableName = node.getTableInfo()
          .getSimpleName();
         schemaName = node
          .getTableInfo()
          .getSchemaName();
         catalogName = node
          .getTableInfo()
          .getCatalogName();
        }
        // I want check tableName,schemaName and catalogName,
        // but JDBCFilter need new method
        if (name.equals(tableName))
         return true;
      }
     }
    return false;
  }
 });


Problem is yet with dependencies (for example, when I get table A with foreign 
key to B
I get exceptions, because JDBCBinder work with complete schema)
I can find all dependencies (exported and imported key table) and return true 
in JDBCFilter#acceptTableName
for dependencies table - with this we haven't to change JDBCBinder or
add checkBox in ArtifactGeneratorWizard for generate or not many-to-one,one-to 
many etc - Can JDBCBinder
skip generate collection (one-to-many,many-to-one ...) ?

I can set patched sqlexplorer if You want try this (It work with eclipse 
3.1M6,last cvs hibernate and hibernate tools)
  
Comments ?

Haris Peco


-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
_______________________________________________
hibernate-devel mailing list
hibernate-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/hibernate-devel

Reply via email to