app/src/main/java/db/juhaku/juhakudb/core/schema/SchemaFactory.java
/*
     * Join table is only for many to many relations.
     */
Join table is only for many to many relations.
Join table is only for many to many relations .
private void createJoinTable(Class<?> table, String tableName, Field column, Schema schema) throws SchemaInitializationException {
        String referenceColName = resolveName(column);
        String referenceTableName = resolveName(ReflectionUtils.getFieldType(column));
        Schema joinTable = getJoinTable(schema, tableName, referenceTableName);
        if (joinTable != null) {
            joinTable.setOrder(keys.incrementAndGet());
            return;
        } else {
            joinTable = new Schema();
        }
        String joinTableName = new StringBuilder(tableName).append("_").append(referenceTableName).toString();
        joinTable.setName(joinTableName);
        joinTable.setOrder(keys.incrementAndGet());
        String type = "INTEGER";
        String firstJoinColName = tableName.concat(NameResolver.ID_FIELD_SUFFIX);
        joinTable.addColumn(createNamedColumn(firstJoinColName, type));
        joinTable.addColumn(createNamedColumn(referenceColName, type));
        String firstJoinIdTable = resolveIdColumn(table);
        String secondJoinIdTable = resolveIdColumn(ReflectionUtils.getGenericFieldType(column));
        joinTable.getReferences().add(new Reference(firstJoinColName, tableName, firstJoinIdTable));
        joinTable.getReferences().add(new Reference(referenceColName, referenceTableName, secondJoinIdTable));
        schema.addTable(joinTable);
    }
private void createJoinTable ( Class < ? > table , String tableName , Field column , Schema schema ) throws SchemaInitializationException { String referenceColName = resolveName ( column ) ; String referenceTableName = resolveName ( ReflectionUtils . getFieldType ( column ) ) ; Schema joinTable = getJoinTable ( schema , tableName , referenceTableName ) ; if ( joinTable != null ) { joinTable . setOrder ( keys . incrementAndGet ( ) ) ; return ; } else { joinTable = new Schema ( ) ; } String joinTableName = new StringBuilder ( tableName ) . append ( "_" ) . append ( referenceTableName ) . toString ( ) ; joinTable . setName ( joinTableName ) ; joinTable . setOrder ( keys . incrementAndGet ( ) ) ; String type = "INTEGER" ; String firstJoinColName = tableName . concat ( NameResolver . ID_FIELD_SUFFIX ) ; joinTable . addColumn ( createNamedColumn ( firstJoinColName , type ) ) ; joinTable . addColumn ( createNamedColumn ( referenceColName , type ) ) ; String firstJoinIdTable = resolveIdColumn ( table ) ; String secondJoinIdTable = resolveIdColumn ( ReflectionUtils . getGenericFieldType ( column ) ) ; joinTable . getReferences ( ) . add ( new Reference ( firstJoinColName , tableName , firstJoinIdTable ) ) ; joinTable . getReferences ( ) . add ( new Reference ( referenceColName , referenceTableName , secondJoinIdTable ) ) ; schema . addTable ( joinTable ) ; }
Join table is only for many to many relations.
Join table is only for many to many relations .
// Resolve real name for entity class of column.