User: mgroot
Date: 01/01/19 13:19:03
Modified: src/main/org/jboss/ejb/plugins/jaws/jdbc
JDBCInitCommand.java
Log:
Fixed a bug in the previous addition of primary key constraints.
If the primkey-field was not defined in ejb-jar.xml, the entity
was not deployable due to a nullpointerexception.
The primary key constraint is now skipped in that case.
Revision Changes Path
1.11 +12 -7
jboss/src/main/org/jboss/ejb/plugins/jaws/jdbc/JDBCInitCommand.java
Index: JDBCInitCommand.java
===================================================================
RCS file:
/products/cvs/ejboss/jboss/src/main/org/jboss/ejb/plugins/jaws/jdbc/JDBCInitCommand.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- JDBCInitCommand.java 2001/01/16 21:25:12 1.10
+++ JDBCInitCommand.java 2001/01/19 21:19:03 1.11
@@ -29,7 +29,7 @@
* @author <a href="mailto:[EMAIL PROTECTED]">Joe Shevland</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Justin Forder</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Michel de Groot</a>
- * @version $Revision: 1.10 $
+ * @version $Revision: 1.11 $
*/
public class JDBCInitCommand
extends JDBCUpdateCommand
@@ -52,13 +52,18 @@
sql += (first ? "" : ",") +
cmpField.getColumnName() + " " +
- cmpField.getSQLType() +
- // If the current field is the primary key field,
- // add the constraint that this field is primary key.
- // This is useful for some dbase editors like MS Access 97
- // that require this information for better editing.
- (jawsEntity.getPrimKeyField().equals(cmpField.getColumnName())?
- " CONSTRAINT pk"+jawsEntity.getTableName()+" PRIMARY KEY":"");
+ cmpField.getSQLType();
+
+ // if primary key defined in ejb-jar.xml
+ if (jawsEntity.getPrimKeyField() != null) {
+ // If the current field is the primary key field,
+ // add the constraint that this field is primary key.
+ // This is useful for some dbase editors like MS Access 97
+ // that require this information for better editing.
+ sql +=
(jawsEntity.getPrimKeyField().equals(cmpField.getColumnName())?
+ " CONSTRAINT pk"+jawsEntity.getTableName()+" PRIMARY
KEY":"");
+ }
+
first = false;
}