-
1. JPA reverse engineer & MySQL
maxandersen Apr 28, 2011 3:45 AM (in response to ericjvandervelden)hmm - sounds like a bug in mysql reverse engineering....
Might be related to https://issues.jboss.org/browse/JBIDE-7488 fix
Workaround set hibernate.default_catalog="sample2" and you should not get any mentions of catalog in your reverse engineering.
-
2. Re: JPA reverse engineer & MySQL
dgeraskov Apr 28, 2011 7:30 AM (in response to maxandersen)could you please check the validation with @Table(name = "F", schema= "sample2", catalog= "sample2")
I guess hibernate tool doesn't add schema as consider it as default.
(In url you have something jdbc:mysql://localhost:3306/?nullCatalogMeansCurrent=false)
where mymysql is schema and you don't need to override it.
Does hibernate work with generated annotation:
@Table(name = "F", catalog= "sample2")
or with updated
@Table(name = "F", schema= "sample2")?
Please check also
@Table(name = "F", schema= "sample2", catalog= "sample2")
-
3. Re: JPA reverse engineer & MySQL
dgeraskov Apr 28, 2011 5:58 AM (in response to dgeraskov)I ask this because it could be a problem of the validator, but not hibernate tools.
-
4. Re: JPA reverse engineer & MySQL
dgeraskov Apr 28, 2011 7:29 AM (in response to dgeraskov)Eric,
we checked this ourself. The hibernate works well with @Table(name = "F", catalog= "sample2") and one of the folowwing:
1) jdbc:mysql://localhost:3306/?nullCatalogMeansCurrent=false
2) jdbc:mysql://localhost:3306/sample2
3) jdbc:mysql://localhost:3306/ hibernate.default_catalog=sample2
sample2
@Table(name = "F", schema= "sample2") works in the cases:
1) jdbc:mysql://localhost:3306/?nullCatalogMeansCurrent=false
2) jdbc:mysql://localhost:3306/sample2
3) jdbc:mysql://localhost:3306/ hibernate.default_schema=sample2
The jpa validator is not consistent in some cases
-
5. Re: JPA reverse engineer & MySQL
reskejal Apr 19, 2013 7:06 PM (in response to ericjvandervelden)Any news about this topic??
I have the same problem with stable release of jboss developer studio (6.0).
In my case the error is only for the validator because i can use the genereted class without problem.
i'm also able to fix the error but i need remove manually the catalog definition and have an annotation like this
@Table(name = "F")
and default values (in JPA property windows) are "Default" for catalog and "Default (sample2)" for schema
Also with this fix my project work.
In jboss dev studio i have a Database Connection like jdbc:mysql://localhost:3306/sample2
while on AS and in persistence.xml use data source with jta (connection string is always like jdbc:mysql://localhost:3306/sample2)
Is there a way to not generate the catalog attribute in annotation ??
Thanks.
-
6. Re: JPA reverse engineer & MySQL
gerry.matte Apr 20, 2013 2:08 AM (in response to maxandersen)This behavior has been standard for MySQL and hibernate from the beginning. I belive the MySQL driver interprets a database schema the same as an Oracle catalog .... but a MySQL catalog has subtle differences from a schema and does not play well with hibernate.
My standard fix up (workaround) is to immediately remove the catalog property. I most frequently use Forge to reverse engineer and generate a CRUD webapp ..... so it's become routine for me. Thanks to Eric for reporting the issue .... I should have done so long ago.
-
7. Re: JPA reverse engineer & MySQL
maxandersen Apr 22, 2013 3:41 AM (in response to reskejal)set hibernate.default_catalog and hibernate.default_schema and the reverse engineering will obey that and remove it.
If someone know of a way to reliably know from a jdbc connection which schema/catalog is the default then we could avoid this, but I haven't found a way that is sane.
-
8. Re: JPA reverse engineer & MySQL
reskejal Apr 22, 2013 4:26 PM (in response to ericjvandervelden)Thanks for yours suggestions!
@Gerry many thanks...Forge its a great project.
@Max i try to set these properties in persistence.xml and in the optional parameters of the database connection..but with no luck, i have always the catalog annotation
-
9. Re: JPA reverse engineer & MySQL
maxandersen Apr 25, 2013 6:38 AM (in response to reskejal)hmm - it should just work.
Can you show me the generated code and the persistence.xml you are using ?