-->
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.  [ 9 posts ] 
Author Message
 Post subject: Hibernate 3 Tool takes too long to generate (PART II)
PostPosted: Fri May 06, 2005 10:51 am 
Regular
Regular

Joined: Wed Sep 29, 2004 11:34 am
Posts: 62
Location: Houston, TX
First, let me apologize for creating another thread. I just want a fresh start at this again.
We want to migrate from hibernate 2.7 to hibernate 3.02. The following is what we have:

    - Hibernate 3.02
    - Eclipse 3.1M4
    - JBossIDE-1.5M1-hibernate-tools
    - MySQL 4.1.7-nt
    - Database contains 181 tables


Step 1: Allow the tool to create the hibernate.cfg.xml file. Output is the following:
Code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC
      "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
      "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
    <session-factory>
        <property name="hibernate.connection.username">***</property>
        <property name="hibernate.connection.password">****</property>
        <property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>
        <property name="hibernate.connection.url">jdbc:mysql://localhost:3306/atdb</property>
        <property name="hibernate.connection.driver_class">org.gjt.mm.mysql.Driver</property>
    </session-factory>
</hibernate-configuration>


Step 2: Create console configuration. Configuration file points to hibernate.cfg.xml. There are no files under Mapping files. Classpath only includes driver for MySQL and it points to bin directory.

Step 3: Set artifact generation. First we selected the cosole configuration which was created in step 2. Output directory points to the src folder.
We want to first only generate the hbm.xml files so we check "Reverse engineer from JDBC Connection" and in the package we put our package name. We also check "generate mappings (hbm.xml)".

The reason we want to first create the hbm files is because there are some Sets where we would like to set lazy="false" so once we update all the hbm files that we need, than we were hoping to edit the console configuration and now point to hbm files. Finally use the artifact generation to "generate domain code (.java)".

Problem: When we try to generate the hbm.xml files it takes a very very long time. Eclipse after 30 to 45 minutes quits and gives a "out of memory error". In the previous thread Max mentioned it should only take a few seconds, could please tell us what was done incorrectly or do we have some versioning issues.


Top
 Profile  
 
 Post subject:
PostPosted: Fri May 06, 2005 12:30 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
Two things:

1) I seriously dont know what should be taking this long. I would probably need the schema to be able to reverese engineer it.

2) If you already have mappings from hibernate 2, why don't you just use them and simply change the DTD reference ?

/max

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Fri May 06, 2005 1:30 pm 
Expert
Expert

Joined: Sat Jun 12, 2004 4:49 pm
Posts: 915
it is long, because you have many fk (probably)

try set hibernate property default schema like

<property name="hibernate.default_schema">Schema_name</property>

in cfg.xml

question : have you views in schema and are there views in mysql

regards


Top
 Profile  
 
 Post subject:
PostPosted: Fri May 06, 2005 2:05 pm 
Regular
Regular

Joined: Wed Sep 29, 2004 11:34 am
Posts: 62
Location: Houston, TX
Thanks for letting me know where to put the default schema. I did not know where to put it.

I do not have any views in mysql.

I tried to regenerate the hbm.xml files but once again it took too long.

I tried what Max asked to use the hbm files that were created for Hibernate 2. We were not sure if they were compatable, but we changed the dtds of them to point hibernate 3. Everything worked out fine! We recreated the configuration file to point to the new hbm files and asked it to generate the POJOs. It created that as well and very quickly!

Now we wanted to a Session Factory. So we right clicked on the console configuration and asked it to create the Session Factory and we receive the following error:

SessionFactory(org.hibernate.MappingException: could not instantiate id generator)
Reason: org.hibernate.MappingException:could not instantiate id generator

Our hbm.xml files point to the "native" id generator. The following is our most simplest and smallest table:

Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
   "-//Hibernate/Hibernate Mapping DTD//EN"
   "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd" >

<hibernate-mapping package="com.at.hib.persistence">
   <class name="DisabilityType" table="disability_type">
   <cache usage="transactional"/>
      <id
         column="ID"
         name="Id"
         type="integer"
      >
         <generator class="native" />
      </id>
      <property
         column="Name"
         length="50"
         name="Name"
         not-null="false"
         type="string"
       />
      <set
         inverse="true"
         lazy="true"
         name="DisabilitySet"
      >
         <key column="TypeID" />
         <one-to-many class="Disability" />
      </set>
   </class>
</hibernate-mapping>


Can someone help us with this issue now. I wanted to thank everyone especially Max for helping us out so far.


Top
 Profile  
 
 Post subject:
PostPosted: Fri May 06, 2005 4:55 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
you need to look/show the complete stacktrace. its available in the Error Log view. It should tell you whats wrong.

You didnt by accident add hibernate.jars to the configuration classpath - right ?

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Fri May 06, 2005 5:30 pm 
Regular
Regular

Joined: Wed Sep 29, 2004 11:34 am
Posts: 62
Location: Houston, TX
I did have hibernate jars in my classpath. I removed them as you requested, but I still get the error.

StackTrace is as follows:

org.hibernate.MappingException: could not instantiate id generator
at org.hibernate.id.IdentifierGeneratorFactory.create(IdentifierGeneratorFactory.java:94)
at org.hibernate.mapping.SimpleValue.createIdentifierGenerator(SimpleValue.java:135)
at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:166)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1054)
at org.hibernate.console.ConsoleConfiguration$1.execute(ConsoleConfiguration.java:222)
at org.hibernate.console.ConsoleConfiguration.execute(ConsoleConfiguration.java:77)
at org.hibernate.console.ConsoleConfiguration.initSessionFactory(ConsoleConfiguration.java:220)
at org.hibernate.eclipse.console.actions.BuildSessionFactoryAction.doRun(BuildSessionFactoryAction.java:51)
at org.hibernate.eclipse.console.actions.ConsoleConfigurationBasedAction.run(ConsoleConfigurationBasedAction.java:47)
at org.eclipse.ui.actions.BaseSelectionListenerAction.runWithEvent(BaseSelectionListenerAction.java:167)
at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:555)
at org.eclipse.jface.action.ActionContributionItem.access$2(ActionContributionItem.java:505)
at org.eclipse.jface.action.ActionContributionItem$6.handleEvent(ActionContributionItem.java:419)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:82)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:833)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:2803)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2448)
at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1569)
at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1540)
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:285)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:144)
at org.eclipse.ui.internal.ide.IDEApplication.run(IDEApplication.java:102)
at org.eclipse.core.internal.runtime.PlatformActivator$1.run(PlatformActivator.java:220)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:273)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:129)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.eclipse.core.launcher.Main.basicRun(Main.java:185)
at org.eclipse.core.launcher.Main.run(Main.java:710)
at org.eclipse.core.launcher.Main.main(Main.java:694)
Caused by: java.lang.ClassNotFoundException: vm
at org.eclipse.osgi.framework.internal.core.BundleLoader.findClass(BundleLoader.java:404)
at org.eclipse.osgi.framework.adaptor.core.AbstractClassLoader.loadClass(AbstractClassLoader.java:93)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at org.hibernate.util.ReflectHelper.classForName(ReflectHelper.java:108)
at org.hibernate.id.IdentifierGeneratorFactory.create(IdentifierGeneratorFactory.java:88)
... 31 more


Top
 Profile  
 
 Post subject:
PostPosted: Fri May 06, 2005 5:43 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
that stacktrace states its looking for "vm" ? have you listed that somewhere in your hibernate mappings ?

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Fri May 06, 2005 5:47 pm 
Expert
Expert

Joined: Sat Jun 12, 2004 4:49 pm
Posts: 915
try this
Code:
<id
         column="ID"
         name="id"
         type="integer"
      >
         <generator class="native" />


lower 'id' excpet 'Id' in name="id"

regards


Top
 Profile  
 
 Post subject:
PostPosted: Fri May 06, 2005 6:04 pm 
Regular
Regular

Joined: Wed Sep 29, 2004 11:34 am
Posts: 62
Location: Houston, TX
Thank You Max!!!!! That was it.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 9 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.