-create hibernate project in Eclipse
-enable Hibernate support
-create valid hibernate.cfg
-import the project to netbeans
-ERROR: hibernate framework is not recognized in imported project
Btw. what hibernate plugin are you using in Eclipse? Fresh Eclipse does not have any support for Hibernate.
You need to install the plugin for the Hibernate. Don't remember where I got it. Must be from somewhere on the
It is because the .cfg.xml is not in the excepcted location - src root (src/java). Currently, we look for any .cfg.xml
under src root to determine if Hibernate framework is included in the project. Eclipse seems to let the user put the cfg
file anywhere they want, not just the src directory. I don't know how this works for them. But it seems to be a problem
dongmeic, in worst case scenario we could do something similar to what we did for persistence.xml - eclipse importer
will find a .cfg.xml file and update a NetBeans property. Btw. where does Eclipse place the files?
When you create a new cfg.xml file in Eclipse, it ask you to specify the location. From what I can tell, it can be
anywhere in the project. And you can have more than one cfg file in one project and they can be in different locations.
Also, to install the hibernate plugin, follow http://www.hibernate.org/hib_docs/tools/reference/en/html/setup.html
I don't think anything needs to be fixed here (what do you think, Vadiraj?). Here are the difference scenarios:
- If the .cfg.xml file is in the src root, the Hibernate framework is recognized just fine.
- If the .cfg.xml is in src, but not at src root, the Hibernate framework is not recognized. But this is not an import
project issue. It is a general issue of how we recognize the Hibernate framework in the project. See issue 145464 - desc 14.
- If the .cfg.xml is not in the src, the framework is not recognized. But I don't think this is an issue. The cfg files
should be in the src. According to Hibernate spec, cfg files need to be on classpath.
Re. "I don't think anything needs to be fixed" - in this particular test case I tend to agree. I just wonder how Eclipse
project can work if config file is not in a package root. That I think would be worth to investigate.
Aside from this issue, as you probably know, Hibernate is quite flexible when it comes to configuration and there are
options of not using XML config file at all and use programmatic way instead. Or you can programatically load XML
configuration file from any location and file can have any name.
Will re-look in 7.0
Do you have a pointer to the Hibernate documentation which says that hibernate.cfg must be in src/java? It makes sense
that this requirements is important at runtime, but do people really also do this at development time? Often people use
some obscure 'conf' directories and then use Ant script to copy them to the Java source root at build time. I am not a
fan of this approach, but it may not be too uncommon.
According to some comments it looks as a candidate to close as won't fix.
We may not support any location for eclipselink project as if we wil move to some recognized by importer, it may break some other dependencies, but we also do not work with custom location outside of src, it's our limitation If I've got it right (may be based on required/preferred way hibernate specification state)
if anybody have smth to add, feel free, but I'm closing now