User: starksm 
  Date: 01/12/08 16:46:22

  Modified:    src/main/org/jboss/ejb/plugins/jaws/jdbc Tag: Branch_2_4
                        JDBCInitCommand.java
  Log:
  Integrate patch 489461
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.12.6.5  +20 -8     
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.6.4
  retrieving revision 1.12.6.5
  diff -u -r1.12.6.4 -r1.12.6.5
  --- JDBCInitCommand.java      2001/11/20 09:42:51     1.12.6.4
  +++ JDBCInitCommand.java      2001/12/09 00:46:22     1.12.6.5
  @@ -31,7 +31,7 @@
    * @author <a href="mailto:[EMAIL PROTECTED]";>Justin Forder</a>
    * @author <a href="mailto:[EMAIL PROTECTED]";>Michel de Groot</a>
    * @author <a href="mailto:[EMAIL PROTECTED]";>danch (Dan Christopherson</a>
  - * @version $Revision: 1.12.6.4 $
  + * @version $Revision: 1.12.6.5 $
    * 
    * Revision:
    * 20010621 danch: fixed bug where mapping a PK field to a different column name
  @@ -55,19 +55,19 @@
         while (it.hasNext())
         {
            CMPFieldMetaData cmpField = (CMPFieldMetaData)it.next();
  -         
  +
            sql += (first ? "" : ",") +
                   cmpField.getColumnName() + " " +
                   cmpField.getSQLType();
  -                
  -         
  +
  +
            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())  {
  +      if (jawsEntity.hasPkConstraint())  {
            sql += ",CONSTRAINT pk"+jawsEntity.getTableName()+" PRIMARY KEY (";
            for (Iterator i = jawsEntity.getPkFields();i.hasNext();) {
               String keyCol = ((PkFieldMetaData)i.next()).getColumnName();
  @@ -122,7 +122,7 @@
            } else {
                try
                {
  -             
  +
                    // since we use the pools, we have to do this within a transaction
                   factory.getContainer().getTransactionManager().begin ();
                   jdbcExecute(null);
  @@ -130,8 +130,19 @@
   
                   // Create successful, log this
                   log.info("Created table '"+jawsEntity.getTableName()+"' 
successfully.");
  -                log.debug("Primary key of table '"+jawsEntity.getTableName()+"' is 
'"
  -                  +jawsEntity.getPrimKeyField()+"'.");
  +                String pkStr;
  +                if (jawsEntity.getPrimKeyField() != null)
  +                  pkStr = "'"+jawsEntity.getPrimKeyField()+"'";
  +                else {
  +                  pkStr = "[";
  +                  for (Iterator i = jawsEntity.getPkFields();i.hasNext();) {
  +                    String keyCol = ((PkFieldMetaData)i.next()).getColumnName();
  +                    pkStr += keyCol;
  +                    pkStr += i.hasNext()?",":"]";
  +                  }
  +                }
  +                log.debug("Primary key of table '"+jawsEntity.getTableName()+"' is "
  +                          +pkStr);
                } catch (Exception e)
                {
                   log.debug("Could not create table " +
  @@ -158,3 +169,4 @@
         return null;
      }
   }
  +
  
  
  

_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-development

Reply via email to