You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@isis.apache.org by ke...@apache.org on 2011/09/13 22:13:31 UTC
svn commit: r1170328 -
/incubator/isis/trunk/framework/runtimes/dflt/objectstores/sql/sql-impl/src/main/java/org/apache/isis/runtimes/dflt/objectstores/sql/auto/PolymorphicForeignKeyInChildCollectionBaseMapper.java
Author: kevin
Date: Tue Sep 13 20:13:30 2011
New Revision: 1170328
URL: http://svn.apache.org/viewvc?rev=1170328&view=rev
Log:
ISIS-118: PolymorphicForeignKeyInChildCollectionBaseMapper now creates unique ids for each collection item stored.
Modified:
incubator/isis/trunk/framework/runtimes/dflt/objectstores/sql/sql-impl/src/main/java/org/apache/isis/runtimes/dflt/objectstores/sql/auto/PolymorphicForeignKeyInChildCollectionBaseMapper.java
Modified: incubator/isis/trunk/framework/runtimes/dflt/objectstores/sql/sql-impl/src/main/java/org/apache/isis/runtimes/dflt/objectstores/sql/auto/PolymorphicForeignKeyInChildCollectionBaseMapper.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/runtimes/dflt/objectstores/sql/sql-impl/src/main/java/org/apache/isis/runtimes/dflt/objectstores/sql/auto/PolymorphicForeignKeyInChildCollectionBaseMapper.java?rev=1170328&r1=1170327&r2=1170328&view=diff
==============================================================================
--- incubator/isis/trunk/framework/runtimes/dflt/objectstores/sql/sql-impl/src/main/java/org/apache/isis/runtimes/dflt/objectstores/sql/auto/PolymorphicForeignKeyInChildCollectionBaseMapper.java (original)
+++ incubator/isis/trunk/framework/runtimes/dflt/objectstores/sql/sql-impl/src/main/java/org/apache/isis/runtimes/dflt/objectstores/sql/auto/PolymorphicForeignKeyInChildCollectionBaseMapper.java Tue Sep 13 20:13:30 2011
@@ -44,6 +44,7 @@ import org.apache.isis.runtimes.dflt.obj
import org.apache.isis.runtimes.dflt.objectstores.sql.jdbc.JdbcPolymorphicObjectReferenceMapping;
import org.apache.isis.runtimes.dflt.objectstores.sql.mapping.FieldMapping;
import org.apache.isis.runtimes.dflt.runtime.system.context.IsisContext;
+import org.apache.isis.runtimes.dflt.runtime.system.persistence.OidGenerator;
/**
* Used to map 1-to-many collections by creating, in the collection child table (which may be an interface or abstract
@@ -60,6 +61,9 @@ public class PolymorphicForeignKeyInChil
private final String classColumnName;
private final String itemIdColumnName;
+ private final IdMappingAbstract polyIdMapper;
+
+ private final OidGenerator oidGenerator;
public PolymorphicForeignKeyInChildCollectionBaseMapper(final ObjectAssociation objectAssociation,
final String parameterBase, final FieldMappingLookup lookup, final ObjectMappingLookup objectMapperLookup,
@@ -69,6 +73,9 @@ public class PolymorphicForeignKeyInChil
classColumnName = Sql.identifier(Sql.sqlName(getForeignKeyName() + "_cls"));
itemIdColumnName = Sql.identifier("item_id");
+
+ polyIdMapper = new JdbcPolymorphicObjectReferenceMapping(itemIdColumnName);
+ oidGenerator = IsisContext.getPersistenceSession().getOidGenerator();
}
@Override
@@ -132,9 +139,6 @@ public class PolymorphicForeignKeyInChil
final Iterator<ObjectAdapter> elements) {
LOG.debug("Saving polymorphic list");
- // TODO: Continue appending "insert" IDs while the element specification is the same. When it changes, commit
- // current list and start again.
-
ObjectSpecification elementSpecification;
while (elements.hasNext()) {
ObjectAdapter thisAdapter = elements.next();
@@ -152,9 +156,10 @@ public class PolymorphicForeignKeyInChil
update.append("," + classColumnName);
update.append(") VALUES (");
- // TODO: I'm not sure about reusing the item's own Id as ID for this table..
- // PK_ID column
- getIdMapping().appendObjectId(connector, update, thisAdapter.getOid());
+ // Row ID column
+ final Oid transientOid = oidGenerator.createTransientOid(thisAdapter.getObject());
+ oidGenerator.convertTransientToPersistentOid(transientOid);
+ polyIdMapper.appendObjectId(connector, update, transientOid);
update.append(",");
// Foreign key ID column
@@ -174,7 +179,7 @@ public class PolymorphicForeignKeyInChil
@Override
public IdMappingAbstract getIdMapping() {
- return new JdbcPolymorphicObjectReferenceMapping(itemIdColumnName);
+ return polyIdMapper;
}
@Override