Problems with Hibernate facet and MySQL

In our project we use Spring, Hibernate and MySQL. When I turn on the Hibernate facet I run into problems with IDEA not being able to locate my database schemas.

In MySQL we hav several schemas (schema_a and schema_b) with multiple tables in each one of them. Some of our entities are stored in tables in schema_a and others in tables in schema_b.

@Table(name="table_a" schema="schema_a")
public class A implements Serializable {
private Long id;

@Table(name="table_b" schema="schema_b")
public class B implements Serializable {
private Long id;

In Spring, our data source is configureed using the MySQL JDBC URL "jdbc:mysql://localhost/schema_a". MySQL seems to require a schema name to be provided in the JDBC URL to connect, although this doesn't have to be the schema name used all the time when reading and writing to the database through the connection. For example, there is no problem for Hibernate to read and write B entities through this data source, despite the fact theat B entities are stored in schema_b. The @Table(name="table_b" schema="schema_b") seems to do the trick.

In IDEA however this is a problem.

In Tools->Data Sources... I can create a data source with the above JDBC URL, but it will only load table information from schema_a. This seems natural, since I specified the schema in the URL.

However, if I leave the schema name out from the URL, using "jdbc:mysql://localhost/" I get the error message from IDEA "Connection was successful. However, no tables were retrieved. Maybe changing 'Schema Name' would help.". But chaning the Schema Name makes no difference. I have tried with empty, "*", "schema_a" and "schema_b" and they all give the exact same error message.

The only way I can get IDEA to load the table information from MySQL is by providing the schema name in the URL, but then only data from one schema is loaded.

This seems to lead to two problems for the Hibernate facet.

1) IDEA complains about not being able to resolve the schema part in @Table(name="table_a" schema="schema_a"). It's the same for entities using schema_b.

2) IDEA is not able to resolve any column names in any entities. This is the same for entities using schema_a and schema_b, although the JDBC URL points to the schema_a and all the tables from schema_a have been loaded in IDEA's data source.

So, for us the Hibernate facet is useless right now. What can I do to make it work for us?

At the present we are using Diana build 8823.

Edited by: Jan Grape on Sep 24, 2008 11:05 AM

1 comment
Comment actions Permalink

Hello Jan,

AFAIU, this is not the problem of Hibernate facet, but the problem of IDEA
data sources. IDEA cannot retrieve tables from a data source by "short" URL
Thank you for this feedback, I have created an issue:



Please sign in to leave a comment.