-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 6 posts ] 
Author Message
 Post subject: Problems with Middlegen and mySQL.
PostPosted: Tue May 25, 2004 4:32 pm 
Newbie

Joined: Tue May 25, 2004 3:22 pm
Posts: 18
Hi there,

I have a problem getting the relations from mySQL database into Middlegen GUI tool (I want to generate then Hibernate mappings).

I searched through the forums but got no good answer to my problem: some say that using a different JDBC driver would help...

So I have a couple of questions:

1. When I declare an ANT task in my build file for Middlegen like the following:

<target name="middlegen.go" depends="common.init, middlegen.init,fail-if-no-xdoclet-1.2,check-driver-present,panic-if-driver-not-present"
description="Launch Middlegen tool">
<taskdef
name="middlegen"
classname="middlegen.MiddlegenTask"
classpathref="middlegen.path"
/>
<echo>Schema name ${database.schema}</echo>
<middlegen
appname="${name}"
prefsdir="${prefs.dir}"
gui="${gui}"
databaseurl="${database.url}"
initialContextFactory="${java.naming.factory.initial}"
providerURL="${java.naming.provider.url}"
datasourceJNDIName="${datasource.jndi.name}"
driver="${database.driver}"
username="${database.userid}"
password="${database.password}"
schema=""
>

<hibernate destination="${build.gen-src.dir}" package="${name}.hibernate" genXDocletTags="false" genIntergratedCompositeKeys="false" javaTypeMapper="middlegen.plugins.hibernate.HibernateJavaTypeMapper"/>
</middlegen>
<mkdir dir="${build.classes.dir}"/>
</target>


Do I have to declare EXPLICITLY in the Middlegen task the relations between my tables like it's been done in the airline example:


<middlegen
..............................
<!--many2many>
<tablea generate="true" name="persons"/>
<jointable name="reservations" generate="false"/>
<tableb generate="true" name="flights"/>
</many2many-->
..................................
</middlegen>


Or the proper JDBC driver SHOULD determine the relations itself from the database without any help of additional mappings in middlegen task?

2. If I don't have to define EXPLICITLY the relations between my tables in middlegen task in order to see relations in GUI (and I assume the hibernate task would then properly generate mappings), so HOW can I solve my problems with mySQL database?

For test purpose I adjusted airline example for using Hypersonic SQL and it worked fine: I could see the relations in the GUI.

Any help is appreciated.

Thanks in advance,

Igor.


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 25, 2004 7:21 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
Hi,

1) No - Middlegen uses the Constraints defined in the database to show the relationships. I am assuming you have the constraints defined.

2) MySQL is the most probmatic DB as I am getting questions about it regually. Normally it turns out to be a database JDBC driver issue - mainly using beta (non-stable) drivers. Look in this area first.

I would also read the forums since most users were able to solve the problem.

--David.


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 26, 2004 8:20 am 
Newbie

Joined: Tue May 25, 2004 3:22 pm
Posts: 18
Thanks, David.

I got my question answered when I looked into the Supported Platforms -> Databases section at the http://boss.bekk.no/boss/middlegen/plat ... abase.html

Should've read that before!!!

trying to find a remedy to my problem I moved my database to the MSSQL Server 2000 and downloaded the appropriate JDBC driver com.microsoft.jdbc.sqlserver.SQLServerDriver
off Microsoft's site.

But I seem to have another problem so that Middlegen reports that could successfully connects to the database but cannot find any tables in it.

Here's my settings:

<property name="database.script.file" value="D:/Work/GWS/gws.proj/automated/gws.ddl"/>
<property name="database.driver.classpath" value="${middlegen.lib}"/>
<property name="database.driver.file" value="${middlegen.lib}/mssqlserver.jar"/>
<property name="database.driver" value="com.microsoft.jdbc.sqlserver.SQLServerDriver"/>
<property name="database.url" value="jdbc:microsoft:sqlserver://localhost:1433;databasename=gws"/>
<property name="database.userid" value="sa"/>
<property name="database.password" value=""/>
<property name="database.schema" value=""/>
<property name="database.catalog" value=""/>

<property name="jboss.datasource.mapping" value="MS SQLSERVER"/>
<!--property name="jboss.datasource.mapping" value="MS SQLSERVER2000"/-->


What could be wron with that? Do I have to specify a SCHEMA name AND/OR catalog?

Thanks in advance.


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 26, 2004 8:37 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
I use Oracle, MSSQL and develop Middlegen with HSQL. MSSQL (atleast my setup) requires Schema and Catelog. Setting up the JDBC driver on a new DB is almost always a troublesome step.


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 27, 2004 3:27 am 
Newbie

Joined: Tue May 25, 2004 3:22 pm
Posts: 18
Thanks for help!

I was able to generate mappings with all the relations after I used mySQL 4.0.17.
It supports InnoDB by default, there's no need to even make changes to config file to set up mySQL using InnoDB.

The driver I used was in mysql-connector-java-3.0.0-beta-bin.jar that comes with Middlegen.

anyway, thanks for help.


Igor.


Top
 Profile  
 
 Post subject:
PostPosted: Fri May 28, 2004 11:50 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
Gald you were able top work it out.

Cheers David.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 6 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.