summaryrefslogtreecommitdiff
path: root/java/jboss5/files/patch-serial-autoinc
blob: 52775eb92c39b3f5664c28d3da1fd682539ed548 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
$FreeBSD$

This patch allows JBoss to correctly create tables when
using the auto-increment feature with Postgresql.

diff -r -u ./server/src/etc/conf/default/standardjbosscmp-jdbc.xml /tmp/jboss-4.0.0-src/server/src/etc/conf/default/standardjbosscmp-jdbc.xml
--- ./server/src/etc/conf/default/standardjbosscmp-jdbc.xml	Thu Sep 16 03:48:58 2004
+++ /tmp/jboss-4.0.0-src/server/src/etc/conf/default/standardjbosscmp-jdbc.xml	Sun Dec  5 22:21:18 2004
@@ -1169,7 +1169,7 @@
          <row-locking-template>SELECT ?1 FROM ?2 WHERE ?3 ORDER BY ?4 FOR UPDATE</row-locking-template>
          <pk-constraint-template>CONSTRAINT ?1 PRIMARY KEY (?2)</pk-constraint-template>
          <fk-constraint-template>ALTER TABLE ?1 ADD CONSTRAINT ?2 FOREIGN KEY (?3) REFERENCES ?4 (?5)</fk-constraint-template>
-         <auto-increment-template>?1</auto-increment-template>
+         <auto-increment-template>?1 serial</auto-increment-template>
          <alias-header-prefix>t</alias-header-prefix>
          <alias-header-suffix>_</alias-header-suffix>
          <alias-max-length>32</alias-max-length>
@@ -1296,7 +1296,7 @@
          <row-locking-template>SELECT ?1 FROM ?2 WHERE ?3 ORDER BY ?4 FOR UPDATE</row-locking-template>
          <pk-constraint-template>CONSTRAINT ?1 PRIMARY KEY (?2)</pk-constraint-template>
          <fk-constraint-template>ALTER TABLE ?1 ADD CONSTRAINT ?2 FOREIGN KEY (?3) REFERENCES ?4 (?5)</fk-constraint-template>
-         <auto-increment-template>?1</auto-increment-template>
+         <auto-increment-template>?1 serial</auto-increment-template>
          <alias-header-prefix>t</alias-header-prefix>
          <alias-header-suffix>_</alias-header-suffix>
          <alias-max-length>32</alias-max-length>
@@ -1423,7 +1423,7 @@
          <row-locking-template/>
          <pk-constraint-template>CONSTRAINT ?1 PRIMARY KEY (?2)</pk-constraint-template>
          <fk-constraint-template>ALTER TABLE ?1 ADD CONSTRAINT ?2 FOREIGN KEY (?3) REFERENCES ?4 (?5)</fk-constraint-template>
-         <auto-increment-template>?1 IDENTITY</auto-increment-template>
+         <auto-increment-template>?1 ?2 ?3 IDENTITY</auto-increment-template>
          <add-column-template>ALTER TABLE ?1 ADD COLUMN ?2 ?3</add-column-template>
          <drop-column-template>ALTER TABLE ?1 DROP COLUMN ?2</drop-column-template>
          <alias-header-prefix>t</alias-header-prefix>
@@ -1717,7 +1717,7 @@
               <fk-constraint-template>ALTER TABLE ?1 ADD CONSTRAINT ?2 FOREIGN KEY (?3) REFERENCES ?4 (?5)</fk-constraint-template>
          -->
          <fk-constraint-template>ALTER TABLE ?1 ADD INDEX (?3), ADD CONSTRAINT ?2 FOREIGN KEY (?3) REFERENCES ?4 (?5)</fk-constraint-template>
-         <auto-increment-template>?1 auto_increment</auto-increment-template>
+         <auto-increment-template>?1 ?2 ?3 auto_increment</auto-increment-template>
          <alter-column-template>ALTER TABLE ?1 MODIFY ?2 ?3</alter-column-template>
          <alias-header-prefix>t</alias-header-prefix>
          <alias-header-suffix>_</alias-header-suffix>
@@ -1857,7 +1857,7 @@
          <row-locking-template>SELECT ?1 FROM ?2 with (updlock) WHERE ?3 ORDER BY ?4</row-locking-template>
          <pk-constraint-template>CONSTRAINT ?1 PRIMARY KEY (?2)</pk-constraint-template>
          <fk-constraint-template>ALTER TABLE ?1 ADD CONSTRAINT ?2 FOREIGN KEY (?3) REFERENCES ?4 (?5)</fk-constraint-template>
-         <auto-increment-template>?1 IDENTITY</auto-increment-template>
+         <auto-increment-template>?1 ?2 ?3 IDENTITY</auto-increment-template>
          <alter-column-template>ALTER TABLE ?1 ALTER COLUMN ?2 ?3</alter-column-template>
          <alias-header-prefix>t</alias-header-prefix>
          <alias-header-suffix>_</alias-header-suffix>
@@ -1989,7 +1989,7 @@
          <row-locking-template>SELECT ?1 FROM ?2 with (xlock) WHERE ?3 ORDER BY ?4</row-locking-template>
          <pk-constraint-template>CONSTRAINT ?1 PRIMARY KEY (?2)</pk-constraint-template>
          <fk-constraint-template>ALTER TABLE ?1 ADD CONSTRAINT ?2 FOREIGN KEY (?3) REFERENCES ?4 (?5)</fk-constraint-template>
-         <auto-increment-template>?1 IDENTITY</auto-increment-template>
+         <auto-increment-template>?1 ?2 ?3 IDENTITY</auto-increment-template>
          <alias-header-prefix>t</alias-header-prefix>
          <alias-header-suffix>_</alias-header-suffix>
          <alias-max-length>32</alias-max-length>
diff -r -u ./server/src/main/org/jboss/ejb/plugins/cmp/jdbc/JDBCStartCommand.java /tmp/jboss-4.0.0-src/server/src/main/org/jboss/ejb/plugins/cmp/jdbc/JDBCStartCommand.java
--- ./server/src/main/org/jboss/ejb/plugins/cmp/jdbc/JDBCStartCommand.java	Tue Sep 14 09:23:02 2004
+++ /tmp/jboss-4.0.0-src/server/src/main/org/jboss/ejb/plugins/cmp/jdbc/JDBCStartCommand.java	Sun Dec  5 22:04:56 2004
@@ -916,14 +916,18 @@
       // apply auto-increment template
       if(type.getAutoIncrement()[0])
       {
-         String columnClause = SQLUtil.getCreateTableColumnsClause(type);
          JDBCFunctionMappingMetaData autoIncrement =
             manager.getMetaData().getTypeMapping().getAutoIncrementTemplate();
          if(autoIncrement == null)
          {
             throw new IllegalStateException("auto-increment template not found");
          }
-         String[] args = new String[]{columnClause};
+         String[] args = new String[]
+							{
+								type.getColumnNames () [0],
+								type.getSQLTypes () [0],
+								type.getNotNull () [0] ? " not null " : ""
+							};
          autoIncrement.getFunctionSql(args, sqlBuffer);
       }
       else