-->
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.  [ 18 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: Reverse generation, generics and custom strategy
PostPosted: Wed Jul 27, 2005 11:22 pm 
Regular
Regular

Joined: Fri Feb 13, 2004 10:02 pm
Posts: 90
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version:
3.0.5

Hibernate Tools plugin
3.0 alpha 4

Hi all, I have a few questions.

1. I need to make use of the meta tags to create the mapping of the generated hbm to a base class (I.E User extends UserBase) and modify the access modifers of some setters and getters. Do I just extract the templates, modify them, and put them on the classpath?

2. Since I'm using reverse engineering, is it possible to specify a custom strategy class using the eclipse plugin?

3. Is it possible to generate generic types for java 5, or should I simply do this in the modified templates in step 1?

Thanks,
Todd


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jul 28, 2005 2:06 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
#1 yes

#2 only possible for ant at the moment

#3 as far as i remmeber ant has generics=true option

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jul 28, 2005 3:22 pm 
Regular
Regular

Joined: Fri Feb 13, 2004 10:02 pm
Posts: 90
Thanks for the help Max. I have one last question. I am creating the ant task and adding it to my maven build, but I can't find any information about how to specify your own subclass of DelegatingReverseEngineeringStrategy to the taskdef.

Thanks,
Todd


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jul 28, 2005 3:25 pm 
Regular
Regular

Joined: Fri Feb 13, 2004 10:02 pm
Posts: 90
Cancel that, I found it. Sorry. For anyone elses benefit its near the top in section 1.1 Configuration and its attributes


Top
 Profile  
 
 Post subject: Still doesn't work
PostPosted: Sat Jul 30, 2005 1:45 pm 
Regular
Regular

Joined: Fri Feb 13, 2004 10:02 pm
Posts: 90
Ok, I'm trying to run the taskdef from within Maven using jelly. I'm pretty sure I have everything set up for my custom delegating strategy, but it seems that the JDBCConfigurationTask can't find the Constructor which does exist. I'm using java 1.5.0_04. I have included a snippit of source from the modified JDBCConfigurationTask that adds more logging, and the debug maven logs.

JDBCConfigurationTask
Code:

private ReverseEngineeringStrategy loadreverseEngineeringStrategy(final String className, ReverseEngineeringStrategy delegate)
    throws BuildException {
        try {
            Class clazz = ReflectHelper.classForName(className);
           
           
            getProject().log("Class is " + clazz, Project.MSG_DEBUG);
       
            Constructor[] cons = clazz.getConstructors();
            Class[] params;
            for(int i = 0; i < cons.length; i++){
               
                getProject().log("Constructor Name '" + cons[i].getName()  + "'", Project.MSG_DEBUG);
                params = cons[i].getParameterTypes();
               
                for(int j = 0; j < params.length; j ++){
                   
                    getProject().log("Parameter " + i + " is of type '" + params[j].getName() + "'", Project.MSG_DEBUG);
                }
            }
           
           
         Constructor constructor = clazz.getConstructor(new Class[] { ReverseEngineeringStrategy.class.getClass() });
           
            getProject().log("Constructor Found", Project.MSG_DEBUG);
           
            return (ReverseEngineeringStrategy) constructor.newInstance(new Object[] { delegate });
        } catch (NoSuchMethodException e) {
         try {
            getProject().log("Could not find public " + className + "(ReverseEngineeringStrategy delegate) constructor on ReverseEngineeringStrategy. Trying no-arg version.",Project.MSG_VERBOSE);         
            Class clazz = ReflectHelper.classForName(className);                  
            ReverseEngineeringStrategy rev = (ReverseEngineeringStrategy) clazz.newInstance();
            getProject().log("Using non-delegating strategy, thus packagename and revengfile will be ignored.", Project.MSG_INFO);
            return rev;
         } catch (Exception eq) {
            throw new BuildException("Could not create or find " + className + " with default no-arg constructor", eq);
         }
      } catch (Exception e) {
         throw new BuildException("Could not create or find " + className + " with one argument delegate constructor", e);
      }
    }




Maven degug log
Code:
  [hibernatetool] [DEBUG] Finding class com.domoflux.dataaccess.hibernate.mapping.MySQLReverseStrategy
    [hibernatetool] [DEBUG] Loaded from C:\workspace\domoflux\dataaccess\target\classes com/domoflux/dataaccess/hibernate/mapping/MySQLReverseStrategy.class
    [hibernatetool] [DEBUG] Finding class org.hibernate.cfg.reveng.DelegatingReverseEngineeringStrategy
    [hibernatetool] [DEBUG] Loaded from C:\Documents and Settings\ninet\.maven\repository\hibernate\jars\hibernate-tools-custom.jar org/hibernate/cfg/reveng/DelegatingReverseEngineeringStrategy.class
    [hibernatetool] [DEBUG] Finding class org.hibernate.cfg.reveng.ReverseEngineeringStrategy
    [hibernatetool] [DEBUG] Loaded from C:\Documents and Settings\ninet\.maven\repository\hibernate\jars\hibernate-tools-custom.jar org/hibernate/cfg/reveng/ReverseEngineeringStrategy.class
    [hibernatetool] [DEBUG] Class java.lang.Object loaded from parent loader (parentFirst)
    [hibernatetool] [DEBUG] Class org.hibernate.cfg.reveng.ReverseEngineeringStrategy loaded from ant loader (parentFirst)
    [hibernatetool] [DEBUG] Class org.hibernate.cfg.reveng.DelegatingReverseEngineeringStrategy loaded from ant loader (parentFirst)
    [hibernatetool] [DEBUG] Class com.domoflux.dataaccess.hibernate.mapping.MySQLReverseStrategy loaded from ant loader (parentFirst)
    [hibernatetool] [DEBUG] Class is class com.domoflux.dataaccess.hibernate.mapping.MySQLReverseStrategy
    [hibernatetool] [DEBUG] Class java.lang.CharSequence loaded from parent loader (parentFirst)
    [hibernatetool] [DEBUG] Constructor Name 'com.domoflux.dataaccess.hibernate.mapping.MySQLReverseStrategy'
    [hibernatetool] [DEBUG] Parameter 0 is of type 'org.hibernate.cfg.reveng.ReverseEngineeringStrategy'
    [hibernatetool] [VERBOSE] Could not find public com.domoflux.dataaccess.hibernate.mapping.MySQLReverseStrategy(ReverseEngineeringStrategy delegate) constructor on ReverseEngineeringStrategy. Trying no-arg version.




task configuration
Code:
<project xmlns:ant="jelly:ant">

   <goal name="genhbm"  prereqs="java:compile">
      
      <ant:taskdef
           name="hibernatetool"
           classname="org.hibernate.tool.ant.HibernateToolTask"
           classpathref="maven.dependency.classpath"/>
      
      <ant:path id="toolpath">
         <ant:pathelement location="${maven.build.dest}" />
         <ant:path refid="maven.dependency.classpath"/>
            
      </ant:path>
      
      <ant:property name="debugpath" refid="toolpath"/>
      <ant:echo> debug path ${debugpath}</ant:echo>
           
      <ant:hibernatetool>
      
         <ant:classpath refid="toolpath"/>
      
         <ant:jdbcconfiguration configurationfile="schemageneration/hibernate.cfg.xml"
            packagename="com.domoflux.data.base"
            revengfile="schemageneration/hibernate.reveng.xml"
            strategy="com.domoflux.dataaccess.hibernate.mapping.MySQLReverseStrategy"
         />
         
         <ant:cfg2hbm destdir="${maven.src.dir}/com/domoflux/dataaccess/hibernate/mapping"/>
      
      </ant:hibernatetool>

   </goal>
</project>



My Strategy
Code:
package com.domoflux.dataaccess.hibernate.mapping;

import org.hibernate.cfg.reveng.DelegatingReverseEngineeringStrategy;
import org.hibernate.cfg.reveng.ReverseEngineeringStrategy;
import org.hibernate.cfg.reveng.TableIdentifier;

/**
* @author Todd Nine
*
* This class applies some special naming conventions
* <p>
* 1. renames all table primary keys to id if there is only a single column for
* that tables primary key
* </p>
*/
public class MySQLReverseStrategy extends DelegatingReverseEngineeringStrategy {

    /**
     * Default constructor
     *
     * @param strategy
     *            The super strategy
     */
    public MySQLReverseStrategy(final ReverseEngineeringStrategy strategy) {
        super(strategy);
    }

    @Override
    public String columnToPropertyName(TableIdentifier table, String property) {
        String tableName = table.getName();
       
        System.out.println("Table Name = '"+ tableName + "'");
        System.out.println("roperty Name = '" + property + "'");
       
        //if the column name is table_name_id, then it is the primary key
        if(property != null && "_id".equals(property.replace(tableName, ""))){
            System.out.println("Generating ID for table '" + tableName + "'");
            return "id";
        }
       
       
        return super.columnToPropertyName(table, property);
    }
   
   

}




Top
 Profile  
 
 Post subject:
PostPosted: Sat Jul 30, 2005 2:30 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
try with the latest cvs version.

Don't know how much extra classloader fun Maven and Jelly can add to the nice mix ;)

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jul 30, 2005 2:45 pm 
Regular
Regular

Joined: Fri Feb 13, 2004 10:02 pm
Posts: 90
Does the latest CVS version require hibernate 3.1? If so, will the mappings I generate be compatible with version 3.0? Also, could this be a JVM specific issue? The class is obviously found, which you can see from the log, but it throws the exception when trying to get the constructor, which exists!

Todd


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jul 30, 2005 2:53 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
even though it is dependent on 3.1 it will generate 3.0 compliant mappings.

I presume the issue has to do with multiple classloaders containing the reveng startegy class and thus gets confused.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject: We are stalled on the same problem than tnine(6months after)
PostPosted: Mon Jan 16, 2006 12:50 pm 
Newbie

Joined: Mon Jan 16, 2006 12:24 pm
Posts: 5
Are there any news on the subject?

We are using hibernate 3.1 and hibernate ant tools 3.1 beta 2.
We have defined a custom strategy class for reverse engineering. like this:


Quote:
public class CACModelReverseEngineeringStrategy extends DelegatingReverseEngineeringStrategy {

public CACModelReverseEngineeringStrategy(final ReverseEngineeringStrategy delegate) {
super(delegate);
}

public String columnToPropertyName(TableIdentifier table, String column) {

StringBuffer colname = new StringBuffer();
colname.append(column);


if (colname.subSequence(0,1).equals("id")) //formatea los campos idnombrepojo a IdNombrepojo
return new StringBuffer( colname.substring(0,1).toUpperCase() ).
append( new StringBuffer( colname.substring(1,2) ).
append( new StringBuffer( colname.substring(2,3).toUpperCase() ).
append( new StringBuffer( colname.substring(3) )
)
)
).toString();

return column.substring(0,1).toUpperCase() + column.substring(1); //Capitaliza el nombre del atributo de un solo nombre.

}
}



Here it's our ant task:

Quote:
<path id="hibernate_tool_path">
<fileset dir="${ant-hibernate-tools.dir}">
<include name="**/*.jar"/>
</fileset>
</path>

<taskdef name="hibernate_tool" classname="org.hibernate.tool.ant.HibernateToolTask" classpathref="hibernate_tool_path"/>


<target name="generacionHibernate" depends="compile, prepare-mapping" description="Genera los ficheros mapeos (.hbm.xml) y POJOS (.java)">
<hibernate_tool>
<classpath refid="hibernate_tool_path"/>
<classpath path="${build.dir}/classes/hibernate"/>
<jdbcconfiguration
packagename="${hibernateGenerated.package}"
configurationfile="${hibernate-src.dir}/hibernate.cfg.xml"
revengfile="${hibernate-src.dir}/hibernate.reveng.xml"
reversestrategy="${build.dir}/classes/hibernate/CACModelReverseEngineeringStrategy"/>
<hbm2hbmxml destdir="${src.dir}/xml"/>
<hbm2java destdir="${src.dir}/java"/>
</hibernate_tool>
</target>




We got this wonderful output from ant:

Quote:
Buildfile: D:\WORKSPACE_CAC_ECLIPSE_05012006\model\src\build_hibernate.xml
compile:
[javac] Compiling 1 source file to D:\WORKSPACE_CAC_ECLIPSE_05012006\model\build\classes
prepare-mapping:
generacionHibernate:
[hibernate_tool] Executing Hibernate Tool with a JDBC Configuration (for reverse engineering)
[hibernate_tool] 1. task: hbm2hbmxml (Generates a set of hbm.xml files)
[hibernate_tool] 16-ene-2006 17:16:00 org.hibernate.cfg.Environment <clinit>
[hibernate_tool] INFO: Hibernate 3.1
[hibernate_tool] 16-ene-2006 17:16:00 org.hibernate.cfg.Environment <clinit>
[hibernate_tool] INFO: hibernate.properties not found
[hibernate_tool] 16-ene-2006 17:16:00 org.hibernate.cfg.Environment <clinit>
[hibernate_tool] INFO: using CGLIB reflection optimizer
[hibernate_tool] 16-ene-2006 17:16:00 org.hibernate.cfg.Environment <clinit>
[hibernate_tool] INFO: using JDK 1.4 java.sql.Timestamp handling
[hibernate_tool] 16-ene-2006 17:16:00 org.hibernate.cfg.Configuration configure
[hibernate_tool] INFO: configuring from file: hibernate.cfg.xml
[hibernate_tool] 16-ene-2006 17:16:00 org.hibernate.cfg.Configuration doConfigure
[hibernate_tool] INFO: Configured SessionFactory: null
[hibernate_tool] 16-ene-2006 17:16:01 org.hibernate.connection.DriverManagerConnectionProvider configure
[hibernate_tool] INFO: Using Hibernate built-in connection pool (not for production use!)
[hibernate_tool] 16-ene-2006 17:16:01 org.hibernate.connection.DriverManagerConnectionProvider configure
[hibernate_tool] INFO: Hibernate connection pool size: 20
[hibernate_tool] 16-ene-2006 17:16:01 org.hibernate.connection.DriverManagerConnectionProvider configure
[hibernate_tool] INFO: autocommit mode: false
[hibernate_tool] 16-ene-2006 17:16:01 org.hibernate.connection.DriverManagerConnectionProvider configure
[hibernate_tool] INFO: using driver: oracle.jdbc.driver.OracleDriver at URL: jdbc:oracle:thin:@atlante:1521:proydev
[hibernate_tool] 16-ene-2006 17:16:01 org.hibernate.connection.DriverManagerConnectionProvider configure
[hibernate_tool] INFO: connection properties: {user=us_cac, password=****}
[hibernate_tool] 16-ene-2006 17:16:02 org.hibernate.cfg.SettingsFactory buildSettings
[hibernate_tool] INFO: RDBMS: Oracle, version: Oracle9i Enterprise Edition Release 9.2.0.6.0 - 64bit Production
[hibernate_tool] With the Partitioning, OLAP and Oracle Data Mining options
[hibernate_tool] JServer Release 9.2.0.6.0 - Production
[hibernate_tool] 16-ene-2006 17:16:02 org.hibernate.cfg.SettingsFactory buildSettings
[hibernate_tool] INFO: JDBC driver: Oracle JDBC driver, version: 9.2.0.5.0
[hibernate_tool] 16-ene-2006 17:16:02 org.hibernate.dialect.Dialect <init>
[hibernate_tool] INFO: Using dialect: org.hibernate.dialect.Oracle9Dialect
[hibernate_tool] 16-ene-2006 17:16:02 org.hibernate.transaction.TransactionFactoryFactory buildTransactionFactory
[hibernate_tool] INFO: Using default transaction strategy (direct JDBC transactions)
[hibernate_tool] 16-ene-2006 17:16:02 org.hibernate.transaction.TransactionManagerLookupFactory getTransactionManagerLoo
kup
[hibernate_tool] INFO: No TransactionManagerLookup configured (in JTA environment, use of read-write or transactional se
cond-level cache is not recommended)
[hibernate_tool] 16-ene-2006 17:16:02 org.hibernate.cfg.SettingsFactory buildSettings
[hibernate_tool] INFO: Automatic flush during beforeCompletion(): disabled
[hibernate_tool] 16-ene-2006 17:16:02 org.hibernate.cfg.SettingsFactory buildSettings
[hibernate_tool] INFO: Automatic session close at end of transaction: disabled
[hibernate_tool] 16-ene-2006 17:16:02 org.hibernate.cfg.SettingsFactory buildSettings
[hibernate_tool] INFO: JDBC batch size: 15
[hibernate_tool] 16-ene-2006 17:16:02 org.hibernate.cfg.SettingsFactory buildSettings
[hibernate_tool] INFO: JDBC batch updates for versioned data: disabled
[hibernate_tool] 16-ene-2006 17:16:02 org.hibernate.cfg.SettingsFactory buildSettings
[hibernate_tool] INFO: Scrollable result sets: enabled
[hibernate_tool] 16-ene-2006 17:16:02 org.hibernate.cfg.SettingsFactory buildSettings
[hibernate_tool] INFO: JDBC3 getGeneratedKeys(): disabled
[hibernate_tool] 16-ene-2006 17:16:02 org.hibernate.cfg.SettingsFactory buildSettings
[hibernate_tool] INFO: Connection release mode: auto
[hibernate_tool] 16-ene-2006 17:16:02 org.hibernate.cfg.SettingsFactory buildSettings
[hibernate_tool] INFO: Default schema: US_CAC
[hibernate_tool] 16-ene-2006 17:16:02 org.hibernate.cfg.SettingsFactory buildSettings
[hibernate_tool] INFO: Default batch fetch size: 1
[hibernate_tool] 16-ene-2006 17:16:02 org.hibernate.cfg.SettingsFactory buildSettings
[hibernate_tool] INFO: Generate SQL with comments: disabled
[hibernate_tool] 16-ene-2006 17:16:02 org.hibernate.cfg.SettingsFactory buildSettings
[hibernate_tool] INFO: Order SQL updates by primary key: disabled
[hibernate_tool] 16-ene-2006 17:16:02 org.hibernate.cfg.SettingsFactory createQueryTranslatorFactory
[hibernate_tool] INFO: Query translator: org.hibernate.hql.ast.ASTQueryTranslatorFactory
[hibernate_tool] 16-ene-2006 17:16:02 org.hibernate.hql.ast.ASTQueryTranslatorFactory <init>
[hibernate_tool] INFO: Using ASTQueryTranslatorFactory
[hibernate_tool] 16-ene-2006 17:16:02 org.hibernate.cfg.SettingsFactory buildSettings
[hibernate_tool] INFO: Query language substitutions: {}
[hibernate_tool] 16-ene-2006 17:16:02 org.hibernate.cfg.SettingsFactory buildSettings
[hibernate_tool] INFO: Second-level cache: enabled
[hibernate_tool] 16-ene-2006 17:16:02 org.hibernate.cfg.SettingsFactory buildSettings
[hibernate_tool] INFO: Query cache: disabled
[hibernate_tool] 16-ene-2006 17:16:02 org.hibernate.cfg.SettingsFactory createCacheProvider
[hibernate_tool] INFO: Cache provider: org.hibernate.cache.EhCacheProvider
[hibernate_tool] 16-ene-2006 17:16:02 org.hibernate.cfg.SettingsFactory buildSettings
[hibernate_tool] INFO: Optimize cache for minimal puts: disabled
[hibernate_tool] 16-ene-2006 17:16:02 org.hibernate.cfg.SettingsFactory buildSettings
[hibernate_tool] INFO: Structured second-level cache entries: disabled
[hibernate_tool] 16-ene-2006 17:16:02 org.hibernate.cfg.SettingsFactory buildSettings
[hibernate_tool] INFO: Statistics: disabled
[hibernate_tool] 16-ene-2006 17:16:02 org.hibernate.cfg.SettingsFactory buildSettings
[hibernate_tool] INFO: Deleted entity synthetic identifier rollback: disabled
[hibernate_tool] 16-ene-2006 17:16:02 org.hibernate.cfg.SettingsFactory buildSettings
[hibernate_tool] INFO: Default entity-mode: pojo
[hibernate_tool] 16-ene-2006 17:16:02 org.hibernate.cfg.reveng.OverrideRepository addFile
[hibernate_tool] INFO: Override file: D:\WORKSPACE_CAC_ECLIPSE_05012006\model\src\hibernate\hibernate.reveng.xml

BUILD FAILED
D:\WORKSPACE_CAC_ECLIPSE_05012006\model\src\build_hibernate.xml:64: Could not create or find build/classes/hibernate/CAC
ModelReverseEngineeringStrategy with one argument delegate constructor

Total time: 4 seconds


We have looked for documentation about hibernate tools 3.1 beta 2 but all the documentation is about version 3.1 beta 1 at best.

Any help will be very appreciated thanks.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 16, 2006 1:01 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
yes - the error message is pretty clear.

The class "build/classes/hibernate/CACModelReverseEngineeringStrategy" does not have a proper constructor.

Looking more closely on the name might tell you what is wrong with this *classname*. ;)

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject: :(
PostPosted: Mon Jan 16, 2006 1:35 pm 
Newbie

Joined: Mon Jan 16, 2006 12:24 pm
Posts: 5
max wrote:
yes - the error message is pretty clear.

The class "build/classes/hibernate/CACModelReverseEngineeringStrategy" does not have a proper constructor.

Looking more closely on the name might tell you what is wrong with this *classname*. ;)


Thanks for your quick response max,

I'm very sorry but we don't see anything wrong with the name class nor the constructor with a ReverseEngineeringStrategy parameter as suggested in the documentation. Are we missing something? Where exactly the error is?(We are really surprised that the error has been so evident and we aren't able to figure what's wrong with the classname as you pointed).

Sorry and thanks again for your time, could you be a bit more explicit, thanks again.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 16, 2006 1:47 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
I am quite sure that "build/classes/hibernate/CACModelReverseEngineeringStrategy" is NOT a real *classname*, but a relative file name.

hibernate.CACModelReverseEngineeringStrategy looks more like a real classname.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject: We got your point
PostPosted: Tue Jan 17, 2006 4:24 am 
Newbie

Joined: Mon Jan 16, 2006 12:24 pm
Posts: 5
max wrote:
I am quite sure that "build/classes/hibernate/CACModelReverseEngineeringStrategy" is NOT a real *classname*, but a relative file name.

hibernate.CACModelReverseEngineeringStrategy looks more like a real classname.


Hi, again max. We have updated the line:

Quote:
<jdbcconfiguration
packagename="${hibernateGenerated.package}"
configurationfile="${hibernate-src.dir}/hibernate.cfg.xml"
revengfile="${hibernate-src.dir}/hibernate.reveng.xml"
reversestrategy="hibernate.CACModelReverseEngineeringStrategy"/>


... in our ant task.

In fact it was our first thought. But the output we got was exactly the same than the one we posted yesterday, of course the las paragraph is as follows:

Quote:
...
...
...
[hibernate_tool] 17-ene-2006 8:59:52 org.hibernate.cfg.reveng.OverrideRepository addFile
[hibernate_tool] INFO: Override file: D:\WORKSPACE_CAC_ECLIPSE_05012006\model\src\hibernate\hibernate.reveng.xml

BUILD FAILED
D:\WORKSPACE_CAC_ECLIPSE_05012006\model\src\build_hibernate.xml:64: Could not create or find hibernate.CACModelReverseEn
gineeringStrategy with one argument delegate constructor

Total time: 5 seconds



Because of that we thought that hibernate was looking for the binary (.class) in spite of the source, so we decided to try pointing to the folder where we place the binaries. (and it seems we were wrong)

I'm going to "paste" the full output (updated) again for you:

Quote:
Buildfile: D:\WORKSPACE_CAC_ECLIPSE_05012006\model\src\build_hibernate.xml
compile:
[javac] Compiling 1 source file to D:\WORKSPACE_CAC_ECLIPSE_05012006\model\build\classes
prepare-mapping:
generacionHibernate:
[hibernate_tool] Executing Hibernate Tool with a JDBC Configuration (for reverse engineering)
[hibernate_tool] 1. task: hbm2hbmxml (Generates a set of hbm.xml files)
[hibernate_tool] 17-ene-2006 8:59:50 org.hibernate.cfg.Environment <clinit>
[hibernate_tool] INFO: Hibernate 3.1
[hibernate_tool] 17-ene-2006 8:59:50 org.hibernate.cfg.Environment <clinit>
[hibernate_tool] INFO: hibernate.properties not found
[hibernate_tool] 17-ene-2006 8:59:50 org.hibernate.cfg.Environment <clinit>
[hibernate_tool] INFO: using CGLIB reflection optimizer
[hibernate_tool] 17-ene-2006 8:59:50 org.hibernate.cfg.Environment <clinit>
[hibernate_tool] INFO: using JDK 1.4 java.sql.Timestamp handling
[hibernate_tool] 17-ene-2006 8:59:51 org.hibernate.cfg.Configuration configure
[hibernate_tool] INFO: configuring from file: hibernate.cfg.xml
[hibernate_tool] 17-ene-2006 8:59:51 org.hibernate.cfg.Configuration doConfigure
[hibernate_tool] INFO: Configured SessionFactory: null
[hibernate_tool] 17-ene-2006 8:59:51 org.hibernate.connection.DriverManagerConnectionProvider configure
[hibernate_tool] INFO: Using Hibernate built-in connection pool (not for production use!)
[hibernate_tool] 17-ene-2006 8:59:51 org.hibernate.connection.DriverManagerConnectionProvider configure
[hibernate_tool] INFO: Hibernate connection pool size: 20
[hibernate_tool] 17-ene-2006 8:59:51 org.hibernate.connection.DriverManagerConnectionProvider configure
[hibernate_tool] INFO: autocommit mode: false
[hibernate_tool] 17-ene-2006 8:59:51 org.hibernate.connection.DriverManagerConnectionProvider configure
[hibernate_tool] INFO: using driver: oracle.jdbc.driver.OracleDriver at URL: jdbc:oracle:thin:@atlante:1521:proydev
[hibernate_tool] 17-ene-2006 8:59:51 org.hibernate.connection.DriverManagerConnectionProvider configure
[hibernate_tool] INFO: connection properties: {user=us_cac, password=****}
[hibernate_tool] 17-ene-2006 8:59:52 org.hibernate.cfg.SettingsFactory buildSettings
[hibernate_tool] INFO: RDBMS: Oracle, version: Oracle9i Enterprise Edition Release 9.2.0.6.0 - 64bit Production
[hibernate_tool] With the Partitioning, OLAP and Oracle Data Mining options
[hibernate_tool] JServer Release 9.2.0.6.0 - Production
[hibernate_tool] 17-ene-2006 8:59:52 org.hibernate.cfg.SettingsFactory buildSettings
[hibernate_tool] INFO: JDBC driver: Oracle JDBC driver, version: 9.2.0.5.0
[hibernate_tool] 17-ene-2006 8:59:52 org.hibernate.dialect.Dialect <init>
[hibernate_tool] INFO: Using dialect: org.hibernate.dialect.Oracle9Dialect
[hibernate_tool] 17-ene-2006 8:59:52 org.hibernate.transaction.TransactionFactoryFactory buildTransactionFactory
[hibernate_tool] INFO: Using default transaction strategy (direct JDBC transactions)
[hibernate_tool] 17-ene-2006 8:59:52 org.hibernate.transaction.TransactionManagerLookupFactory getTransactionManagerLook
up
[hibernate_tool] INFO: No TransactionManagerLookup configured (in JTA environment, use of read-write or transactional se
cond-level cache is not recommended)
[hibernate_tool] 17-ene-2006 8:59:52 org.hibernate.cfg.SettingsFactory buildSettings
[hibernate_tool] INFO: Automatic flush during beforeCompletion(): disabled
[hibernate_tool] 17-ene-2006 8:59:52 org.hibernate.cfg.SettingsFactory buildSettings
[hibernate_tool] INFO: Automatic session close at end of transaction: disabled
[hibernate_tool] 17-ene-2006 8:59:52 org.hibernate.cfg.SettingsFactory buildSettings
[hibernate_tool] INFO: JDBC batch size: 15
[hibernate_tool] 17-ene-2006 8:59:52 org.hibernate.cfg.SettingsFactory buildSettings
[hibernate_tool] INFO: JDBC batch updates for versioned data: disabled
[hibernate_tool] 17-ene-2006 8:59:52 org.hibernate.cfg.SettingsFactory buildSettings
[hibernate_tool] INFO: Scrollable result sets: enabled
[hibernate_tool] 17-ene-2006 8:59:52 org.hibernate.cfg.SettingsFactory buildSettings
[hibernate_tool] INFO: JDBC3 getGeneratedKeys(): disabled
[hibernate_tool] 17-ene-2006 8:59:52 org.hibernate.cfg.SettingsFactory buildSettings
[hibernate_tool] INFO: Connection release mode: auto
[hibernate_tool] 17-ene-2006 8:59:52 org.hibernate.cfg.SettingsFactory buildSettings
[hibernate_tool] INFO: Default schema: US_CAC
[hibernate_tool] 17-ene-2006 8:59:52 org.hibernate.cfg.SettingsFactory buildSettings
[hibernate_tool] INFO: Default batch fetch size: 1
[hibernate_tool] 17-ene-2006 8:59:52 org.hibernate.cfg.SettingsFactory buildSettings
[hibernate_tool] INFO: Generate SQL with comments: disabled
[hibernate_tool] 17-ene-2006 8:59:52 org.hibernate.cfg.SettingsFactory buildSettings
[hibernate_tool] INFO: Order SQL updates by primary key: disabled
[hibernate_tool] 17-ene-2006 8:59:52 org.hibernate.cfg.SettingsFactory createQueryTranslatorFactory
[hibernate_tool] INFO: Query translator: org.hibernate.hql.ast.ASTQueryTranslatorFactory
[hibernate_tool] 17-ene-2006 8:59:52 org.hibernate.hql.ast.ASTQueryTranslatorFactory <init>
[hibernate_tool] INFO: Using ASTQueryTranslatorFactory
[hibernate_tool] 17-ene-2006 8:59:52 org.hibernate.cfg.SettingsFactory buildSettings
[hibernate_tool] INFO: Query language substitutions: {}
[hibernate_tool] 17-ene-2006 8:59:52 org.hibernate.cfg.SettingsFactory buildSettings
[hibernate_tool] INFO: Second-level cache: enabled
[hibernate_tool] 17-ene-2006 8:59:52 org.hibernate.cfg.SettingsFactory buildSettings
[hibernate_tool] INFO: Query cache: disabled
[hibernate_tool] 17-ene-2006 8:59:52 org.hibernate.cfg.SettingsFactory createCacheProvider
[hibernate_tool] INFO: Cache provider: org.hibernate.cache.EhCacheProvider
[hibernate_tool] 17-ene-2006 8:59:52 org.hibernate.cfg.SettingsFactory buildSettings
[hibernate_tool] INFO: Optimize cache for minimal puts: disabled
[hibernate_tool] 17-ene-2006 8:59:52 org.hibernate.cfg.SettingsFactory buildSettings
[hibernate_tool] INFO: Structured second-level cache entries: disabled
[hibernate_tool] 17-ene-2006 8:59:52 org.hibernate.cfg.SettingsFactory buildSettings
[hibernate_tool] INFO: Statistics: disabled
[hibernate_tool] 17-ene-2006 8:59:52 org.hibernate.cfg.SettingsFactory buildSettings
[hibernate_tool] INFO: Deleted entity synthetic identifier rollback: disabled
[hibernate_tool] 17-ene-2006 8:59:52 org.hibernate.cfg.SettingsFactory buildSettings
[hibernate_tool] INFO: Default entity-mode: pojo
[hibernate_tool] 17-ene-2006 8:59:52 org.hibernate.cfg.reveng.OverrideRepository addFile
[hibernate_tool] INFO: Override file: D:\WORKSPACE_CAC_ECLIPSE_05012006\model\src\hibernate\hibernate.reveng.xml

BUILD FAILED
D:\WORKSPACE_CAC_ECLIPSE_05012006\model\src\build_hibernate.xml:64: Could not create or find hibernate.CACModelReverseEn
gineeringStrategy with one argument delegate constructor

Total time: 5 seconds



And of course the resource "CACModelReverseEngineeringStrategy.java" exists in the package "hibernate" which is placed under "src" folder from our "model" project.

Any more ideas? Is there anyone following the thread who has something to add?

Thanks in every way, max


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 17, 2006 4:49 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
And that class is *in* the classpath you give to hibernatetool ?

If yes, then show me the code of that class and run ant with -debug and show the stacktrace - thanks.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject: Here we go again !!!
PostPosted: Tue Jan 17, 2006 5:24 am 
Newbie

Joined: Mon Jan 16, 2006 12:24 pm
Posts: 5
max wrote:
And that class is *in* the classpath you give to hibernatetool ?

If yes, then show me the code of that class and run ant with -debug and show the stacktrace - thanks.


Hi again max,

here you have our full build_hibernate.xml:

Quote:
<?xml version="1.0"?>
<project name="model" basedir=".." default="help">
<property name="src.dir" value="src"/>
<property name="build.dir" value="build"/>
<property name="ant-hibernate-tools.dir" value="lib/ant-hibernate-tools"/>
<property name="hibernateGenerated.dir" value="${src.dir}/es/di/cac/ticketing/model/hibernateGenerated" />
<property name="hibernateGenerated.package" value="es/di/cac/ticketing/model/hibernateGenerated/java" />
<property name="hibernate-src.dir" value="${src.dir}/hibernate"/>
<property environment="env"/>

<!--
==========================================================================================
DEFINICIONES
==========================================================================================
-->

<path id="hibernate_tool_path">
<fileset dir="${ant-hibernate-tools.dir}">
<include name="**/*.jar"/>
</fileset>
</path>

<taskdef name="hibernate_tool" classname="org.hibernate.tool.ant.HibernateToolTask" classpathref="hibernate_tool_path"/>

<!--
==========================================================================================
TAREAS DE ANT
==========================================================================================
-->

<target name="help">
<echo message=""/>
<echo message="-----------------------------------"/>
<echo message=""/>
<echo message="Available targets are:"/>
<echo message=""/>
<echo message="compile --> Compila el fichero de estrategia personalizada."/>
<echo message="prepare-mapping --> Crea el directorio "/>
<echo message="generacionHibernate --> Genera los ficheros .hbm.xml y .java "/>
</target>

<target name="compile" description="Compile CACReverseEngineeringStrategy.java">
<javac destdir="${build.dir}/classes" debug="true" optimize="false"
deprecation="false" failonerror="true">
<src path="${hibernate-src.dir}"/>
<classpath refid="hibernate_tool_path"/>
</javac>
</target>

<target name="prepare-mapping">
<mkdir dir="${hibernateGenerated.dir}"/>
<delete>
<fileset dir="${hibernateGenerated.dir}">
<include name="**/*.java"/>
<include name="**/*.hbm.xml"/>
</fileset>
</delete>

<mkdir dir="${hibernateGenerated.dir}/java"/>
<mkdir dir="${hibernateGenerated.dir}/xml"/>
</target>

<target name="generacionHibernate" depends="compile, prepare-mapping" description="Genera los ficheros de mapeo (.hbm.xml) y POJOS (.java)">
<hibernate_tool>
<classpath refid="hibernate_tool_path"/>
<classpath path="${build.dir}/classes/hibernate"/>
<!--<classpath path="${hibernate-src.dir}/"/>-->
<jdbcconfiguration
packagename="${hibernateGenerated.package}"
configurationfile="${hibernate-src.dir}/hibernate.cfg.xml"
revengfile="${hibernate-src.dir}/hibernate.reveng.xml"
reversestrategy="hibernate.CACModelReverseEngineeringStrategy"/>
<hbm2hbmxml destdir="${src.dir}/xml"/>
<hbm2java destdir="${src.dir}/java"/>
</hibernate_tool>
</target>

</project>


As you can see, the place were the .class is buit is aded to the classpath (we even included in the classpath the path for the source with the same results but is at the present time commented).

And here it is the code for the java class with our customized Reverse Engineering Strategy:

Quote:
package hibernate;

import org.hibernate.cfg.reveng.DelegatingReverseEngineeringStrategy;
import org.hibernate.cfg.reveng.ReverseEngineeringStrategy;
import org.hibernate.cfg.reveng.TableIdentifier;

public class CACModelReverseEngineeringStrategy extends DelegatingReverseEngineeringStrategy {


public CACModelReverseEngineeringStrategy(final ReverseEngineeringStrategy delegate) {
super(delegate);
}


public String columnToPropertyName(TableIdentifier table, String column) {

StringBuffer colname = new StringBuffer();
colname.append(column);


if (colname.subSequence(0,1).equals("id")) //formatea los campos idnombrepojo a IdNombrepojo
return new StringBuffer( colname.substring(0,1).toUpperCase() ).
append( new StringBuffer( colname.substring(1,2) ).
append( new StringBuffer( colname.substring(2,3).toUpperCase() ).
append( new StringBuffer( colname.substring(3) )
)
)
).toString();

return column.substring(0,1).toUpperCase() + column.substring(1); //Capitaliza el nombre del atributo de un solo nombre.

}
}



Can I send you the output from the ant with debug info activated to an email address or something like that? It is 181kB long. A bit overkill to post ...

Thanks again max.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 18 posts ]  Go to page 1, 2  Next

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.