Note that there are some explanatory texts on larger screens.

plurals
  1. POPlay Framework 2.0 and EBean, wrapping INFORMATION_SCHEMA
    primarykey
    data
    text
    <p>Using Play! Framework 2.0.4 and EBean as the persistence layer I am attempting to wrap a databases "meta" information to Java classes.</p> <p>I map the classes in application.conf:</p> <pre><code>db.myData.url="jdbc:sqlserver://localhost:2301;databaseName=myData;" ebean.myData="models.database.JavaTable" </code></pre> <p>I then created a class as follows:</p> <pre><code>package models.database; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.Table; import play.db.ebean.Model; @Entity @Table(name="tables",schema="INFORMATION_SCHEMA",catalog="myData") public class JavaTable extends Model{ @Column(name="TABLE_NAME") public String table_name; public static Finder&lt;String, JavaTable&gt; find = new Finder&lt;String, JavaTable&gt;( String.class, JavaTable.class ); } </code></pre> <p>When I fire up Play!, it tells me that I need to run an evolution on the database to create the table "myData.INFORMATION_SCHEMA.tables". I then tried to test the connection via a unit test...</p> <pre><code>@Test public void testGetTables(){ running(fakeApplication(), new Runnable() { @Override public void run() { EbeanServer server = Ebean.getServer("myData"); List&lt;SqlRow&gt; rows = server.createSqlQuery("select * from myData.Information_Schema.Tables").findList(); for(SqlRow row: rows) System.out.println("====&gt;Row: " + row.toString()); } }); } </code></pre> <p>The unit test executes correctly and the table names are printed out successfully.</p> <p><strong>Edit:</strong> per @nico_ekito I removed the evolution plugin in the configuration file and started getting:</p> <pre><code>RuntimeException DataSource user is null </code></pre> <p>So, researching a bit I decided to disable other datasources in the config file and moved the database I'm attempting to communicate with to "db.default" and "ebean.default" and the models started working. Is there a way to tell a model <em>which</em> datasource it should use if Play has multiple databases defined? Setting the classes via "ebean.default="myData.JavaTable" did not seem to work.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload