Skip to content

Instantly share code, notes, and snippets.

@hugithordarson
Created September 11, 2018 15:26
Show Gist options
  • Save hugithordarson/923b84d28e00c0e79fc605021a47f59d to your computer and use it in GitHub Desktop.
Save hugithordarson/923b84d28e00c0e79fc605021a47f59d to your computer and use it in GitHub Desktop.
package x;
import org.apache.cayenne.map.DbEntity;
import org.apache.cayenne.map.DbJoin;
import org.apache.cayenne.map.DbRelationship;
import nb.NBCore;
public class ListRelationships {
public static void main( String[] args ) {
for( DbEntity dbEntity : NBCore.newContext().getEntityResolver().getDbEntities() ) {
for( DbRelationship dbRelationship : dbEntity.getRelationships() ) {
System.out.println( "--- " + dbRelationship.getSourceEntityName() + ":" + dbRelationship.getName() );
for( DbJoin dbJoin : dbRelationship.getJoins() ) {
System.out.println( dbRelationship.getTargetEntityName() + ";" + dbJoin.getSourceName() + ";" + dbJoin.getTargetName() );
}
System.out.println();
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment