Package com.mysema.query.sql.codegen

Examples of com.mysema.query.sql.codegen.KeyDataFactory


                + "survey_name varchar(30), "
                + "CONSTRAINT PK_employee PRIMARY KEY (id), "
                + "CONSTRAINT FK_survey FOREIGN KEY (survey_id, survey_name) REFERENCES survey(id,name), "
                + "CONSTRAINT FK_superior FOREIGN KEY (superior_id) REFERENCES employee(id))");
       
        KeyDataFactory keyDataFactory = new KeyDataFactory(new DefaultNamingStrategy(), "Q","","test", false);
       
        DatabaseMetaData md = connection.getMetaData();
       
        // EMPLOYEE
       
        // primary key
        Map<String, PrimaryKeyData> primaryKeys = keyDataFactory.getPrimaryKeys(md, null, null, "EMPLOYEE");
        assertFalse(primaryKeys.isEmpty());
        // inverse foreign keys
        Map<String, InverseForeignKeyData> exportedKeys = keyDataFactory.getExportedKeys(md, null, null, "EMPLOYEE");
        assertFalse(exportedKeys.isEmpty());
        assertTrue(exportedKeys.containsKey("FK_SUPERIOR"));
        // foreign keys
        Map<String, ForeignKeyData> importedKeys = keyDataFactory.getImportedKeys(md, null, null, "EMPLOYEE");
        assertFalse(importedKeys.isEmpty());
        assertTrue(importedKeys.containsKey("FK_SUPERIOR"));
        assertTrue(importedKeys.containsKey("FK_SURVEY"));
       
        // SURVEY
       
        // primary key
        primaryKeys = keyDataFactory.getPrimaryKeys(md, null, null, "SURVEY");
        assertFalse(primaryKeys.isEmpty());
        // inverse foreign keys
        exportedKeys = keyDataFactory.getExportedKeys(md, null, null, "SURVEY");
        assertFalse(exportedKeys.isEmpty());
        assertTrue(exportedKeys.containsKey("FK_SURVEY"));
        // foreign keys
        importedKeys = keyDataFactory.getImportedKeys(md, null, null, "SURVEY");
        assertTrue(importedKeys.isEmpty());
       
    }
View Full Code Here

TOP

Related Classes of com.mysema.query.sql.codegen.KeyDataFactory

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.