Hibernate configured via Spring

I am using 7348 and have a project that uses Spring and Hibernate and have both facets enabled. The web.xml of the project references Database-config.xml in the list of contextConfigLocation. In the Database-config.xml, I have:

classpath*:com/company/biz/dao/hibernate ]]>

In the src directory of the package listed above, I have a fair amount of .hbm.xml files. However, when I go to try to run it in Tomcat and do a Make via IDEA building, I receive errors about not being able to resolve query parameters in some .Java files for queries that are listed in the .hbm.xml files in the directory above. I also see other errors in the source files about being unable to resolve symbols that again are defined in the .hbm.xml files which are configured.

I am thinking that IDEA is not using the configuration to be able to find the hbm.xml files. Is this a bug or is my configuration incorrect?

Thanks,
Steve

5 comments

Hello Steve,

I am using 7348 and have a project that uses Spring and Hibernate and
have both facets enabled. The web.xml of the project references
Database-config.xml in the list of contextConfigLocation. In the
Database-config.xml, I have:

<property name="mappingDirectoryLocations">
<value>classpath*:com/company/biz/dao/hibernate</value>
</property>
In the src directory of the package listed above, I have a fair amount
of .hbm.xml files. However, when I go to try to run it in Tomcat and
do a Make via IDEA building, I receive errors about not being able to
resolve query parameters in some .Java files for queries that are
listed in the .hbm.xml files in the directory above. I also see other
errors in the source files about being unable to resolve symbols that
again are defined in the .hbm.xml files which are configured.

I am thinking that IDEA is not using the configuration to be able to
find the hbm.xml files. Is this a bug or is my configuration
incorrect?


I looks like IDEA does not recognize the "mappingDirectoryLocations" property.
You could try to switch to "mappingLocations" (of course, add a "/*.hbm.xml"
suffix).
It seems a bug, or at least an incomplete feature - please create a JIRA
ticket and post the link here.

Regards,

Taras


0

Created http://www.jetbrains.net/jira/browse/IDEA-15769 . One other question, so I switched to mappingLocations as you suggested and this seemed to pull in the Hibernate configuration files. Now, I get errors that IDEA can not resolve tables and columns in those files. What is IDEA using to validate the tables and columns? Perhaps I am still having issues with some part of my configuration.

Thanks,
Steve

0

Hello Steve,

Created http://www.jetbrains.net/jira/browse/IDEA-15769 . One other
question, so I switched to mappingLocations as you suggested and this
seemed to pull in the Hibernate configuration files. Now, I get errors
that IDEA can not resolve tables and columns in those files. What is
IDEA using to validate the tables and columns? Perhaps I am still
having issues with some part of my configuration.


As TomP mentioned, first you need to define a datasource.
Note that the "DataSources" dialog has an "Import" button. In some cases
IDEA can directly import your DataSource from spring xml.

Second, you need to assign a datasource to use for a specific SessionFactory.
This is done in the configuration screen of the Hibernate facet.
This should resolve the errors you mention (and also give you code completion
for table/column names). I think you can also explicitly disable the inspection
that checks table/column names.

Taras


0

Thanks to both of you. Those steps got me up and running great!

0

Please sign in to leave a comment.