Ok, my attempt at rev 6. introduced orders and customers tables. compiles fine. throws exception here in createTable():<br><br><div style="margin-left: 40px;"><font size="1">Create<orders> create4 = new Create<orders>(orders.table);<br>
create4.add(<a href="http://orders.id">orders.id</a>, "varchar(40) not null primary key");<br>create4.add(orders.customersid, "varchar(40) not null foreign key(customersid) references customers(id)");<br>
session.prepare(create4).execute();<br><br></font></div><font size="1"><font size="2">console output:</font></font><br><br>create table users (name varchar(40) not null, username varchar(10) not null primary key, password varchar(10) not null, age smallint not null)<br>
create table permissions (username varchar(10) not null, id varchar(20) not null primary key)<br>create table customers (id varchar(40) not null primary key)<br>create table orders (id varchar(40) not null primary key, customersid varchar(40) not null foreign key(customersid) references customers(id))<br>
Exception in thread "main" java.lang.RuntimeException: java.sql.SQLException: <span style="color: rgb(255, 0, 0);">Unexpected token: FOREIGN in statement [create table orders (id varchar(40) not null primary key, customersid varchar(40) not null foreign]</span><br>
at org.seamframework.sql.ExecutableStatement.execute(ExecutableStatement.java:53)<br> at eg.Main.createTable(Main.java:87)<br> at eg.Main.main(Main.java:52)<br>Caused by: java.sql.SQLException: Unexpected token: FOREIGN in statement [create table orders (id varchar(40) not null primary key, customersid varchar(40) not null foreign]<br>
at org.hsqldb.jdbc.Util.throwError(Unknown Source)<br> at org.hsqldb.jdbc.jdbcPreparedStatement.execute(Unknown Source)<br> at org.seamframework.sql.ExecutableStatement.execute(ExecutableStatement.java:50)<br> ... 2 more<br>
<br>We'll need to be able to handle this in a typesafe manner (I'm talking about DDL stuff like defining not null and PK/FK, etc.) as well and also specify rdbms vendor in a props file, etc. b/c I noticed that the syntax for sql server and oracle are different for defining FK's:<br>
<br><a href="http://www.1keydata.com/sql/sql-foreign-key.html">http://www.1keydata.com/sql/sql-foreign-key.html</a><br><br>Also need to be able to handle identity columns for surrogate keys as well as sequences.<br><br>thx.<br>
<br><br><div class="gmail_quote">On Fri, Nov 27, 2009 at 10:25 PM, Arbi Sookazian <span dir="ltr"><<a href="mailto:asookazian@gmail.com">asookazian@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Looks like there are two tables (users and permissions) but testQuery2() and testQuery3() both select only from one table - users. So now we need a small db schema (i.e. data model). The typical customers and orders would suffice to demo FK and potential outer joins. How can I define customerId as a FK on orders table? Ideally, it would be nice to be able to do all this via tooling (i.e. exec a wizard that would generate the code for us). But we need to be able to do all this via the API for now...<br>
<br><div class="gmail_quote"><div><div></div><div class="h5">On Fri, Nov 27, 2009 at 3:16 PM, Gavin King <span dir="ltr"><<a href="mailto:gavin.king@gmail.com" target="_blank">gavin.king@gmail.com</a>></span> wrote:<br>
</div></div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div><div></div><div class="h5">
New rev, with ability to pass SQL as strings.<br>
<div><br>
On Fri, Nov 27, 2009 at 4:47 PM, Gavin King <<a href="mailto:gavin.king@gmail.com" target="_blank">gavin.king@gmail.com</a>> wrote:<br>
> Latest, with a new approach to specifying types.<br>
><br>
<br>
<br>
<br>
</div>--<br>
<div><div></div><div>Gavin King<br>
<a href="mailto:gavin.king@gmail.com" target="_blank">gavin.king@gmail.com</a><br>
<a href="http://in.relation.to/Bloggers/Gavin" target="_blank">http://in.relation.to/Bloggers/Gavin</a><br>
<a href="http://hibernate.org" target="_blank">http://hibernate.org</a><br>
<a href="http://seamframework.org" target="_blank">http://seamframework.org</a><br>
</div></div><br></div></div><div class="im">_______________________________________________<br>
weld-dev mailing list<br>
<a href="mailto:weld-dev@lists.jboss.org" target="_blank">weld-dev@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/weld-dev" target="_blank">https://lists.jboss.org/mailman/listinfo/weld-dev</a><br></div></blockquote></div><br>
</blockquote></div><br>