java - Apache Metamodel How to add foreign keys while creating tables -


i've written code create tables apache metamodel:

datacontext.executeupdate(new updatescript() {         @override         public void run(updatecallback updatecallback) {             updatecallback.createtable(schema, "atable").withcolumn("id").oftype(columntype.integer)             .withcolumn("anothertableid").oftype(columntype.integer).execute();             updatecallback.createtable(schema, "anothertable").withcolumn("id").oftype(columntype.integer).execute();         } } 

how can add relationship between these tables?

you try:

datacontext.executeupdate(new updatescript() {         @override         public void run(updatecallback updatecallback) {             table atable = updatecallback.createtable(schema, "atable")                 .withcolumn("id").oftype(columntype.integer)                 .withcolumn("anothertableid").oftype(columntype.integer).execute();             table anothertable = updatecallback.createtable(schema, "anothertable")                 .withcolumn("id").oftype(columntype.integer).execute();              mutablerelationship.createrelationship(                anothertable.getcolumnbyname("id"),                atable.getcolumnbyname("anothertableid"));         } } 

Comments

Popular posts from this blog

php - How to display all orders for a single product showing the most recent first? Woocommerce -

asp.net - How to correctly use QUERY_STRING in ISAPI rewrite? -

angularjs - How restrict admin panel using in backend laravel and admin panel on angular? -