[#1816] Add support for materialized views in Oracle's code generator

This commit is contained in:
Lukas Eder 2012-09-22 14:15:06 +02:00
parent 024b3e4913
commit 0640efc113
23 changed files with 170 additions and 49 deletions

View File

@ -39,6 +39,7 @@ package org.jooq.util.oracle;
import static org.jooq.util.oracle.sys.Tables.ALL_COLL_TYPES;
import static org.jooq.util.oracle.sys.Tables.ALL_CONSTRAINTS;
import static org.jooq.util.oracle.sys.Tables.ALL_CONS_COLUMNS;
import static org.jooq.util.oracle.sys.Tables.ALL_MVIEW_COMMENTS;
import static org.jooq.util.oracle.sys.Tables.ALL_OBJECTS;
import static org.jooq.util.oracle.sys.Tables.ALL_PROCEDURES;
import static org.jooq.util.oracle.sys.Tables.ALL_SEQUENCES;
@ -228,17 +229,26 @@ public class OracleDatabase extends AbstractDatabase {
protected List<TableDefinition> getTables0() throws SQLException {
List<TableDefinition> result = new ArrayList<TableDefinition>();
for (Record record : create().select(
ALL_TAB_COMMENTS.OWNER,
ALL_TAB_COMMENTS.TABLE_NAME,
ALL_TAB_COMMENTS.COMMENTS)
.from(ALL_TAB_COMMENTS)
.where(ALL_TAB_COMMENTS.OWNER.upper().in(getInputSchemata()))
.and(ALL_TAB_COMMENTS.TABLE_NAME.notLike("%$%"))
.orderBy(
ALL_TAB_COMMENTS.OWNER,
ALL_TAB_COMMENTS.TABLE_NAME)
.fetch()) {
for (Record record : create()
.select()
.from(create()
.select(
ALL_TAB_COMMENTS.OWNER,
ALL_TAB_COMMENTS.TABLE_NAME,
ALL_TAB_COMMENTS.COMMENTS)
.from(ALL_TAB_COMMENTS)
.where(ALL_TAB_COMMENTS.OWNER.upper().in(getInputSchemata()))
.and(ALL_TAB_COMMENTS.TABLE_NAME.notLike("%$%"))
.unionAll(create()
.select(
ALL_MVIEW_COMMENTS.OWNER,
ALL_MVIEW_COMMENTS.MVIEW_NAME,
ALL_MVIEW_COMMENTS.COMMENTS)
.from(ALL_MVIEW_COMMENTS)
.where(ALL_MVIEW_COMMENTS.OWNER.upper().in(getInputSchemata()))
.and(ALL_MVIEW_COMMENTS.MVIEW_NAME.notLike("%$%"))))
.orderBy(1, 2)
.fetch()) {
SchemaDefinition schema = getSchema(record.getValue(ALL_TAB_COMMENTS.OWNER));
String name = record.getValue(ALL_TAB_COMMENTS.TABLE_NAME);

View File

@ -6,11 +6,12 @@ package org.jooq.util.oracle.sys;
/**
* This class is generated by jOOQ.
*/
@javax.annotation.Generated(value = {"http://www.jooq.org", "2.5.0"},
@javax.annotation.Generated(value = {"http://www.jooq.org", "2.6.0"},
comments = "This class is generated by jOOQ")
@java.lang.SuppressWarnings("all")
public class Sys extends org.jooq.impl.SchemaImpl {
private static final long serialVersionUID = 1034882639;
private static final long serialVersionUID = -999493924;
/**
* The singleton instance of SYS
@ -32,6 +33,7 @@ public class Sys extends org.jooq.impl.SchemaImpl {
org.jooq.util.oracle.sys.tables.AllCollTypes.ALL_COLL_TYPES,
org.jooq.util.oracle.sys.tables.AllConsColumns.ALL_CONS_COLUMNS,
org.jooq.util.oracle.sys.tables.AllConstraints.ALL_CONSTRAINTS,
org.jooq.util.oracle.sys.tables.AllMviewComments.ALL_MVIEW_COMMENTS,
org.jooq.util.oracle.sys.tables.AllObjects.ALL_OBJECTS,
org.jooq.util.oracle.sys.tables.AllProcedures.ALL_PROCEDURES,
org.jooq.util.oracle.sys.tables.AllSequences.ALL_SEQUENCES,

View File

@ -14,11 +14,12 @@ package org.jooq.util.oracle.sys;
* or the {@link org.jooq.impl.Factory} instead, if you want to fully qualify
* tables, routines, etc.
*/
@javax.annotation.Generated(value = {"http://www.jooq.org", "2.5.0"},
@javax.annotation.Generated(value = {"http://www.jooq.org", "2.6.0"},
comments = "This class is generated by jOOQ")
@java.lang.SuppressWarnings("all")
public class SysFactory extends org.jooq.util.oracle.OracleFactory {
private static final long serialVersionUID = 44512269;
private static final long serialVersionUID = -450820231;
/**
* Create a factory with a connection
@ -31,6 +32,17 @@ public class SysFactory extends org.jooq.util.oracle.OracleFactory {
initDefaultSchema();
}
/**
* Create a factory with a data source
*
* @param dataSource The data source to use with objects created from this factory
*/
public SysFactory(javax.sql.DataSource dataSource) {
super(dataSource);
initDefaultSchema();
}
/**
* Create a factory with a connection and some settings
*
@ -43,6 +55,18 @@ public class SysFactory extends org.jooq.util.oracle.OracleFactory {
initDefaultSchema();
}
/**
* Create a factory with a data source and some settings
*
* @param dataSource The data source to use with objects created from this factory
* @param settings The settings to apply to objects created from this factory
*/
public SysFactory(javax.sql.DataSource dataSource, org.jooq.conf.Settings settings) {
super(dataSource, settings);
initDefaultSchema();
}
/**
* Initialise the render mapping's default schema.
* <p>

View File

@ -8,8 +8,9 @@ package org.jooq.util.oracle.sys;
*
* Convenience access to all tables in SYS
*/
@javax.annotation.Generated(value = {"http://www.jooq.org", "2.5.0"},
@javax.annotation.Generated(value = {"http://www.jooq.org", "2.6.0"},
comments = "This class is generated by jOOQ")
@java.lang.SuppressWarnings("all")
public final class Tables {
/**
@ -37,6 +38,11 @@ public final class Tables {
*/
public static final org.jooq.util.oracle.sys.tables.AllConstraints ALL_CONSTRAINTS = org.jooq.util.oracle.sys.tables.AllConstraints.ALL_CONSTRAINTS;
/**
* Comments on materialized views accessible to the user
*/
public static final org.jooq.util.oracle.sys.tables.AllMviewComments ALL_MVIEW_COMMENTS = org.jooq.util.oracle.sys.tables.AllMviewComments.ALL_MVIEW_COMMENTS;
/**
* Objects accessible to the user
*/

View File

@ -8,11 +8,12 @@ package org.jooq.util.oracle.sys.tables;
*
* Arguments in object accessible to the user
*/
@javax.annotation.Generated(value = {"http://www.jooq.org", "2.5.0"},
@javax.annotation.Generated(value = {"http://www.jooq.org", "2.6.0"},
comments = "This class is generated by jOOQ")
@java.lang.SuppressWarnings("all")
public class AllArguments extends org.jooq.impl.TableImpl<org.jooq.Record> {
private static final long serialVersionUID = 764265368;
private static final long serialVersionUID = 19658281;
/**
* The singleton instance of SYS.ALL_ARGUMENTS

View File

@ -8,11 +8,12 @@ package org.jooq.util.oracle.sys.tables;
*
* Comments on columns of accessible tables and views
*/
@javax.annotation.Generated(value = {"http://www.jooq.org", "2.5.0"},
@javax.annotation.Generated(value = {"http://www.jooq.org", "2.6.0"},
comments = "This class is generated by jOOQ")
@java.lang.SuppressWarnings("all")
public class AllColComments extends org.jooq.impl.TableImpl<org.jooq.Record> {
private static final long serialVersionUID = 980924268;
private static final long serialVersionUID = 1390108865;
/**
* The singleton instance of SYS.ALL_COL_COMMENTS

View File

@ -8,11 +8,12 @@ package org.jooq.util.oracle.sys.tables;
*
* Description of named collection types accessible to the user
*/
@javax.annotation.Generated(value = {"http://www.jooq.org", "2.5.0"},
@javax.annotation.Generated(value = {"http://www.jooq.org", "2.6.0"},
comments = "This class is generated by jOOQ")
@java.lang.SuppressWarnings("all")
public class AllCollTypes extends org.jooq.impl.TableImpl<org.jooq.Record> {
private static final long serialVersionUID = 295646347;
private static final long serialVersionUID = -776642910;
/**
* The singleton instance of SYS.ALL_COLL_TYPES

View File

@ -8,11 +8,12 @@ package org.jooq.util.oracle.sys.tables;
*
* Information about accessible columns in constraint definitions
*/
@javax.annotation.Generated(value = {"http://www.jooq.org", "2.5.0"},
@javax.annotation.Generated(value = {"http://www.jooq.org", "2.6.0"},
comments = "This class is generated by jOOQ")
@java.lang.SuppressWarnings("all")
public class AllConsColumns extends org.jooq.impl.TableImpl<org.jooq.Record> {
private static final long serialVersionUID = -235970741;
private static final long serialVersionUID = -618886444;
/**
* The singleton instance of SYS.ALL_CONS_COLUMNS

View File

@ -8,11 +8,12 @@ package org.jooq.util.oracle.sys.tables;
*
* Constraint definitions on accessible tables
*/
@javax.annotation.Generated(value = {"http://www.jooq.org", "2.5.0"},
@javax.annotation.Generated(value = {"http://www.jooq.org", "2.6.0"},
comments = "This class is generated by jOOQ")
@java.lang.SuppressWarnings("all")
public class AllConstraints extends org.jooq.impl.TableImpl<org.jooq.Record> {
private static final long serialVersionUID = -1286861428;
private static final long serialVersionUID = 2083390711;
/**
* The singleton instance of SYS.ALL_CONSTRAINTS

View File

@ -0,0 +1,58 @@
/**
* This class is generated by jOOQ
*/
package org.jooq.util.oracle.sys.tables;
/**
* This class is generated by jOOQ.
*
* Comments on materialized views accessible to the user
*/
@javax.annotation.Generated(value = {"http://www.jooq.org", "2.6.0"},
comments = "This class is generated by jOOQ")
@java.lang.SuppressWarnings("all")
public class AllMviewComments extends org.jooq.impl.TableImpl<org.jooq.Record> {
private static final long serialVersionUID = 104990886;
/**
* The singleton instance of SYS.ALL_MVIEW_COMMENTS
*/
public static final org.jooq.util.oracle.sys.tables.AllMviewComments ALL_MVIEW_COMMENTS = new org.jooq.util.oracle.sys.tables.AllMviewComments();
/**
* The class holding records for this type
*/
@Override
public java.lang.Class<org.jooq.Record> getRecordType() {
return org.jooq.Record.class;
}
/**
* Owner of the materialized view
*/
public final org.jooq.TableField<org.jooq.Record, java.lang.String> OWNER = createField("OWNER", org.jooq.impl.SQLDataType.VARCHAR, this);
/**
* Name of the materialized view
*/
public final org.jooq.TableField<org.jooq.Record, java.lang.String> MVIEW_NAME = createField("MVIEW_NAME", org.jooq.impl.SQLDataType.VARCHAR, this);
/**
* Comment on the materialized view
*/
public final org.jooq.TableField<org.jooq.Record, java.lang.String> COMMENTS = createField("COMMENTS", org.jooq.impl.SQLDataType.VARCHAR, this);
public AllMviewComments() {
super("ALL_MVIEW_COMMENTS", org.jooq.util.oracle.sys.Sys.SYS);
}
public AllMviewComments(java.lang.String alias) {
super(alias, org.jooq.util.oracle.sys.Sys.SYS, org.jooq.util.oracle.sys.tables.AllMviewComments.ALL_MVIEW_COMMENTS);
}
@Override
public org.jooq.util.oracle.sys.tables.AllMviewComments as(java.lang.String alias) {
return new org.jooq.util.oracle.sys.tables.AllMviewComments(alias);
}
}

View File

@ -8,11 +8,12 @@ package org.jooq.util.oracle.sys.tables;
*
* Objects accessible to the user
*/
@javax.annotation.Generated(value = {"http://www.jooq.org", "2.5.0"},
@javax.annotation.Generated(value = {"http://www.jooq.org", "2.6.0"},
comments = "This class is generated by jOOQ")
@java.lang.SuppressWarnings("all")
public class AllObjects extends org.jooq.impl.TableImpl<org.jooq.Record> {
private static final long serialVersionUID = 1730149793;
private static final long serialVersionUID = -233201624;
/**
* The singleton instance of SYS.ALL_OBJECTS

View File

@ -8,11 +8,12 @@ package org.jooq.util.oracle.sys.tables;
*
* Functions/procedures/packages/types/triggers available to the user
*/
@javax.annotation.Generated(value = {"http://www.jooq.org", "2.5.0"},
@javax.annotation.Generated(value = {"http://www.jooq.org", "2.6.0"},
comments = "This class is generated by jOOQ")
@java.lang.SuppressWarnings("all")
public class AllProcedures extends org.jooq.impl.TableImpl<org.jooq.Record> {
private static final long serialVersionUID = -814913983;
private static final long serialVersionUID = -1243506052;
/**
* The singleton instance of SYS.ALL_PROCEDURES

View File

@ -8,11 +8,12 @@ package org.jooq.util.oracle.sys.tables;
*
* Description of SEQUENCEs accessible to the user
*/
@javax.annotation.Generated(value = {"http://www.jooq.org", "2.5.0"},
@javax.annotation.Generated(value = {"http://www.jooq.org", "2.6.0"},
comments = "This class is generated by jOOQ")
@java.lang.SuppressWarnings("all")
public class AllSequences extends org.jooq.impl.TableImpl<org.jooq.Record> {
private static final long serialVersionUID = -1173564530;
private static final long serialVersionUID = 1988039943;
/**
* The singleton instance of SYS.ALL_SEQUENCES

View File

@ -8,11 +8,12 @@ package org.jooq.util.oracle.sys.tables;
*
* All synonyms for base objects accessible to the user and session
*/
@javax.annotation.Generated(value = {"http://www.jooq.org", "2.5.0"},
@javax.annotation.Generated(value = {"http://www.jooq.org", "2.6.0"},
comments = "This class is generated by jOOQ")
@java.lang.SuppressWarnings("all")
public class AllSynonyms extends org.jooq.impl.TableImpl<org.jooq.Record> {
private static final long serialVersionUID = 774001568;
private static final long serialVersionUID = -1259455295;
/**
* The singleton instance of SYS.ALL_SYNONYMS

View File

@ -8,11 +8,12 @@ package org.jooq.util.oracle.sys.tables;
*
* Columns of user's tables, views and clusters
*/
@javax.annotation.Generated(value = {"http://www.jooq.org", "2.5.0"},
@javax.annotation.Generated(value = {"http://www.jooq.org", "2.6.0"},
comments = "This class is generated by jOOQ")
@java.lang.SuppressWarnings("all")
public class AllTabCols extends org.jooq.impl.TableImpl<org.jooq.Record> {
private static final long serialVersionUID = 1567775547;
private static final long serialVersionUID = -1793545258;
/**
* The singleton instance of SYS.ALL_TAB_COLS

View File

@ -8,11 +8,12 @@ package org.jooq.util.oracle.sys.tables;
*
* Comments on tables and views accessible to the user
*/
@javax.annotation.Generated(value = {"http://www.jooq.org", "2.5.0"},
@javax.annotation.Generated(value = {"http://www.jooq.org", "2.6.0"},
comments = "This class is generated by jOOQ")
@java.lang.SuppressWarnings("all")
public class AllTabComments extends org.jooq.impl.TableImpl<org.jooq.Record> {
private static final long serialVersionUID = -2057912058;
private static final long serialVersionUID = -1659849199;
/**
* The singleton instance of SYS.ALL_TAB_COMMENTS

View File

@ -8,11 +8,12 @@ package org.jooq.util.oracle.sys.tables;
*
* Description of attributes of types accessible to the user
*/
@javax.annotation.Generated(value = {"http://www.jooq.org", "2.5.0"},
@javax.annotation.Generated(value = {"http://www.jooq.org", "2.6.0"},
comments = "This class is generated by jOOQ")
@java.lang.SuppressWarnings("all")
public class AllTypeAttrs extends org.jooq.impl.TableImpl<org.jooq.Record> {
private static final long serialVersionUID = -269821555;
private static final long serialVersionUID = -825035176;
/**
* The singleton instance of SYS.ALL_TYPE_ATTRS

View File

@ -8,11 +8,12 @@ package org.jooq.util.oracle.sys.tables;
*
* Description of types accessible to the user
*/
@javax.annotation.Generated(value = {"http://www.jooq.org", "2.5.0"},
@javax.annotation.Generated(value = {"http://www.jooq.org", "2.6.0"},
comments = "This class is generated by jOOQ")
@java.lang.SuppressWarnings("all")
public class AllTypes extends org.jooq.impl.TableImpl<org.jooq.Record> {
private static final long serialVersionUID = 1725656432;
private static final long serialVersionUID = -263338629;
/**
* The singleton instance of SYS.ALL_TYPES

View File

@ -8,11 +8,12 @@ package org.jooq.util.oracle.sys.tables;
*
* Information about all users of the database
*/
@javax.annotation.Generated(value = {"http://www.jooq.org", "2.5.0"},
@javax.annotation.Generated(value = {"http://www.jooq.org", "2.6.0"},
comments = "This class is generated by jOOQ")
@java.lang.SuppressWarnings("all")
public class AllUsers extends org.jooq.impl.TableImpl<org.jooq.Record> {
private static final long serialVersionUID = -752288951;
private static final long serialVersionUID = 1282251068;
/**
* The singleton instance of SYS.ALL_USERS

View File

@ -6,11 +6,12 @@ package org.jooq.util.oracle.sys.udt.records;
/**
* This class is generated by jOOQ.
*/
@javax.annotation.Generated(value = {"http://www.jooq.org", "2.5.0"},
@javax.annotation.Generated(value = {"http://www.jooq.org", "2.6.0"},
comments = "This class is generated by jOOQ")
@java.lang.SuppressWarnings("all")
public class OraMiningNumberNtRecord extends org.jooq.impl.ArrayRecordImpl<java.math.BigDecimal> {
private static final long serialVersionUID = 1946791028;
private static final long serialVersionUID = 1952565575;
public OraMiningNumberNtRecord(org.jooq.Configuration configuration) {
super(org.jooq.util.oracle.sys.Sys.SYS, "ORA_MINING_NUMBER_NT", org.jooq.impl.SQLDataType.NUMERIC, configuration);

View File

@ -6,11 +6,12 @@ package org.jooq.util.oracle.sys.udt.records;
/**
* This class is generated by jOOQ.
*/
@javax.annotation.Generated(value = {"http://www.jooq.org", "2.5.0"},
@javax.annotation.Generated(value = {"http://www.jooq.org", "2.6.0"},
comments = "This class is generated by jOOQ")
@java.lang.SuppressWarnings("all")
public class OraMiningVarchar2NtRecord extends org.jooq.impl.ArrayRecordImpl<java.lang.String> {
private static final long serialVersionUID = 144323262;
private static final long serialVersionUID = -1612093359;
public OraMiningVarchar2NtRecord(org.jooq.Configuration configuration) {
super(org.jooq.util.oracle.sys.Sys.SYS, "ORA_MINING_VARCHAR2_NT", org.jooq.impl.SQLDataType.VARCHAR, configuration);

View File

@ -7,7 +7,7 @@ jdbc.Password=TEST
generator=org.jooq.util.DefaultGenerator
generator.database=org.jooq.util.oracle.OracleDatabase
generator.database.includes=ALL_USERS,ALL_TAB_COMMENTS,ALL_TAB_COLS,ALL_COL_COMMENTS,ALL_CONSTRAINTS,ALL_CONS_COLUMNS,ALL_PROCEDURES,ALL_ARGUMENTS,ALL_OBJECTS,ALL_TYPES,ALL_TYPE_ATTRS,ALL_SEQUENCES,ALL_COLL_TYPES,ORA_MINING_NUMBER_NT,ORA_MINING_VARCHAR2_NT,ALL_SYNONYMS
generator.database.includes=ALL_USERS,ALL_TAB_COMMENTS,ALL_MVIEW_COMMENTS,ALL_TAB_COLS,ALL_COL_COMMENTS,ALL_CONSTRAINTS,ALL_CONS_COLUMNS,ALL_PROCEDURES,ALL_ARGUMENTS,ALL_OBJECTS,ALL_TYPES,ALL_TYPE_ATTRS,ALL_SEQUENCES,ALL_COLL_TYPES,ORA_MINING_NUMBER_NT,ORA_MINING_VARCHAR2_NT,ALL_SYNONYMS
generator.database.excludes=
generator.generate.records=false
generator.generate.deprecated=false

View File

@ -1,3 +1,4 @@
DROP MATERIALIZED VIEW m_library/
DROP VIEW v_library/
DROP VIEW v_author/
DROP VIEW v_book/
@ -735,6 +736,10 @@ SELECT a.first_name || ' ' || a.last_name, b.title
FROM t_author a JOIN t_book b ON b.author_id = a.id
/
CREATE MATERIALIZED VIEW m_library REFRESH WITH ROWID AS
SELECT * FROM v_library
/
CREATE VIEW v_author AS
SELECT * FROM t_author
/