This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 140811

Summary: Rev.Eng. wizard doesn't generate POJOs and HBMs
Product: javaee Reporter: Jan Horvath <jhorvath>
Component: HibernateAssignee: Petr Cyhelsky <cyhelsky>
Status: RESOLVED INVALID    
Severity: blocker CC: kganfield, ksudhanshu, pjiricka, varungovil
Priority: P2    
Version: 6.x   
Hardware: All   
OS: All   
Issue Type: DEFECT Exception Reporter:
Bug Depends on: 147797    
Bug Blocks:    
Attachments: My Log File
my metrics file
My UI gestures

Description Jan Horvath 2008-07-18 19:58:34 UTC
I've tested reverse engineering wizard with sakila[1] sample database which we can consider as a valid db schema. Only reveng file was create, no POJOs, no 
HBMs. 

[1] http://forge.mysql.com/wiki/SakilaSampleDB#Get_the_Sakila_Sample_Database
Comment 1 _ gowri 2008-07-18 20:04:59 UTC
Hibernate Tools code from hibernate.org is not working well only with MySQL db. This works well with JavaDB and HSQLDB.
Investigating why Hibernate Tools is failing for MySQL only..
Comment 2 _ gowri 2008-07-22 07:32:15 UTC
Partial bug is fixed in http://hg.netbeans.org/main/rev/3f7a80c5548b.
Comment 3 _ gowri 2008-07-22 21:39:34 UTC
With the above fix, POJOs (with or without annotations) can be generated. There still seems to be a problem with
generating mapping files which I am investigating. Since there is a workaround for this to use annotated POJOs, I am
lowering the priority to 3. 
Comment 4 Jan Horvath 2008-09-03 12:37:55 UTC
*** Issue 145039 has been marked as a duplicate of this issue. ***
Comment 5 scitronpousty 2008-09-17 23:16:27 UTC
*** Issue 138839 has been marked as a duplicate of this issue. ***
Comment 6 scitronpousty 2008-09-17 23:22:15 UTC
This still doesn't work with PostgreSQL either using the nightly. 
I can't get it to work with annotations either. Can someone please tell me how I can help diagnose where this is going
wrong. On my machine this feature is not doing anything but making the reveng.xml file.
Extremely frustrating.


Product Version: NetBeans IDE Dev (Build 200809170201)
Java: 1.6.0_07; Java HotSpot(TM) Client VM 10.0-b23
System: Windows XP version 5.1 running on x86; Cp1252; en_US (nb)
Comment 7 Jayashri Visvanathan 2008-09-17 23:25:31 UTC
Honza,
  Can you please try PostgreSQL and confirm that annotations can be generated with Sakila.
thanks.
Comment 8 Vadiraj Deshpande 2008-09-18 22:12:05 UTC
Fixed : http://hg.netbeans.org/main/rev/ee43236d7e7b
Now mapping files can be generated using Reverse Engg. wizard.
Comment 9 Vadiraj Deshpande 2008-09-18 22:12:53 UTC
Also, Annotated POJOs can be generated without any issues as before.
Comment 10 scitronpousty 2008-09-21 07:04:15 UTC
Still not working for me. Here is the steps on followed on Win XP sp2, Java 6.latestButNot10, Netbeans9201401
Fresh .netbeans, .netbeans-derby and netbeansprojects folder
1. Add the db connection under server to my Postgresql database
2. Created a web project with only the hibernate libraries checked - used tomcat 6.0.18 and the server and j2ee5
At this point I get a hibernate.cfg.xml in the root src folder
3. Added the jdbc jar file to the project libraries - using the jdbc4 driver that ships with PostgreSQL. 
4. Right click on the source packages folder and select New -> Other and then choose Hibernate -> HIbernate Mapping
Files and POJOS from database
5. Leave all the defaults on the first page of the wizard which will put the reveng.xml file in src/java
6. I add all my tables on the next page of the wizard
7. Leave all the checkboxes alone and type in "data" for the packaged to create the files in
It creates the reveng.xml file but none of the other files are created. 
This feels like broken to me. Please let me know if I am doing anything wrong but it seems like I am following the right
path.
Comment 11 scitronpousty 2008-09-21 07:11:51 UTC
Just so you know this works if I point it at a derby datasource that came with netbeans. 
So either this is an issue with usercreated datasources (on the server tab) or with just postgresql
Comment 12 scitronpousty 2008-09-21 08:05:56 UTC
This also works with a MySQL user added database so my guess is this a Postgresql issue. I have filed a bug 
http://www.netbeans.org/issues/show_bug.cgi?id=147797
for the hibernate plugin wizard where it does not add the postgresql dialect to the hibernate.cfg.xml on creation.
Please test this with postgresql to make sure the fix works.
Thanks for all your help
Comment 13 Vadiraj Deshpande 2008-09-21 11:49:52 UTC
Thanks Steve for testing the fix. Mostly the root cause is because of #147797 (not having the right dialect). I will
test the fix with Postgresql and verify. Meanwhile, if you have the IDE logs, can you please attach to this issue ?

-Vadiraj
Comment 14 scitronpousty 2008-09-22 16:46:15 UTC
How do I turn on my IDE log? If it is on by default then where do I grab it?
Thanks
Steve
Comment 15 Vadiraj Deshpande 2008-09-22 19:25:32 UTC
Hi Steven,
IDE log is stored in ${netbeans.home}/var/log/messages.log where ${netbeans.home} is the directory used by IDE to store data. You can find out the exact 
value of '${netbeans.home}' on the About box in the IDE (Help/About). By default, all development builds have the logs turned on.

-Vadiraj.
Comment 16 scitronpousty 2008-09-22 19:33:38 UTC
Created attachment 70235 [details]
My Log File
Comment 17 scitronpousty 2008-09-22 19:36:51 UTC
Created attachment 70236 [details]
my metrics file
Comment 18 scitronpousty 2008-09-22 19:37:27 UTC
Created attachment 70237 [details]
My UI gestures
Comment 19 Vadiraj Deshpande 2008-09-24 09:54:06 UTC
Fixed Schema selection related issue in generated reveng.xml file. Schema generation now happens using <schema-selection> tags and not using <table-
filter> as it used to happen before. 
This fix applies to all databases including PostgreSQL with which this issue was re-opened.
Tested with PostgreSQL, MySQL, Oracle 10g and JavaDB, the reverse engg. process to generate annotated POJOs and/or mapping files.

http://hg.netbeans.org/main/rev/2bc40b634f50
Comment 20 Martin Fousek 2008-09-26 10:20:16 UTC
Verified with NetBeans IDE Dev (Build 200809220201) (for MySQL and PostgreSQL, JavaDB).
Comment 21 Martin Fousek 2008-09-26 10:21:50 UTC
Sorry, verified with NetBeans IDE Dev (Build 200809251401) (for MySQL and PostgreSQL, JavaDB).
Comment 22 scitronpousty 2008-10-12 07:19:09 UTC
Works now for me as well. Thanks everyone - loving netbeans, the developers, and the community
Comment 23 ksudhanshu 2009-08-04 02:27:05 UTC
When i creating a pojo and hbm from MySQL 5.1 database table (With foreign key relationship) i am getting this.
Comment 24 ksudhanshu 2009-08-04 02:27:47 UTC
When i creating a pojo and hbm from MySQL 5.1 database table (With foreign key relationship) i am getting this.
Comment 25 Petr Cyhelsky 2009-08-04 15:40:19 UTC
I'm not very sure, what is the nature of your problem as your description is too short but I tested generating POJOs and
HBMs nonetheless. Config:

Product Version: NetBeans IDE Dev (Build 090804)
Java: 1.6.0_0; OpenJDK Client VM 14.0-b08
System: Linux version 2.6.28-14-generic running on i386; UTF-8; en_US (nb)
Mysql:   Server version		5.1.31-1ubuntu2
sakila sample db

and everything seems to work fine (POJOs and HBMs were generated correctly).

=> INCOMPLETE If you encounter the problem again, please include more detailed description of the problem, IDE log and
some steps to reproduce the problem.
Comment 26 Michal Mocnak 2009-09-22 10:36:01 UTC
Without requested information for long time - INVALID. We can't do anything in this case. Reporter, please add requested information and reopen issue. 
Thanks in advance.
Comment 27 rweaver 2011-03-24 22:38:04 UTC
This occurred for me as well when I followed the instructions at http://netbeans.org/kb/docs/web/hibernate-webapp.html that said to add the property hibernate.query.factory_class set to org.hibernate.hql.classic.ClassicQueryTranslatorFactory in the hibernate.cfg.xml file

Looking at my log file, there is an error (even though the class does appear to exist in the hibernate3.jar:

INFO [org.hibernate.cfg.SettingsFactory]: Query translator: org.hibernate.hql.classic.ClassicQueryTransactionFactory
SEVERE [org.openide.util.Exceptions]
org.hibernate.HibernateException: could not instantiate QueryTranslatorFactory: org.hibernate.hql.classic.ClassicQueryTransactionFactory
	at org.hibernate.cfg.SettingsFactory.createQueryTranslatorFactory(SettingsFactory.java:391)
	at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:222)
	at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:2005)
	at org.hibernate.cfg.JDBCMetaDataConfiguration.readFromJDBC(JDBCMetaDataConfiguration.java:40)
	at org.netbeans.modules.hibernate.wizards.HibernateCodeGenWizard.generateClasses(HibernateCodeGenWizard.java:328)
	at org.netbeans.modules.hibernate.wizards.HibernateCodeGenWizard.instantiate(HibernateCodeGenWizard.java:419)
	at org.openide.loaders.TemplateWizard$InstantiatingIteratorBridge.instantiate(TemplateWizard.java:1019)
	at org.openide.loaders.TemplateWizard.handleInstantiate(TemplateWizard.java:591)
	at org.openide.loaders.TemplateWizard.instantiateNewObjects(TemplateWizard.java:412)
	at org.openide.loaders.TemplateWizardIterImpl.instantiate(TemplateWizardIterImpl.java:256)
	at org.openide.loaders.TemplateWizardIteratorWrapper.instantiate(TemplateWizardIteratorWrapper.java:168)
	at org.openide.WizardDescriptor.callInstantiateOpen(WizardDescriptor.java:1541)
	at org.openide.WizardDescriptor.callInstantiate(WizardDescriptor.java:1498)
	at org.openide.WizardDescriptor.access$1700(WizardDescriptor.java:130)
	at org.openide.WizardDescriptor$Listener$2$1.run(WizardDescriptor.java:2069)
	at org.openide.util.RequestProcessor$Task.run(RequestProcessor.java:1418)
	at org.openide.util.RequestProcessor$Processor.run(RequestProcessor.java:1957)
Caused by: java.lang.ClassNotFoundException: org.hibernate.hql.classic.ClassicQueryTransactionFactory starting from ModuleCL@d20759b[org.netbeans.modules.hibernatelib] with possible defining loaders [ModuleCL@d20759b[org.netbeans.modules.hibernatelib]] and declared parents [ModuleCL@2af6a882[org.netbeans.libs.freemarker], ModuleCL@6070c38c[org.netbeans.libs.commons_logging]]
	at org.netbeans.ProxyClassLoader.loadClass(ProxyClassLoader.java:264)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
	at java.lang.Class.forName0(Native Method)
	at java.lang.Class.forName(Class.java:169)
	at org.hibernate.util.ReflectHelper.classForName(ReflectHelper.java:100)
	at org.hibernate.cfg.SettingsFactory.createQueryTranslatorFactory(SettingsFactory.java:388)
	... 16 more
Caused by: java.lang.ClassNotFoundException: org.hibernate.hql.classic.ClassicQueryTransactionFactory
	at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
	at org.netbeans.ProxyClassLoader.loadClass(ProxyClassLoader.java:262)
	... 21 more


Removing the hibernate.query.factory_class property setting from the hibernate.cfg.xml file caused the POJO's to be generated properly.