New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Generate constructor with var and schema parameters #1877
Comments
Maybe (schema, table, variable) and (schema, table, pathmetadata) could be used instead in addition to the existing (variable) and (pathmetadata) constructors? |
Would you be interested to provide a PR for it? It's mostly customizing this class https://github.com/querydsl/querydsl/blob/master/querydsl-sql-codegen/src/main/java/com/querydsl/sql/codegen/MetaDataSerializer.java |
Before doing anything I've come across a problem when using mysql. For some reason mysql uses catalogs to identify schemes. The sql generator uses "null" for schema. public QMaster(String variable) {
super(Master.class, forVariable(variable), "null", "master");
addMetadata();
}
public QMaster(String variable, String schema, String table) {
super(Master.class, forVariable(variable), schema, table);
addMetadata();
}
public QMaster(Path<? extends Master> path) {
super(path.getType(), path.getMetadata(), "null", "master");
addMetadata();
}
public QMaster(PathMetadata metadata) {
super(Master.class, metadata, "null", "master");
addMetadata();
}
public void addMetadata() {
addMetadata(masterId, ColumnMetadata.named("master_id").withIndex(1).ofType(Types.INTEGER).withSize(10).notNull());
addMetadata(name, ColumnMetadata.named("name").withIndex(2).ofType(Types.VARCHAR).withSize(45).notNull());
} Another problem is that <configuration>
<schemaPattern>master,client_1</schemaPattern>
<jdbcDriver>com.mysql.jdbc.Driver</jdbcDriver>
<jdbcUrl>jdbc:mysql://127.0.0.1:3306?useSSL=false</jdbcUrl>
<jdbcUser>root</jdbcUser>
<jdbcPassword>root123</jdbcPassword>
<packageName>com.github.natros.querydsl.entities</packageName>
<targetFolder>${project.basedir}/target/generated-sources/java</targetFolder>
<schemaToPackage>true</schemaToPackage>
<exportBeans>true</exportBeans>
</configuration> I'm testing with
|
Hello, Is there a way to make schemaToPackage working with mysql? |
This is for the case where each customer has its own database with the same strucure using a single connection. Fixes querydsl#1877
I have a scenario where the database (mysql) is composed of a master schema and a schema for each client. The tables in each schema have the same structure.
I guess the solution is to construct the Q types with the schema
My work would be simplified if I had a constructor with only the variable and the schema:
Using QueryDSL SQL 4.1.0
The text was updated successfully, but these errors were encountered: