User: mgroot
Date: 01/01/24 12:36:24
Modified: src/main/org/jboss/ejb/plugins/jaws/jdbc
JDBCInitCommand.java
Log:
Added pk-constraint tag
Revision Changes Path
1.12 +14 -10
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.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- JDBCInitCommand.java 2001/01/19 21:19:03 1.11
+++ JDBCInitCommand.java 2001/01/24 20:36:24 1.12
@@ -19,6 +19,7 @@
import org.jboss.ejb.plugins.jaws.JPMInitCommand;
import org.jboss.ejb.plugins.jaws.metadata.CMPFieldMetaData;
+import org.jboss.ejb.plugins.jaws.metadata.PkFieldMetaData;
/**
* JAWSPersistenceManager JDBCInitCommand
@@ -29,7 +30,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.11 $
+ * @version $Revision: 1.12 $
*/
public class JDBCInitCommand
extends JDBCUpdateCommand
@@ -54,18 +55,21 @@
cmpField.getColumnName() + " " +
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;
}
+
+ // If there is a primary key field,
+ // and the bean has explicitly <pk-constraint>true</pk-constraint> in jaws.xml
+ // add primary key constraint.
+ if (jawsEntity.getPrimKeyField() != null && jawsEntity.hasPkConstraint()) {
+ sql += ",CONSTRAINT pk"+jawsEntity.getTableName()+" PRIMARY KEY (";
+ for (Iterator i = jawsEntity.getPkFields();i.hasNext();) {
+ sql += ((PkFieldMetaData)i.next()).getName();
+ sql += i.hasNext()?",":"";
+ }
+ sql +=")";
+ }
sql += ")";