Re: Strange behavior when using MetaDataExporter with Oracle

197 views
Skip to first unread message

Timo Westkämper

unread,
Dec 10, 2012, 8:13:36 AM12/10/12
to Querydsl on behalf of Christian Lipp
Hi.

Did you verify that the Java class names are also returned if you use DatabaseMetaData directly?

metadata = conn.getMetadata();
results = metadata.getTables(...)

I haven't experienced this behaviour before.

Br,
Timo

On Mon, Dec 10, 2012 at 2:56 PM, Christian Lipp via Querydsl <querydsl+noreply-APn2wQe_8HM4021...@googlegroups.com> wrote:
I am using a Oracle 9.2.0.5 database and have to access the database with plain JDBC.
In my vision I want to use Spring Data JDBC Extensions with Querydsl for SQL.

But even the first steps aren't working, the code generation. When I use the MetaDataExporter to export the schema following the blog entry http://blog.mysema.com/2011/01/querying-in-sql-with-querydsl.html the exporter is logging the following lines:

[2012-12-10 13:50:35,872] INFO main - com.mysema.query.sql.codegen.MetaDataExporter.handleTable(302) - Exported /1005bd30_LnkdConstant successfully
[2012-12-10 13:50:35,947] INFO main - com.mysema.query.sql.codegen.MetaDataExporter.handleTable(302) - Exported /10076b23_OraCustomDatumClosur successfully
[2012-12-10 13:50:36,020] INFO main - com.mysema.query.sql.codegen.MetaDataExporter.handleTable(302) - Exported /1025308f_SunTileScheduler successfully
[2012-12-10 13:50:36,091] INFO main - com.mysema.query.sql.codegen.MetaDataExporter.handleTable(302) - Exported /10297c91_SAXAttrList successfully
[2012-12-10 13:50:36,160] INFO main - com.mysema.query.sql.codegen.MetaDataExporter.handleTable(302) - Exported /103a2e73_DefaultEditorKitEndP successfully
[2012-12-10 13:50:36,231] INFO main - com.mysema.query.sql.codegen.MetaDataExporter.handleTable(302) - Exported /1048734f_DefaultFolder successfully
...

This never stops, it generates source code for all my Java classes in Memory. My code is as simple as:

package my.package;

import java.io.File;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

import com.mysema.query.sql.codegen.MetaDataExporter;

public class QueryDslExporter
{
public static void main(String[] args) throws SQLException
{
   DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
   String url = "jdbc:oracle:thin:@10.1.1.173:1521:xxx";
   Connection conn = DriverManager.getConnection(url, "xxx", "xxx");
MetaDataExporter exporter = new MetaDataExporter();
exporter.setPackageName("my.package.domain");
exporter.setTargetFolder(new File("src/main/java"));
exporter.export(conn.getMetaData());
}
}

Dependencies are:

<properties>
<querydsl.version>2.9.0</querydsl.version>
</properties>

<dependencies>
<dependency>
<groupId>com.mysema.querydsl</groupId>
<artifactId>querydsl-sql</artifactId>
<version>${querydsl.version}</version>
</dependency>
<dependency>
<groupId>com.mysema.querydsl</groupId>
<artifactId>querydsl-sql-codegen</artifactId>
<version>${querydsl.version}</version>
</dependency>

Did anyone know what is going on?
Kind regards, Christian



--
Timo Westkämper
Mysema Oy
+358 (0)40 591 2172
www.mysema.com



Christian Lipp

unread,
Dec 11, 2012, 4:56:07 AM12/11/12
to quer...@googlegroups.com
Hi,

when I used the following code
   DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
   String url = "jdbc:oracle:thin:@10.1.1.173:1521:XXX";
   connection = DriverManager.getConnection(url, "XXX", "XXX");
   DatabaseMetaData metadata = connection.getMetaData();
   resultSet = metadata.getTables(null, null, null, null);

I got a non empty resultSet containing the (correct) system tables. Since this is not what I wanted, I provided explicitely my schema:
    resultSet = metadata.getTables(null, "SCHEMA", null, null);
This also worked.

Then I tried to set the schema for the MetaDataExporter and than it worked even with QueryDSL!
   exporter.setSchemaPattern("SCHEMA");

So this tells me that QueryDSL has problems to generate the schema for Oracle 9i system tables.
Thanks for your help,
Christian


Am Montag, 10. Dezember 2012 14:13:36 UTC+1 schrieb Timo Westkämper:
Hi.

Did you verify that the Java class names are also returned if you use DatabaseMetaData directly?

metadata = conn.getMetadata();
results = metadata.getTables(...)

I haven't experienced this behaviour before.

Br,
Timo

Timo Westkämper

unread,
Dec 11, 2012, 5:02:00 AM12/11/12
to Querydsl on behalf of Christian Lipp
Hi.

On Tue, Dec 11, 2012 at 11:56 AM, Christian Lipp via Querydsl <querydsl+noreply-APn2wQe_8HM4021...@googlegroups.com> wrote:
Hi,

when I used the following code
   DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
   String url = "jdbc:oracle:thin:@10.1.1.173:1521:XXX";
   connection = DriverManager.getConnection(url, "XXX", "XXX");
   DatabaseMetaData metadata = connection.getMetaData();
   resultSet = metadata.getTables(null, null, null, null);

I got a non empty resultSet containing the (correct) system tables.

The result is different from Querydsl?
 
Since this is not what I wanted, I provided explicitely my schema:
    resultSet = metadata.getTables(null, "SCHEMA", null, null);
This also worked.

Then I tried to set the schema for the MetaDataExporter and than it worked even with QueryDSL!
   exporter.setSchemaPattern("SCHEMA");

So this tells me that QueryDSL has problems to generate the schema for Oracle 9i system tables.
Thanks for your help,
Christian

Querydsl uses  metadata.getTables(null, null, null, null); internally, if you don't provide any filters.

Br,
Timo

Christian Lipp

unread,
Dec 12, 2012, 5:55:41 AM12/12/12
to quer...@googlegroups.com
The result for 

   resultSet = metadata.getTables(null, null, null, null);
is not different compared to QueryDSL. The strange objects I was mentioning are visible under Oracle - public synonyms

So it is my fault and everything is working. Sorry!

Kind regards, Christrian

Am Dienstag, 11. Dezember 2012 11:02:00 UTC+1 schrieb timowest:
Hi.

On Mon, Dec 10, 2012 at 2:56 PM, Christian Lipp via Querydsl <querydsl+noreply-APn2wQe_8HM4021XVxNw0zKjLB4ba45fOaeEJJSD5GqP...@googlegroups.com> wrote:
I am using a Oracle 9.2.0.5 database and have to access the database with plain JDBC.
In my vision I want to use Spring Data JDBC Extensions with Querydsl for SQL.

But even the first steps aren't working, the code generation. When I use the MetaDataExporter to export the schema following the blog entry http://blog.mysema.com/2011/01/querying-in-sql-with-querydsl.html the exporter is logging the following lines:

[2012-12-10 13:50:35,872] INFO main - com.mysema.query.sql.codegen.MetaDataExporter.handleTable(302) - Exported /1005bd30_LnkdConstant successfully
[2012-12-10 13:50:35,947] INFO main - com.mysema.query.sql.codegen.MetaDataExporter.handleTable(302) - Exported /10076b23_OraCustomDatumClosur successfully
[2012-12-10 13:50:36,020] INFO main - com.mysema.query.sql.codegen.MetaDataExporter.handleTable(302) - Exported /1025308f_SunTileScheduler successfully
[2012-12-10 13:50:36,091] INFO main - com.mysema.query.sql.codegen.MetaDataExporter.handleTable(302) - Exported /10297c91_SAXAttrList successfully
[2012-12-10 13:50:36,160] INFO main - com.mysema.query.sql.codegen.MetaDataExporter.handleTable(302) - Exported /103a2e73_DefaultEditorKitEndP successfully
[2012-12-10 13:50:36,231] INFO main - com.mysema.query.sql.codegen.MetaDataExporter.handleTable(302) - Exported /1048734f_DefaultFolder successfully
...

This never stops, it generates source code for all my Java classes in Memory. My code is as simple as:

package my.package;

import java.io.File;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

import com.mysema.query.sql.codegen.MetaDataExporter;

public class QueryDslExporter
{
public static void main(String[] args) throws SQLException
{
   DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
   String url = "jdbc:ora...@10.1.1.173:1521:xxx";

Timo Westkämper

unread,
Dec 12, 2012, 5:57:06 AM12/12/12
to Querydsl on behalf of Christian Lipp
Hi.

On Wed, Dec 12, 2012 at 12:55 PM, Christian Lipp via Querydsl <querydsl+noreply-APn2wQe_8HM4021...@googlegroups.com> wrote:
The result for 

   resultSet = metadata.getTables(null, null, null, null);
is not different compared to QueryDSL. The strange objects I was mentioning are visible under Oracle - public synonyms

So it is my fault and everything is working. Sorry!

No need to apologize. I just wanted to make sure that Querydsl doesn't get the strange results from somewhere else.

Br,
Timo
 
Reply all
Reply to author
Forward
0 new messages