Digest for jooq-user@googlegroups.com - 4 updates in 3 topics

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Digest for jooq-user@googlegroups.com - 4 updates in 3 topics

http://groups.google.com/group/jooq-user/topics mailing list
Manuel Rossetti <[hidden email]>: Nov 29 03:42PM -0800

I generated the database using an sql script. Here is a snippet of that
script for the ARC table. The behavior is not specific to this table. It
occurs in all the generated DDL.
 
CREATE TABLE Arc (
ID INTEGER NOT NULL GENERATED ALWAYS AS IDENTITY,
Edge INTEGER DEFAULT 0,
Product INTEGER DEFAULT 0,
Priority INTEGER DEFAULT 1,
PRIMARY KEY (ID));
 
/* Foreign keys for Arc */
ALTER TABLE Arc ADD CONSTRAINT EdgeArc FOREIGN KEY (Edge) REFERENCES Edge
(ID);
ALTER TABLE Arc ADD CONSTRAINT ProductArc FOREIGN KEY (Product) REFERENCES
Product (ID);
 
So, notice that in my original SQL the constraints are named (e.g 'EdgeArc')
 
The Keys.java class seems to have captured the names.
 
//
-------------------------------------------------------------------------
// FOREIGN KEY definitions
//
-------------------------------------------------------------------------
 
public static final ForeignKey<ArcRecord, EdgeRecord> EDGEARC =
ForeignKeys0.EDGEARC;
public static final ForeignKey<ArcRecord, ProductRecord> PRODUCTARC =
ForeignKeys0.PRODUCTARC;
 
However, the DDL generated statements are like this:
 
create table "APP"."ARC"(
"ID" integer not null,
"EDGE" integer,
"PRODUCT" integer,
"PRIORITY" integer,
constraint "SQL171126155154580"
primary key ("ID")
)
 
alter table "APP"."ARC"
add constraint
foreign key ("EDGE")
references "EDGE" ("ID")
alter table "APP"."ARC"
add constraint
foreign key ("PRODUCT")
references "PRODUCT" ("ID")
 
So that the generated DDL are missing the constraint names.
 
BTW, my intent is to use the generated DDL to essentially replicate the
database and restore the original schema, which is one of the use cases for
the DDL functionality. In the jOOQ manual, the generated alter statements
do have the names for the constraints. So, I don't see what is going on
here.
 
 
 
 
 
On Tuesday, November 28, 2017 at 5:53:34 AM UTC-6, Lukas Eder wrote:
Lukas Eder <[hidden email]>: Nov 30 05:31PM +0100

Hi Manuel,
 
Thanks for your script. I've added the two additional tables to it:
 
CREATE TABLE Edge (
ID INTEGER NOT NULL GENERATED ALWAYS AS IDENTITY,
PRIMARY KEY (ID));
 
CREATE TABLE Product (
ID INTEGER NOT NULL GENERATED ALWAYS AS IDENTITY,
PRIMARY KEY (ID));
 
CREATE TABLE Arc (
ID INTEGER NOT NULL GENERATED ALWAYS AS IDENTITY,
Edge INTEGER DEFAULT 0,
Product INTEGER DEFAULT 0,
Priority INTEGER DEFAULT 1,
PRIMARY KEY (ID));
 
ALTER TABLE Arc ADD CONSTRAINT EdgeArc FOREIGN KEY (Edge) REFERENCES Edge
(ID);
ALTER TABLE Arc ADD CONSTRAINT ProductArc FOREIGN KEY (Product) REFERENCES
Product (ID);
 
 
And then ran the query that the jOOQ code generator runs:
 
SELECT
fc.constraintname,
ft.tablename,
fs.schemaname,
fg.descriptor,
pc.constraintname,
ps.schemaname
FROM
sys.sysconstraints fc
JOIN
sys.sysforeignkeys f ON f.constraintid = fc.constraintid
JOIN
sys.sysconglomerates fg ON fg.conglomerateid = f.conglomerateid
JOIN
sys.systables ft ON ft.tableid = fg.tableid
JOIN
sys.sysschemas fs ON ft.schemaid = fs.schemaid
JOIN
sys.sysconstraints pc ON pc.constraintid = f.keyconstraintid
JOIN
sys.sysschemas ps ON pc.schemaid = ps.schemaid
WHERE
cast(fc.type as varchar(32672)) = 'F'
 
 
But I don't see anything wrong with the output:
 
CONSTRAINTNAME |TABLENAME |SCHEMANAME |DESCRIPTOR
|CONSTRAINTNAME |SCHEMANAME |
-----------------------
|---------------------|-----------|--------------|---------------------|-----------|
EDGEARC |ARC |TEST |BTREE (2)
|SQL171130171546430 |TEST |
PRODUCTARC |ARC |TEST |BTREE (3)
|SQL171130171546540 |TEST |
 
 
The generated code on my side is correct as well:
 
public static final ForeignKey<ArcRecord, EdgeRecord> EDGEARC =
createForeignKey(org.jooq.test.derby.generatedclasses.Keys.SQL171130171546430,
Arc.ARC, "EDGEARC", Arc.EDGE);
public static final ForeignKey<ArcRecord, ProductRecord> PRODUCTARC
=
createForeignKey(org.jooq.test.derby.generatedclasses.Keys.SQL171130171546540,
Arc.ARC, "PRODUCTARC", Arc.PRODUCT);
 
When running this program:
 
import org.jooq.SQLDialect;
import org.jooq.impl.DSL;
import org.jooq.test.derby.generatedclasses.Tables;
 
public class Derby {
public static void main(String[] args) throws Exception {
System.out.println(
DSL.using(SQLDialect.DERBY).ddl(Tables.ARC)
);
}
}
 
 
I'm getting the expected output:
 
create table "TEST"."ARC"(
"ID" int generated by default as identity not null,
"EDGE" int default 0,
"PRODUCT" int default 0,
"PRIORITY" int default 1,
constraint "SQL171130171546620"
primary key ("ID"),
constraint "EDGEARC"
foreign key ("EDGE")
references "TEST"."EDGE" ("ID"),
constraint "PRODUCTARC"
foreign key ("PRODUCT")
references "TEST"."PRODUCT" ("ID")
);
 
 
So, clearly, there's a missing piece to help me reproduce this case... I've
tried version 3.11-SNAPSHOT and 3.9.6. Any other hint, maybe, to help me
reproduce this?
 
Thanks,
Lukas
 
Lukas Eder <[hidden email]>: Nov 30 06:02AM -0800

Version 1.6.0 - November 30, 2017
================================================================================
 
This release is the first Java-9 modularised jOOX version, publishing jOOX
under the module name org.jooq.joox. We're now cross-releasing the library
for 2 target JDK versions:
 
- Java 6/7/8: Using Maven artifactId joor-java-6
- Java 9: Using Maven artifactId joor
 
The artifactId joor will always support the latest JDK versions in the
future.
 
There is currently no separate deliverable for Java 8, as we're not really
using any of Java 8's features in the API yet.
 
Apart from the above, there are also some minor new features, which can be
seen in the release notes:
https://github.com/jOOQ/jOOX/issues?q=is%3Aissue+milestone%3A%22Version+1.6.0%22+is%3Aclosed
Lukas Eder <[hidden email]>: Nov 30 03:01AM -0800

Version 0.9.7 - November 30, 2017
================================================================================
 
This release is the first Java-9 modularised jOOR version, publishing jOOR
under the module name org.jooq.joor. We're now cross-releasing the library
for 3 target JDK versions:
 
- Java 6/7: Using Maven artifactId joor-java-6
- Java 8: Using Maven artifactId joor-java-8
- Java 9: Using Maven artifactId joor
 
The artifactId joor will always support the latest JDK versions in the
future.
 
Apart from the above, there are also some minor new features, which can be
seen in the release notes:
https://github.com/jOOQ/jOOR/issues?utf8=%E2%9C%93&q=label%3A%22R%3A+Fixed%22+is%3Aclosed+
You received this digest because you're subscribed to updates for this group. You can change your settings on the group membership page.
To unsubscribe from this group and stop receiving emails from it send an email to [hidden email].