User: danch
Date: 01/06/21 22:41:05
Modified: src/main/org/jboss/ejb/plugins/jaws/jdbc Tag: Branch_2_4
JDBCInitCommand.java
Log:
fix bug when PK field != columnname
Revision Changes Path
No revision
No revision
1.12.6.1 +21 -15
jboss/src/main/org/jboss/ejb/plugins/jaws/jdbc/JDBCInitCommand.java
Index: JDBCInitCommand.java
===================================================================
RCS file:
/cvsroot/jboss/jboss/src/main/org/jboss/ejb/plugins/jaws/jdbc/JDBCInitCommand.java,v
retrieving revision 1.12
retrieving revision 1.12.6.1
diff -u -r1.12 -r1.12.6.1
--- JDBCInitCommand.java 2001/01/24 20:36:24 1.12
+++ JDBCInitCommand.java 2001/06/22 05:41:05 1.12.6.1
@@ -30,7 +30,12 @@
* @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.12 $
+ * @author <a href="mailto:[EMAIL PROTECTED]">danch (Dan Christopherson</a>
+ * @version $Revision: 1.12.6.1 $
+ *
+ * Revision:
+ * 20010621 danch: fixed bug where mapping a PK field to a different column name
+ * resulted in an improper PK constraint.
*/
public class JDBCInitCommand
extends JDBCUpdateCommand
@@ -59,17 +64,18 @@
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 +=")";
+ // 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();) {
+ String keyCol = ((PkFieldMetaData)i.next()).getColumnName();
+ sql += keyCol;
+ sql += i.hasNext()?",":"";
}
+ sql +=")";
+ }
sql += ")";
@@ -122,10 +128,10 @@
jdbcExecute(null);
factory.getContainer().getTransactionManager().commit ();
- // Create successful, log this
- log.log("Created table '"+jawsEntity.getTableName()+"'
successfully.");
- log.debug("Primary key of table '"+jawsEntity.getTableName()+"'
is '"
- +jawsEntity.getPrimKeyField()+"'.");
+ // Create successful, log this
+ log.log("Created table '"+jawsEntity.getTableName()+"'
successfully.");
+ log.debug("Primary key of table '"+jawsEntity.getTableName()+"' is
'"
+ +jawsEntity.getPrimKeyField()+"'.");
} catch (Exception e)
{
log.debug("Could not create table " +
_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/jboss-development