-
1. Re: How to reverse engineer tables from multiple schemas?
wouterhartog Jan 7, 2010 5:26 PM (in response to wouterhartog)One correction to my post above: the java class is annotated with the right table name AND catalog name.
E.g. @Table(name = "user", catalog = "maintenance")
So that's good, if I would have tables from multiple schemas, there should be no confusion where the class is mapped to.
Question remains how I can reverse engineer from multiple schemas / catalogs from MySQL.
-
2. Re: How to reverse engineer tables from multiple schemas?
dgolovin Jan 11, 2010 1:17 PM (in response to wouterhartog)Looks like reverse engineering strategy definition could help. Here is the link http://docs.jboss.org/tools/3.1.0.CR1/en/hibernatetools/html/reverseengineering.html.1 of 1 people found this helpful -
3. Re: How to reverse engineer tables from multiple schemas?
maxandersen Jan 13, 2010 5:19 PM (in response to wouterhartog)1 of 1 people found this helpfulhibernate tools were actually built from day 1 to support multiple schemas and catalogs so unless you are doing something unexpected or we got a new bug then it should "just work".
btw. As far as I recall mysql doesn't actually really have schemas or at least it doesn't report them as such in jdbc metadata.
Could you please show your config and properties that you use ? (btw. datasource is irrelevant since hibernate tools doesn't use that since we are not running inside the appserver)
-
4. Re: How to reverse engineer tables from multiple schemas?
dgolovin Jan 13, 2010 7:54 PM (in response to maxandersen)Here is DTP issue for reference https://bugs.eclipse.org/bugs/show_bug.cgi?id=249013 MySQL: catalogs and schemas inconsistent with other vendorsit it says in first paragraph of description:
Using MySQL 5.0.41, Database.getCatalogs() returns an empty list; while
Database.getSchemas() returns a list with a single Schema that has the same
name as the Database. This Schema contains the Database's Tables. -
5. Re: How to reverse engineer tables from multiple schemas?
wouterhartog Jan 15, 2010 1:24 PM (in response to maxandersen)Thanks to the replies from Denis and Max, I tried a few more things and got it to work now.The issue was with the hibernate.reveng.xml file.Based on what the wizard created, I had just this in in the reveng.xml file:<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE hibernate-reverse-engineering PUBLIC "-//Hibernate/Hibernate Reverse Engineering DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-reverse-engineering-3.0.dtd" ><hibernate-reverse-engineering><table-filter match-schema="maintenance" match-name=".*"/><table-filter match-schema="consultant_db" match-name=".*"/></hibernate-reverse-engineering>I also changed the 'match-schema' attribute to 'match-catalog', but that didn't help.However, when I changed it to the following, it worked fine:<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE hibernate-reverse-engineering PUBLIC "-//Hibernate/Hibernate Reverse Engineering DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-reverse-engineering-3.0.dtd" ><hibernate-reverse-engineering><schema-selection match-catalog="maintenance" /><schema-selection match-catalog="consultant_db" /></hibernate-reverse-engineering>In other words, just using 'table-filter' doesn't make it look at different catalogs/ databases in MySQL, but the 'schema-selection' element does.I think this is quite acceptable for how it works.However, the Hibernate reverse engineering editor can perhaps be improved:- How can we get multiple schemas to show up in the wizard? It looks like the wizard looks at the hibernate.connection.url property in the hibernate-console.properties file. However, when I leave out the name of the database (e.g. jdbc:mysql://localhost:3306) without the database, the wizard does not return any tables.- The wizard could have an extra tab at the bottom where you can select the schemas/ catalogs you want, effectively creating the <schema-selection ...> tagsThank you! -
6. Re: How to reverse engineer tables from multiple schemas?
wouterhartog Jan 15, 2010 1:25 PM (in response to wouterhartog)as written in my last post:
use <schema-selection ..> in the reveng.xml file.
-
7. Re: How to reverse engineer tables from multiple schemas?
maxandersen Jan 18, 2010 5:29 AM (in response to wouterhartog)the issue is most likely affected by how mysql views schema and catalog based on your jdbc url and then return it to the jdbc metadata.
feel free to add jira for the various enhancements you suggested.