cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r1245351 - in /cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src: main/java/org/apache/cayenne/dba/ingres/ test/java/org/apache/cayenne/access/ test/java/org/apache/cayenne/testdo/quotemap/auto/ test/resources/
Date Fri, 17 Feb 2012 09:04:42 GMT
Author: oltka
Date: Fri Feb 17 09:04:41 2012
New Revision: 1245351

URL: http://svn.apache.org/viewvc?rev=1245351&view=rev
Log:
CAY-1666 fixed problem with Merge factory tests

Modified:
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/ingres/IngresAdapter.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/ingres/IngresMergerFactory.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/IdentityColumnsTest.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/testdo/quotemap/auto/_QuoteAdress.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/testdo/quotemap/auto/_Quote_Person.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/resources/quoted-identifiers.map.xml

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/ingres/IngresAdapter.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/ingres/IngresAdapter.java?rev=1245351&r1=1245350&r2=1245351&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/ingres/IngresAdapter.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/ingres/IngresAdapter.java
Fri Feb 17 09:04:41 2012
@@ -40,6 +40,8 @@ import org.apache.cayenne.dba.TypesMappi
 import org.apache.cayenne.di.Inject;
 import org.apache.cayenne.map.DbAttribute;
 import org.apache.cayenne.map.DbEntity;
+import org.apache.cayenne.map.DbJoin;
+import org.apache.cayenne.map.DbRelationship;
 import org.apache.cayenne.merge.MergerFactory;
 import org.apache.cayenne.query.Query;
 import org.apache.cayenne.query.SQLAction;
@@ -64,10 +66,9 @@ public class IngresAdapter extends JdbcA
             @Inject(USER_EXTENDED_TYPE_LIST) List<ExtendedType> userExtendedTypes,
             @Inject(EXTENDED_TYPE_FACTORY_LIST) List<ExtendedTypeFactory> extendedTypeFactories)
{
         super(runtimeProperties, defaultExtendedTypes, userExtendedTypes, extendedTypeFactories);
-        this.setSupportsUniqueConstraints(false);
+        setSupportsUniqueConstraints(true);
     }
-    
-    
+  
     @Override
     public QualifierTranslator getQualifierTranslator(QueryAssembler queryAssembler) {
         return new TrimmingQualifierTranslator(
@@ -160,9 +161,5 @@ public class IngresAdapter extends JdbcA
         if (at.isMandatory()) {
             buf.append(" NOT NULL");
         }
-        
-//        if (at.isGenerated()) {
-//            buf.append(" GENERATED ALWAYS AS IDENTITY");
-//        }
     }
 }

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/ingres/IngresMergerFactory.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/ingres/IngresMergerFactory.java?rev=1245351&r1=1245350&r2=1245351&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/ingres/IngresMergerFactory.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/ingres/IngresMergerFactory.java
Fri Feb 17 09:04:41 2012
@@ -25,7 +25,9 @@ import org.apache.cayenne.dba.DbAdapter;
 import org.apache.cayenne.dba.QuotingStrategy;
 import org.apache.cayenne.map.DbAttribute;
 import org.apache.cayenne.map.DbEntity;
+import org.apache.cayenne.map.DbJoin;
 import org.apache.cayenne.map.DbRelationship;
+import org.apache.cayenne.merge.AddRelationshipToDb;
 import org.apache.cayenne.merge.DropColumnToDb;
 import org.apache.cayenne.merge.DropRelationshipToDb;
 import org.apache.cayenne.merge.MergerFactory;
@@ -75,6 +77,66 @@ public class IngresMergerFactory extends
 
         };
     }
+   
+    @Override
+    public MergerToken createAddRelationshipToDb(DbEntity entity, final DbRelationship rel)
{
+        return new AddRelationshipToDb(entity, rel) {
+            @Override
+            public List<String> createSql(DbAdapter adapter) {
+              
+              if (!rel.isToMany() && rel.isToPK() && !rel.isToDependentPK())
{
+                  
+                  
+                DbEntity source = (DbEntity) rel.getSourceEntity();
+                boolean status = (source.getDataMap() != null && source.getDataMap().isQuotingSQLIdentifiers());
+                QuotingStrategy context = adapter.getQuotingStrategy(status);
+                StringBuilder buf = new StringBuilder();
+                StringBuilder refBuf = new StringBuilder();
+        
+                buf.append("ALTER TABLE ");
+                buf.append(context.quoteFullyQualifiedName(source));
+        
+                // requires the ADD CONSTRAINT statement
+                buf.append(" ADD CONSTRAINT ");
+                String name = "U_"
+                        + rel.getSourceEntity().getName()
+                        + "_"
+                        + (long) (System.currentTimeMillis() / (Math.random() * 100000));
+        
+                buf.append(context.quoteString(name));
+                buf.append(" FOREIGN KEY (");
+        
+                boolean first = true;
+                for (DbJoin join : rel.getJoins()) {
+                    if (!first) {
+                        buf.append(", ");
+                        refBuf.append(", ");
+                    }
+                    else
+                        first = false;
+        
+                    buf.append(context.quoteString(join.getSourceName()));
+                    refBuf.append(context.quoteString(join.getTargetName()));
+                }
+        
+                buf.append(") REFERENCES ");
+                buf.append(context.quoteFullyQualifiedName((DbEntity) rel.getTargetEntity()));
+                buf.append(" (");
+                buf.append(refBuf.toString());
+                buf.append(')');
+        
+                String fksql = buf.toString();
+                  
+                  if (fksql != null) {
+                      return Collections.singletonList(fksql);
+                  }
+              }
+             
+              return Collections.emptyList();
+             
+            }
+        };
+    }
     
     
     @Override
@@ -99,7 +161,7 @@ public class IngresMergerFactory extends
                 buf.append(context.quoteFullyQualifiedName(getEntity()));
                 buf.append(" DROP CONSTRAINT ");
                 buf.append(fkName);
-                buf.append(" RESTRICT ");
+                buf.append(" CASCADE ");
 
                 return Collections.singletonList(buf.toString());
             }

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/IdentityColumnsTest.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/IdentityColumnsTest.java?rev=1245351&r1=1245350&r2=1245351&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/IdentityColumnsTest.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/IdentityColumnsTest.java
Fri Feb 17 09:04:41 2012
@@ -90,7 +90,7 @@ public class IdentityColumnsTest extends
 
         SelectQuery q = new SelectQuery(GeneratedColumnTestEntity.class);
         q.setPageSize(10);
-        List results = context.performQuery(q);
+        List<?> results = context.performQuery(q);
         assertEquals(1, results.size());
 
         // per CAY-823 an attempt to resolve an object results in an exception

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/testdo/quotemap/auto/_QuoteAdress.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/testdo/quotemap/auto/_QuoteAdress.java?rev=1245351&r1=1245350&r2=1245351&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/testdo/quotemap/auto/_QuoteAdress.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/testdo/quotemap/auto/_QuoteAdress.java
Fri Feb 17 09:04:41 2012
@@ -18,25 +18,25 @@ public abstract class _QuoteAdress exten
     public static final String ADDRESS_ID_PK_COLUMN = "ADDRESS ID";
 
     public void setCity(String city) {
-        writeProperty(CITY_PROPERTY, city);
+        writeProperty("city", city);
     }
     public String getCity() {
-        return (String)readProperty(CITY_PROPERTY);
+        return (String)readProperty("city");
     }
 
     public void setGroup(String group) {
-        writeProperty(GROUP_PROPERTY, group);
+        writeProperty("group", group);
     }
     public String getGroup() {
-        return (String)readProperty(GROUP_PROPERTY);
+        return (String)readProperty("group");
     }
 
     public void setPerson_Rel(Quote_Person person_Rel) {
-        setToOneTarget(PERSON_REL_PROPERTY, person_Rel, true);
+        setToOneTarget("person_Rel", person_Rel, true);
     }
 
     public Quote_Person getPerson_Rel() {
-        return (Quote_Person)readProperty(PERSON_REL_PROPERTY);
+        return (Quote_Person)readProperty("person_Rel");
     }
 
 

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/testdo/quotemap/auto/_Quote_Person.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/testdo/quotemap/auto/_Quote_Person.java?rev=1245351&r1=1245350&r2=1245351&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/testdo/quotemap/auto/_Quote_Person.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/testdo/quotemap/auto/_Quote_Person.java
Fri Feb 17 09:04:41 2012
@@ -23,46 +23,46 @@ public abstract class _Quote_Person exte
     public static final String ID_PK_COLUMN = "id";
 
     public void setDAte(Date dAte) {
-        writeProperty(D_ATE_PROPERTY, dAte);
+        writeProperty("dAte", dAte);
     }
     public Date getDAte() {
-        return (Date)readProperty(D_ATE_PROPERTY);
+        return (Date)readProperty("dAte");
     }
 
     public void setFULL_name(String fULL_name) {
-        writeProperty(F_ULL_NAME_PROPERTY, fULL_name);
+        writeProperty("fULL_name", fULL_name);
     }
     public String getFULL_name() {
-        return (String)readProperty(F_ULL_NAME_PROPERTY);
+        return (String)readProperty("fULL_name");
     }
 
     public void setGroup(String group) {
-        writeProperty(GROUP_PROPERTY, group);
+        writeProperty("group", group);
     }
     public String getGroup() {
-        return (String)readProperty(GROUP_PROPERTY);
+        return (String)readProperty("group");
     }
 
     public void setName(String name) {
-        writeProperty(NAME_PROPERTY, name);
+        writeProperty("name", name);
     }
     public String getName() {
-        return (String)readProperty(NAME_PROPERTY);
+        return (String)readProperty("name");
     }
 
     public void setSalary(Integer salary) {
-        writeProperty(SALARY_PROPERTY, salary);
+        writeProperty("salary", salary);
     }
     public Integer getSalary() {
-        return (Integer)readProperty(SALARY_PROPERTY);
+        return (Integer)readProperty("salary");
     }
 
     public void setAddress_Rel(QuoteAdress address_Rel) {
-        setToOneTarget(ADDRESS_REL_PROPERTY, address_Rel, true);
+        setToOneTarget("address_Rel", address_Rel, true);
     }
 
     public QuoteAdress getAddress_Rel() {
-        return (QuoteAdress)readProperty(ADDRESS_REL_PROPERTY);
+        return (QuoteAdress)readProperty("address_Rel");
     }
 
 

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/resources/quoted-identifiers.map.xml
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/resources/quoted-identifiers.map.xml?rev=1245351&r1=1245350&r2=1245351&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/resources/quoted-identifiers.map.xml
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/resources/quoted-identifiers.map.xml
Fri Feb 17 09:04:41 2012
@@ -15,7 +15,7 @@
 		<db-attribute name="FULL name" type="VARCHAR" length="300"/>
 		<db-attribute name="GROUP" type="VARCHAR" length="100"/>
 		<db-attribute name="NAME" type="VARCHAR" length="100"/>
-		<db-attribute name="address_id" type="INTEGER"/>
+		<db-attribute name="address_id" type="INTEGER" isMandatory="true"/>
 		<db-attribute name="id" type="INTEGER" isPrimaryKey="true" isMandatory="true"/>
 		<db-attribute name="salary" type="INTEGER"/>
 	</db-entity>



Mime
View raw message