private void analyzeForeignKey ( SQLiteDatabaseSchema schema ) { for ( SQLiteEntity entity : schema . getEntities ( ) ) { for ( SQLProperty property : entity . getCollection ( ) ) { if ( property . isForeignKey ( ) ) { SQLiteEntity reference = schema . getEntity ( property . foreignParentClassName ) ; AssertKripton . asserTrueOrUnspecifiedBeanException ( reference != null , schema , entity , property . foreignParentClassName ) ; if ( ! entity . equals ( reference ) ) { entity . referedEntities . add ( reference ) ; } } } } for ( SQLiteDaoDefinition dao : schema . getCollection ( ) ) { if ( dao . getElement ( ) . getAnnotation ( BindDaoMany2Many . class ) != null ) { ClassName entity1 = TypeUtility . className ( AnnotationUtility . extractAsClassName ( dao . getElement ( ) , BindDaoMany2Many . class , AnnotationAttributeType . ENTITY_1 ) ) ; ClassName entity2 = TypeUtility . className ( AnnotationUtility . extractAsClassName ( dao . getElement ( ) , BindDaoMany2Many . class , AnnotationAttributeType . ENTITY_2 ) ) ; // only if dao has an entity if ( dao . getEntity ( ) != null ) { // check foreign key to entity1 and entity2 checkForeignKeyForM2M ( schema , dao . getEntity ( ) , entity1 ) ; checkForeignKeyForM2M ( schema , dao . getEntity ( ) , entity2 ) ; } } } }
Analyze foreign key .