Package org.datanucleus.store.rdbms.schema

Examples of org.datanucleus.store.rdbms.schema.ForeignKeyInfo


        RDBMSTableFKInfo fkInfo = (RDBMSTableFKInfo)handler.getSchemaData(conn, "foreign-keys",
            new Object[] {this});
        Iterator iter = fkInfo.getChildren().iterator();
        while (iter.hasNext())
        {
            ForeignKeyInfo fki = (ForeignKeyInfo)iter.next();
            // JDBC drivers can return null names for foreign keys, so we then skip the DROP CONSTRAINT.
            String fkName = (String)fki.getProperty("fk_name");
            if (fkName != null)
            {
                fkNames.add(fkName);
            }
        }
View Full Code Here


            RDBMSTableFKInfo tableFkInfo = (RDBMSTableFKInfo)handler.getSchemaData(conn, "foreign-keys",
                new Object[] {this});
            Iterator fksIter = tableFkInfo.getChildren().iterator();
            while (fksIter.hasNext())
            {
                ForeignKeyInfo fkInfo = (ForeignKeyInfo)fksIter.next();
                DatastoreIdentifier fkIdentifier;
                String fkName = (String)fkInfo.getProperty("fk_name");
                if (fkName == null)
                {
                    fkIdentifier = idFactory.newForeignKeyIdentifier(this, foreignKeysByName.size());
                }
                else
                {
                    fkIdentifier = idFactory.newIdentifier(IdentifierType.FOREIGN_KEY, fkName);
                }
   
                short deferrability = ((Short)fkInfo.getProperty("deferrability")).shortValue();
                boolean initiallyDeferred = deferrability == DatabaseMetaData.importedKeyInitiallyDeferred;
                ForeignKey fk = (ForeignKey) foreignKeysByName.get(fkIdentifier);
                if (fk == null)
                {
                    fk = new ForeignKey(initiallyDeferred);
                    fk.setName(fkIdentifier.getIdentifierName());
                    foreignKeysByName.put(fkIdentifier, fk);
                }
   
                String pkTableName = (String)fkInfo.getProperty("pk_table_name");
                AbstractTable refTable = (AbstractTable)storeMgr.getDatastoreClass(
                    idFactory.newDatastoreContainerIdentifier(pkTableName));
                if (refTable != null)
                {
                    String fkColumnName = (String)fkInfo.getProperty("fk_column_name");
                    String pkColumnName = (String)fkInfo.getProperty("pk_column_name");
                    DatastoreIdentifier colName = idFactory.newIdentifier(IdentifierType.COLUMN, fkColumnName);
                    DatastoreIdentifier refColName = idFactory.newIdentifier(IdentifierType.COLUMN, pkColumnName);
                    DatastoreField col = columnsByName.get(colName);
                    DatastoreField refCol = refTable.columnsByName.get(refColName);
                    if (col != null && refCol != null)
View Full Code Here

     * @param rs The result set returned from DatabaseMetaData.get??portedKeys()
     * @return The foreign key info
     */
    public ForeignKeyInfo newFKInfo(ResultSet rs)
    {
        return new ForeignKeyInfo(rs);
    }
View Full Code Here

TOP

Related Classes of org.datanucleus.store.rdbms.schema.ForeignKeyInfo

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.