You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cayenne.apache.org by aa...@apache.org on 2013/06/22 21:36:54 UTC
svn commit: r1495773 [2/3] - in
/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src:
main/java/org/apache/cayenne/ main/java/org/apache/cayenne/access/
main/java/org/apache/cayenne/access/jdbc/
main/java/org/apache/cayenne/access/trans/ main/j...
Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/reflect/PersistentDescriptorFactory.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/reflect/PersistentDescriptorFactory.java?rev=1495773&r1=1495772&r2=1495773&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/reflect/PersistentDescriptorFactory.java (original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/reflect/PersistentDescriptorFactory.java Sat Jun 22 19:36:53 2013
@@ -61,18 +61,15 @@ public abstract class PersistentDescript
protected ClassDescriptor getDescriptor(ObjEntity entity, Class<?> entityClass) {
String superEntityName = entity.getSuperEntityName();
- ClassDescriptor superDescriptor = (superEntityName != null) ? descriptorMap
- .getDescriptor(superEntityName) : null;
+ ClassDescriptor superDescriptor = (superEntityName != null) ? descriptorMap.getDescriptor(superEntityName)
+ : null;
PersistentDescriptor descriptor = createDescriptor();
descriptor.setEntity(entity);
descriptor.setSuperclassDescriptor(superDescriptor);
descriptor.setObjectClass(entityClass);
- descriptor.setPersistenceStateAccessor(new BeanAccessor(
- entityClass,
- "persistenceState",
- Integer.TYPE));
+ descriptor.setPersistenceStateAccessor(new BeanAccessor(entityClass, "persistenceState", Integer.TYPE));
// only include this entity attributes and skip superclasses...
for (Attribute attribute : descriptor.getEntity().getDeclaredAttributes()) {
@@ -82,48 +79,37 @@ public abstract class PersistentDescript
for (ObjAttribute objAttribute : embedded.getAttributes()) {
createEmbeddedAttributeProperty(descriptor, embedded, objAttribute);
}
- }
- else if (attribute instanceof ObjAttribute) {
+ } else if (attribute instanceof ObjAttribute) {
createAttributeProperty(descriptor, (ObjAttribute) attribute);
}
}
// only include this entity relationships and skip superclasses...
- for (Relationship relationship : descriptor
- .getEntity()
- .getDeclaredRelationships()) {
+ for (Relationship relationship : descriptor.getEntity().getDeclaredRelationships()) {
ObjRelationship objRelationship = (ObjRelationship) relationship;
if (relationship.isToMany()) {
String collectionType = objRelationship.getCollectionType();
- if (collectionType == null
- || ObjRelationship.DEFAULT_COLLECTION_TYPE.equals(collectionType)) {
+ if (collectionType == null || ObjRelationship.DEFAULT_COLLECTION_TYPE.equals(collectionType)) {
createToManyListProperty(descriptor, objRelationship);
- }
- else if (collectionType.equals("java.util.Map")) {
+ } else if (collectionType.equals("java.util.Map")) {
createToManyMapProperty(descriptor, objRelationship);
- }
- else if (collectionType.equals("java.util.Set")) {
+ } else if (collectionType.equals("java.util.Set")) {
createToManySetProperty(descriptor, objRelationship);
- }
- else if (collectionType.equals("java.util.Collection")) {
+ } else if (collectionType.equals("java.util.Collection")) {
createToManyCollectionProperty(descriptor, objRelationship);
+ } else {
+ throw new IllegalArgumentException("Unsupported to-many collection type: " + collectionType);
}
- else {
- throw new IllegalArgumentException(
- "Unsupported to-many collection type: " + collectionType);
- }
- }
- else {
+ } else {
createToOneProperty(descriptor, objRelationship);
}
}
- EntityInheritanceTree inheritanceTree = descriptorMap
- .getResolver()
- .lookupInheritanceTree(descriptor.getEntity().getName());
+ EntityInheritanceTree inheritanceTree = descriptorMap.getResolver().getInheritanceTree(
+ descriptor.getEntity().getName());
descriptor.setEntityInheritanceTree(inheritanceTree);
indexSubclassDescriptors(descriptor, inheritanceTree);
indexQualifiers(descriptor, inheritanceTree);
@@ -132,7 +118,7 @@ public abstract class PersistentDescript
indexRootDbEntities(descriptor, inheritanceTree);
indexSuperclassProperties(descriptor);
-
+
descriptor.sortProperties();
return descriptor;
@@ -142,21 +128,14 @@ public abstract class PersistentDescript
return new PersistentDescriptor();
}
- protected void createAttributeProperty(
- PersistentDescriptor descriptor,
- ObjAttribute attribute) {
+ protected void createAttributeProperty(PersistentDescriptor descriptor, ObjAttribute attribute) {
Class<?> propertyType = attribute.getJavaClass();
Accessor accessor = createAccessor(descriptor, attribute.getName(), propertyType);
- descriptor.addDeclaredProperty(new SimpleAttributeProperty(
- descriptor,
- accessor,
- attribute));
+ descriptor.addDeclaredProperty(new SimpleAttributeProperty(descriptor, accessor, attribute));
}
- protected void createEmbeddedAttributeProperty(
- PersistentDescriptor descriptor,
- EmbeddedAttribute embeddedAttribute,
- ObjAttribute attribute) {
+ protected void createEmbeddedAttributeProperty(PersistentDescriptor descriptor,
+ EmbeddedAttribute embeddedAttribute, ObjAttribute attribute) {
Class<?> embeddableClass = embeddedAttribute.getJavaClass();
@@ -170,53 +149,31 @@ public abstract class PersistentDescript
EmbeddableDescriptor embeddableDescriptor = createEmbeddableDescriptor(embeddedAttribute);
- Accessor embeddedAccessor = createAccessor(descriptor, embeddedAttribute
- .getName(), embeddableClass);
- Accessor embeddedableAccessor = createEmbeddableAccessor(
- embeddableDescriptor,
- embeddableName,
+ Accessor embeddedAccessor = createAccessor(descriptor, embeddedAttribute.getName(), embeddableClass);
+ Accessor embeddedableAccessor = createEmbeddableAccessor(embeddableDescriptor, embeddableName,
attribute.getJavaClass());
- Accessor accessor = new EmbeddedFieldAccessor(
- embeddableDescriptor,
- embeddedAccessor,
- embeddedableAccessor);
- descriptor.addDeclaredProperty(new SimpleAttributeProperty(
- descriptor,
- accessor,
- attribute));
- }
-
- protected abstract void createToOneProperty(
- PersistentDescriptor descriptor,
- ObjRelationship relationship);
-
- protected abstract void createToManySetProperty(
- PersistentDescriptor descriptor,
- ObjRelationship relationship);
-
- protected abstract void createToManyMapProperty(
- PersistentDescriptor descriptor,
- ObjRelationship relationship);
-
- protected abstract void createToManyListProperty(
- PersistentDescriptor descriptor,
- ObjRelationship relationship);
-
- protected abstract void createToManyCollectionProperty(
- PersistentDescriptor descriptor,
- ObjRelationship relationship);
-
- protected void indexSubclassDescriptors(
- PersistentDescriptor descriptor,
- EntityInheritanceTree inheritanceTree) {
+ Accessor accessor = new EmbeddedFieldAccessor(embeddableDescriptor, embeddedAccessor, embeddedableAccessor);
+ descriptor.addDeclaredProperty(new SimpleAttributeProperty(descriptor, accessor, attribute));
+ }
+
+ protected abstract void createToOneProperty(PersistentDescriptor descriptor, ObjRelationship relationship);
+
+ protected abstract void createToManySetProperty(PersistentDescriptor descriptor, ObjRelationship relationship);
+
+ protected abstract void createToManyMapProperty(PersistentDescriptor descriptor, ObjRelationship relationship);
+
+ protected abstract void createToManyListProperty(PersistentDescriptor descriptor, ObjRelationship relationship);
+
+ protected abstract void createToManyCollectionProperty(PersistentDescriptor descriptor, ObjRelationship relationship);
+
+ protected void indexSubclassDescriptors(PersistentDescriptor descriptor, EntityInheritanceTree inheritanceTree) {
if (inheritanceTree != null) {
for (EntityInheritanceTree child : inheritanceTree.getChildren()) {
ObjEntity childEntity = child.getEntity();
- descriptor.addSubclassDescriptor(
- childEntity.getClassName(),
+ descriptor.addSubclassDescriptor(childEntity.getClassName(),
descriptorMap.getDescriptor(childEntity.getName()));
indexSubclassDescriptors(descriptor, child);
@@ -224,9 +181,7 @@ public abstract class PersistentDescript
}
}
- protected void indexRootDbEntities(
- PersistentDescriptor descriptor,
- EntityInheritanceTree inheritanceTree) {
+ protected void indexRootDbEntities(PersistentDescriptor descriptor, EntityInheritanceTree inheritanceTree) {
if (inheritanceTree != null) {
@@ -238,28 +193,24 @@ public abstract class PersistentDescript
}
}
- private void appendDeclaredRootDbEntity(
- PersistentDescriptor descriptor,
- ObjEntity entity) {
+ private void appendDeclaredRootDbEntity(PersistentDescriptor descriptor, ObjEntity entity) {
DbEntity dbEntity = entity.getDbEntity();
if (dbEntity != null) {
- // descriptor takes care of weeding off duplicates, which are likely in cases
+ // descriptor takes care of weeding off duplicates, which are likely
+ // in cases
// of non-horizontal inheritance
descriptor.addRootDbEntity(dbEntity);
}
}
- protected void indexQualifiers(
- final PersistentDescriptor descriptor,
- EntityInheritanceTree inheritanceTree) {
+ protected void indexQualifiers(final PersistentDescriptor descriptor, EntityInheritanceTree inheritanceTree) {
Expression qualifier;
if (inheritanceTree != null) {
qualifier = inheritanceTree.qualifierForEntityAndSubclasses();
- }
- else {
+ } else {
qualifier = descriptor.getEntity().getDeclaredQualifier();
}
@@ -277,13 +228,10 @@ public abstract class PersistentDescript
public void startNode(Expression node, Expression parentNode) {
if (node.getType() == Expression.DB_PATH) {
String path = node.getOperand(0).toString();
- final DbAttribute attribute = (DbAttribute) dbEntity
- .getAttribute(path);
+ final DbAttribute attribute = (DbAttribute) dbEntity.getAttribute(path);
if (attribute != null) {
- ObjAttribute objectAttribute = descriptor
- .getEntity()
- .getAttributeForDbAttribute(attribute);
+ ObjAttribute objectAttribute = descriptor.getEntity().getAttributeForDbAttribute(attribute);
if (objectAttribute == null) {
objectAttribute = new ObjAttribute(attribute.getName()) {
@@ -295,18 +243,17 @@ public abstract class PersistentDescript
};
// we semi-officially DO NOT support inheritance
- // descriptors based on related entities, so here we
+ // descriptors based on related entities, so
+ // here we
// assume that DbAttribute is rooted in the root
// DbEntity, and no relationship is involved.
objectAttribute.setDbAttributePath(attribute.getName());
- objectAttribute.setType(TypesMapping
- .getJavaBySqlType(attribute.getType()));
+ objectAttribute.setType(TypesMapping.getJavaBySqlType(attribute.getType()));
}
attributes.put(objectAttribute.getName(), objectAttribute);
}
- }
- else if (node.getType() == Expression.OBJ_PATH) {
+ } else if (node.getType() == Expression.OBJ_PATH) {
String path = node.getOperand(0).toString();
ObjAttribute attribute = (ObjAttribute) descriptor.getEntity().getAttribute(path);
attributes.put(path, attribute);
@@ -330,9 +277,7 @@ public abstract class PersistentDescript
public boolean visitAttribute(AttributeProperty property) {
// decorate super property to return an overridden attribute
- descriptor.addSuperProperty(new AttributePropertyDecorator(
- descriptor,
- property));
+ descriptor.addSuperProperty(new AttributePropertyDecorator(descriptor, property));
return true;
}
@@ -352,19 +297,15 @@ public abstract class PersistentDescript
/**
* Creates an accessor for the property.
*/
- protected Accessor createAccessor(
- PersistentDescriptor descriptor,
- String propertyName,
- Class<?> propertyType) throws PropertyException {
+ protected Accessor createAccessor(PersistentDescriptor descriptor, String propertyName, Class<?> propertyType)
+ throws PropertyException {
return new FieldAccessor(descriptor.getObjectClass(), propertyName, propertyType);
}
/**
* Creates an accessor to read a map key for a given relationship.
*/
- protected Accessor createMapKeyAccessor(
- ObjRelationship relationship,
- ClassDescriptor targetDescriptor) {
+ protected Accessor createMapKeyAccessor(ObjRelationship relationship, ClassDescriptor targetDescriptor) {
String mapKey = relationship.getMapKey();
if (mapKey != null) {
@@ -377,9 +318,7 @@ public abstract class PersistentDescript
/**
* Creates an accessor for the property of the embeddable class.
*/
- protected Accessor createEmbeddableAccessor(
- EmbeddableDescriptor descriptor,
- String propertyName,
+ protected Accessor createEmbeddableAccessor(EmbeddableDescriptor descriptor, String propertyName,
Class<?> propertyType) {
return new FieldAccessor(descriptor.getObjectClass(), propertyName, propertyType);
}
@@ -387,13 +326,10 @@ public abstract class PersistentDescript
/**
* Creates a descriptor of the embedded property.
*/
- protected EmbeddableDescriptor createEmbeddableDescriptor(
- EmbeddedAttribute embeddedAttribute) {
- // TODO: andrus, 11/19/2007 = avoid creation of descriptor for every property of
+ protected EmbeddableDescriptor createEmbeddableDescriptor(EmbeddedAttribute embeddedAttribute) {
+ // TODO: andrus, 11/19/2007 = avoid creation of descriptor for every
+ // property of
// embeddable; look up reusable descriptor instead.
- return new FieldEmbeddableDescriptor(
- embeddedAttribute.getEmbeddable(),
- "owner",
- "embeddedProperty");
+ return new FieldEmbeddableDescriptor(embeddedAttribute.getEmbeddable(), "owner", "embeddedProperty");
}
}
Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/ClientServerChannelTest.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/ClientServerChannelTest.java?rev=1495773&r1=1495772&r2=1495773&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/ClientServerChannelTest.java (original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/ClientServerChannelTest.java Sat Jun 22 19:36:53 2013
@@ -65,10 +65,10 @@ public class ClientServerChannelTest ext
@Inject
protected DataChannelInterceptor queryInterceptor;
-
+
@Inject
protected JdbcEventLogger logger;
-
+
@Inject
private ServerRuntime runtime;
@@ -104,9 +104,8 @@ public class ClientServerChannelTest ext
public void testGetEntityResolver() throws Exception {
EntityResolver resolver = clientServerChannel.getEntityResolver();
assertNotNull(resolver);
- assertNull(resolver.lookupObjEntity(ClientMtTable1.class));
- assertNotNull(resolver.getClientEntityResolver().lookupObjEntity(
- ClientMtTable1.class));
+ assertNull(resolver.getObjEntity(ClientMtTable1.class));
+ assertNotNull(resolver.getClientEntityResolver().getObjEntity(ClientMtTable1.class));
}
public void testSynchronizeCommit() throws Exception {
@@ -114,16 +113,13 @@ public class ClientServerChannelTest ext
SelectQuery query = new SelectQuery(MtTable1.class);
// no changes...
- clientServerChannel.onSync(
- serverContext,
- new MockGraphDiff(),
- DataChannel.FLUSH_CASCADE_SYNC);
+ clientServerChannel.onSync(serverContext, new MockGraphDiff(), DataChannel.FLUSH_CASCADE_SYNC);
assertEquals(0, serverContext.performQuery(query).size());
// introduce changes
- clientServerChannel.onSync(serverContext, new NodeCreateOperation(new ObjectId(
- "MtTable1")), DataChannel.FLUSH_CASCADE_SYNC);
+ clientServerChannel.onSync(serverContext, new NodeCreateOperation(new ObjectId("MtTable1")),
+ DataChannel.FLUSH_CASCADE_SYNC);
assertEquals(1, serverContext.performQuery(query).size());
}
@@ -146,16 +142,12 @@ public class ClientServerChannelTest ext
ClientMtTable1 clientObject = (ClientMtTable1) result;
assertNotNull(clientObject.getObjectId());
- assertEquals(
- new ObjectId("MtTable1", MtTable1.TABLE1_ID_PK_COLUMN, 55),
- clientObject.getObjectId());
+ assertEquals(new ObjectId("MtTable1", MtTable1.TABLE1_ID_PK_COLUMN, 55), clientObject.getObjectId());
}
public void testPerformQueryValuePropagation() throws Exception {
- byte[] bytes = new byte[] {
- 1, 2, 3
- };
+ byte[] bytes = new byte[] { 1, 2, 3 };
tMtTable3.insert(1, bytes, "abc", 4);
@@ -175,9 +167,7 @@ public class ClientServerChannelTest ext
assertEquals("abc", clientObject.getCharColumn());
assertEquals(new Integer(4), clientObject.getIntColumn());
- assertTrue(new EqualsBuilder()
- .append(clientObject.getBinaryColumn(), bytes)
- .isEquals());
+ assertTrue(new EqualsBuilder().append(clientObject.getBinaryColumn(), bytes).isEquals());
}
public void testPerformQueryPropagationInheritance() throws Exception {
@@ -195,9 +185,7 @@ public class ClientServerChannelTest ext
assertEquals(1, results.size());
Object result = results.get(0);
- assertTrue(
- "Result is of wrong type: " + result,
- result instanceof ClientMtTable1Subclass);
+ assertTrue("Result is of wrong type: " + result, result instanceof ClientMtTable1Subclass);
ClientMtTable1Subclass clientObject = (ClientMtTable1Subclass) result;
assertEquals("sub1", clientObject.getGlobalAttribute1());
Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/DataContextPrefetchTest.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/DataContextPrefetchTest.java?rev=1495773&r1=1495772&r2=1495773&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/DataContextPrefetchTest.java (original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/DataContextPrefetchTest.java Sat Jun 22 19:36:53 2013
@@ -83,15 +83,8 @@ public class DataContextPrefetchTest ext
tArtist.setColumns("ARTIST_ID", "ARTIST_NAME");
tPainting = new TableHelper(dbHelper, "PAINTING");
- tPainting.setColumns(
- "PAINTING_ID",
- "PAINTING_TITLE",
- "ARTIST_ID",
- "ESTIMATED_PRICE").setColumnTypes(
- Types.INTEGER,
- Types.VARCHAR,
- Types.BIGINT,
- Types.DECIMAL);
+ tPainting.setColumns("PAINTING_ID", "PAINTING_TITLE", "ARTIST_ID", "ESTIMATED_PRICE").setColumnTypes(
+ Types.INTEGER, Types.VARCHAR, Types.BIGINT, Types.DECIMAL);
tPaintingInfo = new TableHelper(dbHelper, "PAINTING_INFO");
tPaintingInfo.setColumns("PAINTING_ID", "TEXT_REVIEW");
@@ -143,7 +136,7 @@ public class DataContextPrefetchTest ext
tArtistExhibit.insert(101, 3);
tArtistExhibit.insert(101, 4);
}
-
+
public void testPrefetchToMany_ViaProperty() throws Exception {
createTwoArtistsAndTwoPaintingsDataSet();
@@ -166,8 +159,7 @@ public class DataContextPrefetchTest ext
assertEquals(1, toMany.size());
Painting p = (Painting) toMany.get(0);
- assertEquals("Invalid prefetched painting:" + p, "p_"
- + a.getArtistName(), p.getPaintingTitle());
+ assertEquals("Invalid prefetched painting:" + p, "p_" + a.getArtistName(), p.getPaintingTitle());
}
}
});
@@ -179,8 +171,7 @@ public class DataContextPrefetchTest ext
Map<String, Object> params = new HashMap<String, Object>();
params.put("name1", "artist2");
params.put("name2", "artist3");
- Expression e = Expression
- .fromString("artistName = $name1 or artistName = $name2");
+ Expression e = Expression.fromString("artistName = $name1 or artistName = $name2");
SelectQuery q = new SelectQuery("Artist", e.expWithParameters(params));
q.addPrefetch(Artist.PAINTING_ARRAY_PROPERTY);
@@ -193,8 +184,7 @@ public class DataContextPrefetchTest ext
assertEquals(2, artists.size());
Artist a1 = artists.get(0);
- List<?> toMany = (List<?>) a1
- .readPropertyDirectly(Artist.PAINTING_ARRAY_PROPERTY);
+ List<?> toMany = (List<?>) a1.readPropertyDirectly(Artist.PAINTING_ARRAY_PROPERTY);
assertNotNull(toMany);
assertFalse(((ValueHolder) toMany).isFault());
assertEquals(1, toMany.size());
@@ -203,8 +193,7 @@ public class DataContextPrefetchTest ext
assertEquals("p_" + a1.getArtistName(), p1.getPaintingTitle());
Artist a2 = artists.get(1);
- List<?> toMany2 = (List<?>) a2
- .readPropertyDirectly(Artist.PAINTING_ARRAY_PROPERTY);
+ List<?> toMany2 = (List<?>) a2.readPropertyDirectly(Artist.PAINTING_ARRAY_PROPERTY);
assertNotNull(toMany2);
assertFalse(((ValueHolder) toMany2).isFault());
assertEquals(1, toMany2.size());
@@ -237,24 +226,22 @@ public class DataContextPrefetchTest ext
assertEquals(1, toMany.size());
Painting p = (Painting) toMany.get(0);
- assertEquals("Invalid prefetched painting:" + p, "p_"
- + a.getArtistName(), p.getPaintingTitle());
+ assertEquals("Invalid prefetched painting:" + p, "p_" + a.getArtistName(), p.getPaintingTitle());
}
}
});
}
-
+
/**
- * Test that a to-many relationship is initialized when a target entity has a compound
- * PK only partially involved in relationship.
+ * Test that a to-many relationship is initialized when a target entity has
+ * a compound PK only partially involved in relationship.
*/
public void testPrefetchToMany_OnJoinTableDisjoinedPrefetch() throws Exception {
createTwoArtistsWithExhibitsDataSet();
SelectQuery q = new SelectQuery(Artist.class);
- q.addPrefetch(Artist.ARTIST_EXHIBIT_ARRAY_PROPERTY).setSemantics(
- PrefetchTreeNode.DISJOINT_PREFETCH_SEMANTICS);
+ q.addPrefetch(Artist.ARTIST_EXHIBIT_ARRAY_PROPERTY).setSemantics(PrefetchTreeNode.DISJOINT_PREFETCH_SEMANTICS);
q.addOrdering(Artist.ARTIST_NAME_PROPERTY, SortOrder.ASCENDING);
final List<Artist> artists = context.performQuery(q);
@@ -266,34 +253,29 @@ public class DataContextPrefetchTest ext
Artist a1 = artists.get(0);
assertEquals("artist2", a1.getArtistName());
- List<?> toMany = (List<?>) a1
- .readPropertyDirectly(Artist.ARTIST_EXHIBIT_ARRAY_PROPERTY);
+ List<?> toMany = (List<?>) a1.readPropertyDirectly(Artist.ARTIST_EXHIBIT_ARRAY_PROPERTY);
assertNotNull(toMany);
assertFalse(((ValueHolder) toMany).isFault());
assertEquals(2, toMany.size());
ArtistExhibit artistExhibit = (ArtistExhibit) toMany.get(0);
- assertEquals(PersistenceState.COMMITTED, artistExhibit
- .getPersistenceState());
+ assertEquals(PersistenceState.COMMITTED, artistExhibit.getPersistenceState());
assertSame(a1, artistExhibit.getToArtist());
Artist a2 = artists.get(1);
assertEquals("artist3", a2.getArtistName());
- List<?> toMany2 = (List<?>) a2
- .readPropertyDirectly(Artist.ARTIST_EXHIBIT_ARRAY_PROPERTY);
+ List<?> toMany2 = (List<?>) a2.readPropertyDirectly(Artist.ARTIST_EXHIBIT_ARRAY_PROPERTY);
assertNotNull(toMany2);
assertFalse(((ValueHolder) toMany2).isFault());
assertEquals(3, toMany2.size());
ArtistExhibit artistExhibit2 = (ArtistExhibit) toMany2.get(0);
- assertEquals(PersistenceState.COMMITTED, artistExhibit2
- .getPersistenceState());
+ assertEquals(PersistenceState.COMMITTED, artistExhibit2.getPersistenceState());
assertSame(a2, artistExhibit2.getToArtist());
}
});
}
-
-
+
public void testPrefetchToManyOnJoinTableJoinedPrefetch_ViaProperty() throws Exception {
createTwoArtistsWithExhibitsDataSet();
@@ -335,15 +317,14 @@ public class DataContextPrefetchTest ext
}
/**
- * Test that a to-many relationship is initialized when a target entity has a compound
- * PK only partially involved in relationship.
+ * Test that a to-many relationship is initialized when a target entity has
+ * a compound PK only partially involved in relationship.
*/
public void testPrefetchToManyOnJoinTableJoinedPrefetch() throws Exception {
createTwoArtistsWithExhibitsDataSet();
SelectQuery q = new SelectQuery(Artist.class);
- q.addPrefetch("artistExhibitArray").setSemantics(
- PrefetchTreeNode.JOINT_PREFETCH_SEMANTICS);
+ q.addPrefetch("artistExhibitArray").setSemantics(PrefetchTreeNode.JOINT_PREFETCH_SEMANTICS);
q.addOrdering(Artist.ARTIST_NAME_PROPERTY, SortOrder.ASCENDING);
final List<Artist> artists = context.performQuery(q);
@@ -362,21 +343,18 @@ public class DataContextPrefetchTest ext
assertEquals(2, toMany.size());
ArtistExhibit artistExhibit = (ArtistExhibit) toMany.get(0);
- assertEquals(PersistenceState.COMMITTED, artistExhibit
- .getPersistenceState());
+ assertEquals(PersistenceState.COMMITTED, artistExhibit.getPersistenceState());
assertSame(a1, artistExhibit.getToArtist());
Artist a2 = artists.get(1);
assertEquals("artist3", a2.getArtistName());
- List<?> toMany2 = (List<?>) a2
- .readPropertyDirectly(Artist.ARTIST_EXHIBIT_ARRAY_PROPERTY);
+ List<?> toMany2 = (List<?>) a2.readPropertyDirectly(Artist.ARTIST_EXHIBIT_ARRAY_PROPERTY);
assertNotNull(toMany2);
assertFalse(((ValueHolder) toMany2).isFault());
assertEquals(3, toMany2.size());
ArtistExhibit artistExhibit2 = (ArtistExhibit) toMany2.get(0);
- assertEquals(PersistenceState.COMMITTED, artistExhibit2
- .getPersistenceState());
+ assertEquals(PersistenceState.COMMITTED, artistExhibit2.getPersistenceState());
assertSame(a2, artistExhibit2.getToArtist());
}
});
@@ -389,10 +367,8 @@ public class DataContextPrefetchTest ext
public void testPrefetch_ToManyNoReverse() throws Exception {
createTwoArtistsAndTwoPaintingsDataSet();
- ObjEntity paintingEntity = context.getEntityResolver().lookupObjEntity(
- Painting.class);
- ObjRelationship relationship = (ObjRelationship) paintingEntity
- .getRelationship("toArtist");
+ ObjEntity paintingEntity = context.getEntityResolver().getObjEntity(Painting.class);
+ ObjRelationship relationship = (ObjRelationship) paintingEntity.getRelationship("toArtist");
paintingEntity.removeRelationship("toArtist");
try {
@@ -410,8 +386,7 @@ public class DataContextPrefetchTest ext
assertFalse(((ValueHolder) toMany).isFault());
}
});
- }
- finally {
+ } finally {
paintingEntity.addRelationship(relationship);
}
}
@@ -419,10 +394,8 @@ public class DataContextPrefetchTest ext
public void testPrefetch_ToManyNoReverseWithQualifier() throws Exception {
createTwoArtistsAndTwoPaintingsDataSet();
- ObjEntity paintingEntity = context.getEntityResolver().lookupObjEntity(
- Painting.class);
- ObjRelationship relationship = (ObjRelationship) paintingEntity
- .getRelationship("toArtist");
+ ObjEntity paintingEntity = context.getEntityResolver().getObjEntity(Painting.class);
+ ObjRelationship relationship = (ObjRelationship) paintingEntity.getRelationship("toArtist");
paintingEntity.removeRelationship("toArtist");
try {
@@ -444,8 +417,7 @@ public class DataContextPrefetchTest ext
}
});
- }
- finally {
+ } finally {
paintingEntity.addRelationship(relationship);
}
}
@@ -466,8 +438,7 @@ public class DataContextPrefetchTest ext
Object toOnePrefetch = p1.readNestedProperty("toArtist");
assertNotNull(toOnePrefetch);
- assertTrue(
- "Expected Artist, got: " + toOnePrefetch.getClass().getName(),
+ assertTrue("Expected Artist, got: " + toOnePrefetch.getClass().getName(),
toOnePrefetch instanceof Artist);
Artist a1 = (Artist) toOnePrefetch;
@@ -520,9 +491,7 @@ public class DataContextPrefetchTest ext
ArtGroup fetchedChild = results.get(0);
// The parent must be fully fetched, not just HOLLOW (a fault)
- assertEquals(PersistenceState.COMMITTED, fetchedChild
- .getToParentGroup()
- .getPersistenceState());
+ assertEquals(PersistenceState.COMMITTED, fetchedChild.getToParentGroup().getPersistenceState());
}
});
}
@@ -545,9 +514,7 @@ public class DataContextPrefetchTest ext
Painting painting = results.get(0);
// The parent must be fully fetched, not just HOLLOW (a fault)
- assertEquals(PersistenceState.COMMITTED, painting
- .getToArtist()
- .getPersistenceState());
+ assertEquals(PersistenceState.COMMITTED, painting.getToArtist().getPersistenceState());
}
});
}
@@ -559,7 +526,8 @@ public class DataContextPrefetchTest ext
SelectQuery artistQuery = new SelectQuery(Artist.class, artistExp);
Artist artist1 = (Artist) context.performQuery(artistQuery).get(0);
- // find the painting not matching the artist (this is the case where such prefetch
+ // find the painting not matching the artist (this is the case where
+ // such prefetch
// at least makes sense)
Expression exp = ExpressionFactory.noMatchExp("toArtist", artist1);
@@ -623,7 +591,8 @@ public class DataContextPrefetchTest ext
SelectQuery q = new SelectQuery(Artist.class, e);
q.addPrefetch("paintingArray");
- // prefetch with query using date in qualifier used to fail on SQL Server
+ // prefetch with query using date in qualifier used to fail on SQL
+ // Server
// see CAY-119 for details
context.performQuery(q);
}
@@ -660,7 +629,8 @@ public class DataContextPrefetchTest ext
queryInterceptor.runWithQueriesBlocked(new UnitTestClosure() {
public void execute() {
- // per CAY-499 second run of a cached query with prefetches (i.e. when the
+ // per CAY-499 second run of a cached query with prefetches
+ // (i.e. when the
// result is served from cache) used to throw an exception...
List<Painting> cachedResult = context.performQuery(q);
@@ -670,8 +640,7 @@ public class DataContextPrefetchTest ext
Object toOnePrefetch = p1.readNestedProperty("toArtist");
assertNotNull(toOnePrefetch);
- assertTrue(
- "Expected Artist, got: " + toOnePrefetch.getClass().getName(),
+ assertTrue("Expected Artist, got: " + toOnePrefetch.getClass().getName(),
toOnePrefetch instanceof Artist);
Artist a1 = (Artist) toOnePrefetch;
@@ -695,7 +664,8 @@ public class DataContextPrefetchTest ext
queryInterceptor.runWithQueriesBlocked(new UnitTestClosure() {
public void execute() {
- // per CAY-499 second run of a cached query with prefetches (i.e. when the
+ // per CAY-499 second run of a cached query with prefetches
+ // (i.e. when the
// result is served from cache) used to throw an exception...
List<Painting> cachedResult = context.performQuery(q);
@@ -705,8 +675,7 @@ public class DataContextPrefetchTest ext
Object toOnePrefetch = p1.readNestedProperty("toArtist");
assertNotNull(toOnePrefetch);
- assertTrue(
- "Expected Artist, got: " + toOnePrefetch.getClass().getName(),
+ assertTrue("Expected Artist, got: " + toOnePrefetch.getClass().getName(),
toOnePrefetch instanceof Artist);
Artist a1 = (Artist) toOnePrefetch;
Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/DeleteObjectTest.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/DeleteObjectTest.java?rev=1495773&r1=1495772&r2=1495773&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/DeleteObjectTest.java (original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/DeleteObjectTest.java Sat Jun 22 19:36:53 2013
@@ -113,7 +113,8 @@ public class DeleteObjectTest extends Se
}
}
- // Similar to testDeleteObjects2, but extract ObjectContext instead of DataContext.
+ // Similar to testDeleteObjects2, but extract ObjectContext instead of
+ // DataContext.
public void testDeleteObjects2() throws Exception {
createObjectsDataSet();
@@ -154,11 +155,10 @@ public class DeleteObjectTest extends Se
context.deleteObjects(paintings);
- // as Painting -> Artist has Nullify rule, relationship list has to be cleaned up,
+ // as Painting -> Artist has Nullify rule, relationship list has to be
+ // cleaned up,
// and no exceptions thrown on concurrent modification...
- ObjRelationship r = (ObjRelationship) context
- .getEntityResolver()
- .lookupObjEntity(Painting.class)
+ ObjRelationship r = (ObjRelationship) context.getEntityResolver().getObjEntity(Painting.class)
.getRelationship("toArtist");
assertEquals(DeleteRule.NULLIFY, r.getDeleteRule());
assertEquals(0, paintings.size());
Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/DeleteRulesTest.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/DeleteRulesTest.java?rev=1495773&r1=1495772&r2=1495773&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/DeleteRulesTest.java (original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/DeleteRulesTest.java Sat Jun 22 19:36:53 2013
@@ -68,8 +68,7 @@ public class DeleteRulesTest extends Ser
try {
context.deleteObjects(test1);
fail("Should have thrown an exception");
- }
- catch (Exception e) {
+ } catch (Exception e) {
// GOOD!
}
context.commitChanges();
@@ -120,8 +119,7 @@ public class DeleteRulesTest extends Ser
assertTrue(b.getUntitledRel().contains(a));
context.commitChanges();
- }
- finally {
+ } finally {
changeDeleteRule(oldRule);
}
}
@@ -146,8 +144,7 @@ public class DeleteRulesTest extends Ser
assertEquals(PersistenceState.DELETED, a.getPersistenceState());
assertEquals(PersistenceState.COMMITTED, b.getPersistenceState());
context.commitChanges();
- }
- finally {
+ } finally {
changeDeleteRule(oldRule);
restoreReverse(reverse);
}
@@ -172,8 +169,7 @@ public class DeleteRulesTest extends Ser
assertEquals(PersistenceState.TRANSIENT, a.getPersistenceState());
assertEquals(PersistenceState.TRANSIENT, b.getPersistenceState());
- }
- finally {
+ } finally {
changeDeleteRule(oldRule);
}
}
@@ -197,8 +193,7 @@ public class DeleteRulesTest extends Ser
context.commitChanges();
assertEquals(PersistenceState.TRANSIENT, a.getPersistenceState());
assertEquals(PersistenceState.TRANSIENT, b.getPersistenceState());
- }
- finally {
+ } finally {
changeDeleteRule(oldRule);
restoreReverse(reverse);
}
@@ -223,8 +218,7 @@ public class DeleteRulesTest extends Ser
assertEquals(PersistenceState.MODIFIED, b.getPersistenceState());
assertFalse(b.getUntitledRel().contains(a));
context.commitChanges();
- }
- finally {
+ } finally {
changeDeleteRule(oldRule);
}
}
@@ -248,8 +242,7 @@ public class DeleteRulesTest extends Ser
assertEquals(PersistenceState.DELETED, a.getPersistenceState());
assertEquals(PersistenceState.COMMITTED, b.getPersistenceState());
context.commitChanges();
- }
- finally {
+ } finally {
changeDeleteRule(oldRule);
restoreReverse(reverse);
}
@@ -268,13 +261,11 @@ public class DeleteRulesTest extends Ser
try {
context.deleteObjects(a);
fail("Must have thrown a deny exception..");
- }
- catch (DeleteDenyException ex) {
+ } catch (DeleteDenyException ex) {
// expected... but check further
assertJoinNotDeleted(a, b);
}
- }
- finally {
+ } finally {
changeDeleteRule(oldRule);
}
}
@@ -293,59 +284,47 @@ public class DeleteRulesTest extends Ser
try {
context.deleteObjects(a);
fail("Must have thrown a deny exception..");
- }
- catch (DeleteDenyException ex) {
+ } catch (DeleteDenyException ex) {
// expected... but check further
assertJoinNotDeleted(a, b);
}
- }
- finally {
+ } finally {
changeDeleteRule(oldRule);
restoreReverse(reverse);
}
}
private int changeDeleteRule(int deleteRule) {
- ObjEntity entity = context.getEntityResolver().lookupObjEntity(
- DeleteRuleFlatA.class);
+ ObjEntity entity = context.getEntityResolver().getObjEntity(DeleteRuleFlatA.class);
- ObjRelationship relationship = (ObjRelationship) entity
- .getRelationship(DeleteRuleFlatA.FLAT_B_PROPERTY);
+ ObjRelationship relationship = (ObjRelationship) entity.getRelationship(DeleteRuleFlatA.FLAT_B_PROPERTY);
int oldRule = relationship.getDeleteRule();
relationship.setDeleteRule(deleteRule);
return oldRule;
}
private ObjRelationship unsetReverse() {
- ObjEntity entity = context.getEntityResolver().lookupObjEntity(
- DeleteRuleFlatA.class);
+ ObjEntity entity = context.getEntityResolver().getObjEntity(DeleteRuleFlatA.class);
- ObjRelationship relationship = (ObjRelationship) entity
- .getRelationship(DeleteRuleFlatA.FLAT_B_PROPERTY);
+ ObjRelationship relationship = (ObjRelationship) entity.getRelationship(DeleteRuleFlatA.FLAT_B_PROPERTY);
ObjRelationship reverse = relationship.getReverseRelationship();
if (reverse != null) {
reverse.getSourceEntity().removeRelationship(reverse.getName());
- context.getEntityResolver().getClassDescriptorMap().removeDescriptor(
- "DeleteRuleFlatA");
- context.getEntityResolver().getClassDescriptorMap().removeDescriptor(
- "DeleteRuleFlatB");
+ context.getEntityResolver().getClassDescriptorMap().removeDescriptor("DeleteRuleFlatA");
+ context.getEntityResolver().getClassDescriptorMap().removeDescriptor("DeleteRuleFlatB");
}
return reverse;
}
private void restoreReverse(ObjRelationship reverse) {
- ObjEntity entity = context.getEntityResolver().lookupObjEntity(
- DeleteRuleFlatA.class);
+ ObjEntity entity = context.getEntityResolver().getObjEntity(DeleteRuleFlatA.class);
- ObjRelationship relationship = (ObjRelationship) entity
- .getRelationship(DeleteRuleFlatA.FLAT_B_PROPERTY);
+ ObjRelationship relationship = (ObjRelationship) entity.getRelationship(DeleteRuleFlatA.FLAT_B_PROPERTY);
relationship.getTargetEntity().addRelationship(reverse);
- context.getEntityResolver().getClassDescriptorMap().removeDescriptor(
- "DeleteRuleFlatA");
- context.getEntityResolver().getClassDescriptorMap().removeDescriptor(
- "DeleteRuleFlatB");
+ context.getEntityResolver().getClassDescriptorMap().removeDescriptor("DeleteRuleFlatA");
+ context.getEntityResolver().getClassDescriptorMap().removeDescriptor("DeleteRuleFlatB");
}
private void assertJoinDeleted(DeleteRuleFlatA a, DeleteRuleFlatB b) {
@@ -362,8 +341,7 @@ public class DeleteRulesTest extends Ser
ArcOperation arcDelete = (ArcOperation) diff;
if (arcDelete.getNodeId().equals(a.getObjectId())
&& arcDelete.getTargetNodeId().equals(b.getObjectId())
- && arcDelete.getArcId().equals(DeleteRuleFlatA.FLAT_B_PROPERTY)
- && arcDelete.isDelete()) {
+ && arcDelete.getArcId().equals(DeleteRuleFlatA.FLAT_B_PROPERTY) && arcDelete.isDelete()) {
return;
}
}
@@ -385,9 +363,7 @@ public class DeleteRulesTest extends Ser
ArcOperation arcDelete = (ArcOperation) diff;
if (arcDelete.getNodeId().equals(a.getObjectId())
&& arcDelete.getTargetNodeId().equals(b.getObjectId())
- && arcDelete.getArcId().equals(
- DeleteRuleFlatA.FLAT_B_PROPERTY)
- && !arcDelete.isDelete()) {
+ && arcDelete.getArcId().equals(DeleteRuleFlatA.FLAT_B_PROPERTY) && !arcDelete.isDelete()) {
fail("Join was deleted for flattened relationship");
}
}
Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/FlattenedArcKeyTest.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/FlattenedArcKeyTest.java?rev=1495773&r1=1495772&r2=1495773&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/FlattenedArcKeyTest.java (original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/FlattenedArcKeyTest.java Sat Jun 22 19:36:53 2013
@@ -37,8 +37,7 @@ public class FlattenedArcKeyTest extends
public void testAttributes() {
ObjectId src = new ObjectId("X");
ObjectId target = new ObjectId("Y");
- ObjRelationship r1 = (ObjRelationship) entityResolver.lookupObjEntity(
- FlattenedTest3.class).getRelationship(
+ ObjRelationship r1 = (ObjRelationship) entityResolver.getObjEntity(FlattenedTest3.class).getRelationship(
FlattenedTest3.TO_FT1_PROPERTY);
FlattenedArcKey update = new FlattenedArcKey(src, target, r1);
@@ -47,20 +46,17 @@ public class FlattenedArcKeyTest extends
assertSame(target, update.id2.getSourceId());
assertSame(r1, update.relationship);
}
-
+
public void testHashCode() {
ObjectId src = new ObjectId("X");
ObjectId target = new ObjectId("Y");
- ObjRelationship r1 = (ObjRelationship) entityResolver.lookupObjEntity(
- FlattenedTest3.class).getRelationship(
+ ObjRelationship r1 = (ObjRelationship) entityResolver.getObjEntity(FlattenedTest3.class).getRelationship(
FlattenedTest3.TO_FT1_PROPERTY);
FlattenedArcKey update = new FlattenedArcKey(src, target, r1);
- FlattenedArcKey update1 = new FlattenedArcKey(target, src,
- r1.getReverseRelationship());
+ FlattenedArcKey update1 = new FlattenedArcKey(target, src, r1.getReverseRelationship());
- ObjRelationship r3 = (ObjRelationship) entityResolver.lookupObjEntity(
- FlattenedTest1.class).getRelationship(
+ ObjRelationship r3 = (ObjRelationship) entityResolver.getObjEntity(FlattenedTest1.class).getRelationship(
FlattenedTest1.FT3OVER_COMPLEX_PROPERTY);
FlattenedArcKey update2 = new FlattenedArcKey(target, src, r3);
@@ -76,16 +72,13 @@ public class FlattenedArcKeyTest extends
public void testEquals() {
ObjectId src = new ObjectId("X");
ObjectId target = new ObjectId("Y");
- ObjRelationship r1 = (ObjRelationship) entityResolver.lookupObjEntity(
- FlattenedTest3.class).getRelationship(
+ ObjRelationship r1 = (ObjRelationship) entityResolver.getObjEntity(FlattenedTest3.class).getRelationship(
FlattenedTest3.TO_FT1_PROPERTY);
FlattenedArcKey update = new FlattenedArcKey(src, target, r1);
- FlattenedArcKey update1 = new FlattenedArcKey(target, src,
- r1.getReverseRelationship());
+ FlattenedArcKey update1 = new FlattenedArcKey(target, src, r1.getReverseRelationship());
- ObjRelationship r3 = (ObjRelationship) entityResolver.lookupObjEntity(
- FlattenedTest1.class).getRelationship(
+ ObjRelationship r3 = (ObjRelationship) entityResolver.getObjEntity(FlattenedTest1.class).getRelationship(
FlattenedTest1.FT3OVER_COMPLEX_PROPERTY);
FlattenedArcKey update2 = new FlattenedArcKey(target, src, r3);
Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/QuotedIdentifiersTest.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/QuotedIdentifiersTest.java?rev=1495773&r1=1495772&r2=1495773&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/QuotedIdentifiersTest.java (original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/QuotedIdentifiersTest.java Sat Jun 22 19:36:53 2013
@@ -88,7 +88,7 @@ public class QuotedIdentifiersTest exten
public void testPrefetchQuote() throws Exception {
DbEntity entity = context
.getEntityResolver()
- .lookupObjEntity(QuoteAdress.class)
+ .getObjEntity(QuoteAdress.class)
.getDbEntity();
List idAttributes = Collections.singletonList(entity.getAttribute("City"));
List updatedAttributes = Collections.singletonList(entity.getAttribute("City"));
Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/jdbc/BatchActionLockingTest.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/jdbc/BatchActionLockingTest.java?rev=1495773&r1=1495772&r2=1495773&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/jdbc/BatchActionLockingTest.java (original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/jdbc/BatchActionLockingTest.java Sat Jun 22 19:36:53 2013
@@ -64,7 +64,7 @@ public class BatchActionLockingTest exte
JdbcAdapter adapter = buildAdapter(true);
DbEntity dbEntity = resolver
- .lookupObjEntity(SimpleLockingTestEntity.class)
+ .getObjEntity(SimpleLockingTestEntity.class)
.getDbEntity();
List<DbAttribute> qualifierAttributes = Arrays.asList((DbAttribute) dbEntity
@@ -112,7 +112,7 @@ public class BatchActionLockingTest exte
JdbcAdapter adapter = buildAdapter(true);
DbEntity dbEntity = resolver
- .lookupObjEntity(SimpleLockingTestEntity.class)
+ .getObjEntity(SimpleLockingTestEntity.class)
.getDbEntity();
List<DbAttribute> qualifierAttributes = Arrays.asList((DbAttribute) dbEntity
Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/jdbc/BatchActionTest.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/jdbc/BatchActionTest.java?rev=1495773&r1=1495772&r2=1495773&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/jdbc/BatchActionTest.java (original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/jdbc/BatchActionTest.java Sat Jun 22 19:36:53 2013
@@ -35,7 +35,7 @@ public class BatchActionTest extends Ser
@Inject
private ServerRuntime runtime;
-
+
@Inject
private AdhocObjectFactory objectFactory;
@@ -45,12 +45,11 @@ public class BatchActionTest extends Ser
// test with adapter that supports keys
JdbcAdapter adapter = buildAdapter(true);
- InsertBatchQuery batch1 = new InsertBatchQuery(resolver.lookupObjEntity(
- GeneratedColumnTestEntity.class).getDbEntity(), 5);
+ InsertBatchQuery batch1 = new InsertBatchQuery(resolver.getObjEntity(GeneratedColumnTestEntity.class)
+ .getDbEntity(), 5);
assertTrue(new BatchAction(batch1, adapter, resolver).hasGeneratedKeys());
- InsertBatchQuery batch2 = new InsertBatchQuery(resolver.lookupObjEntity(
- Artist.class).getDbEntity(), 5);
+ InsertBatchQuery batch2 = new InsertBatchQuery(resolver.getObjEntity(Artist.class).getDbEntity(), 5);
assertFalse(new BatchAction(batch2, adapter, resolver).hasGeneratedKeys());
}
@@ -60,19 +59,16 @@ public class BatchActionTest extends Ser
// test with adapter that does not support keys...
JdbcAdapter adapter = buildAdapter(false);
- InsertBatchQuery batch1 = new InsertBatchQuery(resolver.lookupObjEntity(
- GeneratedColumnTestEntity.class).getDbEntity(), 5);
+ InsertBatchQuery batch1 = new InsertBatchQuery(resolver.getObjEntity(GeneratedColumnTestEntity.class)
+ .getDbEntity(), 5);
assertFalse(new BatchAction(batch1, adapter, resolver).hasGeneratedKeys());
- InsertBatchQuery batch2 = new InsertBatchQuery(resolver.lookupObjEntity(
- Artist.class).getDbEntity(), 5);
+ InsertBatchQuery batch2 = new InsertBatchQuery(resolver.getObjEntity(Artist.class).getDbEntity(), 5);
assertFalse(new BatchAction(batch2, adapter, resolver).hasGeneratedKeys());
}
JdbcAdapter buildAdapter(boolean supportGeneratedKeys) {
- JdbcAdapter adapter = objectFactory.newInstance(
- JdbcAdapter.class,
- JdbcAdapter.class.getName());
+ JdbcAdapter adapter = objectFactory.newInstance(JdbcAdapter.class, JdbcAdapter.class.getName());
adapter.setSupportsGeneratedKeys(supportGeneratedKeys);
return adapter;
}
Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/jdbc/SoftDeleteBatchQueryBuilderTest.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/jdbc/SoftDeleteBatchQueryBuilderTest.java?rev=1495773&r1=1495772&r2=1495773&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/jdbc/SoftDeleteBatchQueryBuilderTest.java (original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/jdbc/SoftDeleteBatchQueryBuilderTest.java Sat Jun 22 19:36:53 2013
@@ -50,86 +50,60 @@ public class SoftDeleteBatchQueryBuilder
@Inject
protected DbAdapter adapter;
-
+
@Inject
private UnitDbAdapter unitAdapter;
-
+
@Inject
private AdhocObjectFactory objectFactory;
private DeleteBatchQueryBuilder createBuilder() {
- JdbcAdapter adapter = objectFactory.newInstance(
- JdbcAdapter.class,
- JdbcAdapter.class.getName());
+ JdbcAdapter adapter = objectFactory.newInstance(JdbcAdapter.class, JdbcAdapter.class.getName());
return createBuilder(adapter);
}
private DeleteBatchQueryBuilder createBuilder(JdbcAdapter adapter) {
- return (DeleteBatchQueryBuilder) new SoftDeleteQueryBuilderFactory()
- .createDeleteQueryBuilder(adapter);
+ return (DeleteBatchQueryBuilder) new SoftDeleteQueryBuilderFactory().createDeleteQueryBuilder(adapter);
}
public void testCreateSqlString() throws Exception {
- DbEntity entity = context
- .getEntityResolver()
- .lookupObjEntity(SoftTest.class)
- .getDbEntity();
+ DbEntity entity = context.getEntityResolver().getObjEntity(SoftTest.class).getDbEntity();
- List<DbAttribute> idAttributes = Collections.singletonList((DbAttribute) entity
- .getAttribute("SOFT_TEST_ID"));
+ List<DbAttribute> idAttributes = Collections.singletonList((DbAttribute) entity.getAttribute("SOFT_TEST_ID"));
DeleteBatchQuery deleteQuery = new DeleteBatchQuery(entity, idAttributes, null, 1);
DeleteBatchQueryBuilder builder = createBuilder();
String generatedSql = builder.createSqlString(deleteQuery);
assertNotNull(generatedSql);
- assertEquals("UPDATE "
- + entity.getName()
- + " SET DELETED = ? WHERE SOFT_TEST_ID = ?", generatedSql);
+ assertEquals("UPDATE " + entity.getName() + " SET DELETED = ? WHERE SOFT_TEST_ID = ?", generatedSql);
}
public void testCreateSqlStringWithNulls() throws Exception {
- DbEntity entity = context
- .getEntityResolver()
- .lookupObjEntity(SoftTest.class)
- .getDbEntity();
+ DbEntity entity = context.getEntityResolver().getObjEntity(SoftTest.class).getDbEntity();
- List<DbAttribute> idAttributes = Arrays.asList((DbAttribute) entity
- .getAttribute("SOFT_TEST_ID"), (DbAttribute) entity.getAttribute("NAME"));
+ List<DbAttribute> idAttributes = Arrays.asList((DbAttribute) entity.getAttribute("SOFT_TEST_ID"),
+ (DbAttribute) entity.getAttribute("NAME"));
Collection<String> nullAttributes = Collections.singleton("NAME");
- DeleteBatchQuery deleteQuery = new DeleteBatchQuery(
- entity,
- idAttributes,
- nullAttributes,
- 1);
+ DeleteBatchQuery deleteQuery = new DeleteBatchQuery(entity, idAttributes, nullAttributes, 1);
DeleteBatchQueryBuilder builder = createBuilder();
String generatedSql = builder.createSqlString(deleteQuery);
assertNotNull(generatedSql);
- assertEquals(
- "UPDATE "
- + entity.getName()
- + " SET DELETED = ? WHERE SOFT_TEST_ID = ? AND NAME IS NULL",
+ assertEquals("UPDATE " + entity.getName() + " SET DELETED = ? WHERE SOFT_TEST_ID = ? AND NAME IS NULL",
generatedSql);
}
public void testCreateSqlStringWithIdentifiersQuote() throws Exception {
- DbEntity entity = context
- .getEntityResolver()
- .lookupObjEntity(SoftTest.class)
- .getDbEntity();
+ DbEntity entity = context.getEntityResolver().getObjEntity(SoftTest.class).getDbEntity();
try {
entity.getDataMap().setQuotingSQLIdentifiers(true);
- List<DbAttribute> idAttributes = Collections
- .singletonList((DbAttribute) entity.getAttribute("SOFT_TEST_ID"));
+ List<DbAttribute> idAttributes = Collections.singletonList((DbAttribute) entity
+ .getAttribute("SOFT_TEST_ID"));
- DeleteBatchQuery deleteQuery = new DeleteBatchQuery(
- entity,
- idAttributes,
- null,
- 1);
+ DeleteBatchQuery deleteQuery = new DeleteBatchQuery(entity, idAttributes, null, 1);
JdbcAdapter adapter = (JdbcAdapter) this.adapter;
DeleteBatchQueryBuilder builder = createBuilder(adapter);
String generatedSql = builder.createSqlString(deleteQuery);
@@ -138,21 +112,9 @@ public class SoftDeleteBatchQueryBuilder
String charEnd = unitAdapter.getIdentifiersEndQuote();
assertNotNull(generatedSql);
- assertEquals("UPDATE "
- + charStart
- + entity.getName()
- + charEnd
- + " SET "
- + charStart
- + "DELETED"
- + charEnd
- + " = ? WHERE "
- + charStart
- + "SOFT_TEST_ID"
- + charEnd
- + " = ?", generatedSql);
- }
- finally {
+ assertEquals("UPDATE " + charStart + entity.getName() + charEnd + " SET " + charStart + "DELETED" + charEnd
+ + " = ? WHERE " + charStart + "SOFT_TEST_ID" + charEnd + " = ?", generatedSql);
+ } finally {
entity.getDataMap().setQuotingSQLIdentifiers(false);
}
@@ -160,8 +122,7 @@ public class SoftDeleteBatchQueryBuilder
public void testUpdate() throws Exception {
- final DbEntity entity = context.getEntityResolver().lookupObjEntity(
- SoftTest.class).getDbEntity();
+ final DbEntity entity = context.getEntityResolver().getObjEntity(SoftTest.class).getDbEntity();
JdbcAdapter adapter = (JdbcAdapter) this.adapter;
BatchQueryBuilderFactory oldFactory = adapter.getBatchQueryBuilderFactory();
@@ -178,9 +139,7 @@ public class SoftDeleteBatchQueryBuilder
@Override
protected void assertResult() throws Exception {
- query
- .setQualifier(ExpressionFactory.matchExp("name", test
- .getName()));
+ query.setQualifier(ExpressionFactory.matchExp("name", test.getName()));
assertEquals(1, context.performQuery(query).size());
query.andQualifier(ExpressionFactory.matchDbExp("DELETED", true));
@@ -196,20 +155,15 @@ public class SoftDeleteBatchQueryBuilder
@Override
protected void assertResult() throws Exception {
- query
- .setQualifier(ExpressionFactory.matchExp("name", test
- .getName()));
+ query.setQualifier(ExpressionFactory.matchExp("name", test.getName()));
assertEquals(0, context.performQuery(query).size());
- SQLTemplate template = new SQLTemplate(
- entity,
- "SELECT * FROM SOFT_TEST");
+ SQLTemplate template = new SQLTemplate(entity, "SELECT * FROM SOFT_TEST");
template.setFetchingDataRows(true);
assertEquals(1, context.performQuery(template).size());
}
}.runTest(200);
- }
- finally {
+ } finally {
context.performQuery(new SQLTemplate(entity, "DELETE FROM SOFT_TEST"));
adapter.setBatchQueryBuilderFactory(oldFactory);
}
Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/trans/DeleteBatchQueryBuilderTest.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/trans/DeleteBatchQueryBuilderTest.java?rev=1495773&r1=1495772&r2=1495773&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/trans/DeleteBatchQueryBuilderTest.java (original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/trans/DeleteBatchQueryBuilderTest.java Sat Jun 22 19:36:53 2013
@@ -45,17 +45,15 @@ public class DeleteBatchQueryBuilderTest
@Inject
private DbAdapter adapter;
-
+
@Inject
private UnitDbAdapter unitAdapter;
-
+
@Inject
private AdhocObjectFactory objectFactory;
public void testConstructor() throws Exception {
- DbAdapter adapter = objectFactory.newInstance(
- DbAdapter.class,
- JdbcAdapter.class.getName());
+ DbAdapter adapter = objectFactory.newInstance(DbAdapter.class, JdbcAdapter.class.getName());
DeleteBatchQueryBuilder builder = new DeleteBatchQueryBuilder(adapter);
@@ -63,62 +61,49 @@ public class DeleteBatchQueryBuilderTest
}
public void testCreateSqlString() throws Exception {
- DbEntity entity = runtime.getDataDomain().getEntityResolver().lookupObjEntity(
- SimpleLockingTestEntity.class).getDbEntity();
+ DbEntity entity = runtime.getDataDomain().getEntityResolver().getObjEntity(SimpleLockingTestEntity.class)
+ .getDbEntity();
- List<DbAttribute> idAttributes = Collections.singletonList((DbAttribute) entity
- .getAttribute("LOCKING_TEST_ID"));
+ List<DbAttribute> idAttributes = Collections
+ .singletonList((DbAttribute) entity.getAttribute("LOCKING_TEST_ID"));
DeleteBatchQuery deleteQuery = new DeleteBatchQuery(entity, idAttributes, null, 1);
-
+
DbAdapter adapter = objectFactory.newInstance(DbAdapter.class, JdbcAdapter.class.getName());
DeleteBatchQueryBuilder builder = new DeleteBatchQueryBuilder(adapter);
String generatedSql = builder.createSqlString(deleteQuery);
assertNotNull(generatedSql);
- assertEquals(
- "DELETE FROM " + entity.getName() + " WHERE LOCKING_TEST_ID = ?",
- generatedSql);
+ assertEquals("DELETE FROM " + entity.getName() + " WHERE LOCKING_TEST_ID = ?", generatedSql);
}
public void testCreateSqlStringWithNulls() throws Exception {
- DbEntity entity = runtime.getDataDomain().getEntityResolver().lookupObjEntity(
- SimpleLockingTestEntity.class).getDbEntity();
+ DbEntity entity = runtime.getDataDomain().getEntityResolver().getObjEntity(SimpleLockingTestEntity.class)
+ .getDbEntity();
- List<DbAttribute> idAttributes = Arrays.asList((DbAttribute) entity
- .getAttribute("LOCKING_TEST_ID"), (DbAttribute) entity
- .getAttribute("NAME"));
+ List<DbAttribute> idAttributes = Arrays.asList((DbAttribute) entity.getAttribute("LOCKING_TEST_ID"),
+ (DbAttribute) entity.getAttribute("NAME"));
Collection<String> nullAttributes = Collections.singleton("NAME");
- DeleteBatchQuery deleteQuery = new DeleteBatchQuery(
- entity,
- idAttributes,
- nullAttributes,
- 1);
-
+ DeleteBatchQuery deleteQuery = new DeleteBatchQuery(entity, idAttributes, nullAttributes, 1);
+
DbAdapter adapter = objectFactory.newInstance(DbAdapter.class, JdbcAdapter.class.getName());
DeleteBatchQueryBuilder builder = new DeleteBatchQueryBuilder(adapter);
String generatedSql = builder.createSqlString(deleteQuery);
assertNotNull(generatedSql);
- assertEquals("DELETE FROM "
- + entity.getName()
- + " WHERE LOCKING_TEST_ID = ? AND NAME IS NULL", generatedSql);
+ assertEquals("DELETE FROM " + entity.getName() + " WHERE LOCKING_TEST_ID = ? AND NAME IS NULL", generatedSql);
}
public void testCreateSqlStringWithIdentifiersQuote() throws Exception {
- DbEntity entity = runtime.getDataDomain().getEntityResolver().lookupObjEntity(
- SimpleLockingTestEntity.class).getDbEntity();
+ DbEntity entity = runtime.getDataDomain().getEntityResolver().getObjEntity(SimpleLockingTestEntity.class)
+ .getDbEntity();
try {
entity.getDataMap().setQuotingSQLIdentifiers(true);
- List<DbAttribute> idAttributes = Collections
- .singletonList((DbAttribute) entity.getAttribute("LOCKING_TEST_ID"));
+ List<DbAttribute> idAttributes = Collections.singletonList((DbAttribute) entity
+ .getAttribute("LOCKING_TEST_ID"));
- DeleteBatchQuery deleteQuery = new DeleteBatchQuery(
- entity,
- idAttributes,
- null,
- 1);
+ DeleteBatchQuery deleteQuery = new DeleteBatchQuery(entity, idAttributes, null, 1);
JdbcAdapter adapter = (JdbcAdapter) this.adapter;
DeleteBatchQueryBuilder builder = new DeleteBatchQueryBuilder(adapter);
String generatedSql = builder.createSqlString(deleteQuery);
@@ -127,40 +112,27 @@ public class DeleteBatchQueryBuilderTest
String charEnd = unitAdapter.getIdentifiersEndQuote();
assertNotNull(generatedSql);
- assertEquals("DELETE FROM "
- + charStart
- + entity.getName()
- + charEnd
- + " WHERE "
- + charStart
- + "LOCKING_TEST_ID"
- + charEnd
- + " = ?", generatedSql);
- }
- finally {
+ assertEquals("DELETE FROM " + charStart + entity.getName() + charEnd + " WHERE " + charStart
+ + "LOCKING_TEST_ID" + charEnd + " = ?", generatedSql);
+ } finally {
entity.getDataMap().setQuotingSQLIdentifiers(false);
}
}
public void testCreateSqlStringWithNullsWithIdentifiersQuote() throws Exception {
- DbEntity entity = runtime.getDataDomain().getEntityResolver().lookupObjEntity(
- SimpleLockingTestEntity.class).getDbEntity();
+ DbEntity entity = runtime.getDataDomain().getEntityResolver().getObjEntity(SimpleLockingTestEntity.class)
+ .getDbEntity();
try {
entity.getDataMap().setQuotingSQLIdentifiers(true);
- List<DbAttribute> idAttributes = Arrays.asList((DbAttribute) entity
- .getAttribute("LOCKING_TEST_ID"), (DbAttribute) entity
- .getAttribute("NAME"));
+ List<DbAttribute> idAttributes = Arrays.asList((DbAttribute) entity.getAttribute("LOCKING_TEST_ID"),
+ (DbAttribute) entity.getAttribute("NAME"));
Collection<String> nullAttributes = Collections.singleton("NAME");
- DeleteBatchQuery deleteQuery = new DeleteBatchQuery(
- entity,
- idAttributes,
- nullAttributes,
- 1);
+ DeleteBatchQuery deleteQuery = new DeleteBatchQuery(entity, idAttributes, nullAttributes, 1);
JdbcAdapter adapter = (JdbcAdapter) this.adapter;
@@ -171,21 +143,10 @@ public class DeleteBatchQueryBuilderTest
String charEnd = unitAdapter.getIdentifiersEndQuote();
assertNotNull(generatedSql);
- assertEquals("DELETE FROM "
- + charStart
- + entity.getName()
- + charEnd
- + " WHERE "
- + charStart
- + "LOCKING_TEST_ID"
- + charEnd
- + " = ? AND "
- + charStart
- + "NAME"
- + charEnd
- + " IS NULL", generatedSql);
- }
- finally {
+ assertEquals("DELETE FROM " + charStart + entity.getName() + charEnd + " WHERE " + charStart
+ + "LOCKING_TEST_ID" + charEnd + " = ? AND " + charStart + "NAME" + charEnd + " IS NULL",
+ generatedSql);
+ } finally {
entity.getDataMap().setQuotingSQLIdentifiers(false);
}
}
Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/trans/InsertBatchQueryBuilderTest.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/trans/InsertBatchQueryBuilderTest.java?rev=1495773&r1=1495772&r2=1495773&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/trans/InsertBatchQueryBuilderTest.java (original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/trans/InsertBatchQueryBuilderTest.java Sat Jun 22 19:36:53 2013
@@ -54,7 +54,7 @@ public class InsertBatchQueryBuilderTest
}
public void testCreateSqlString() throws Exception {
- DbEntity entity = runtime.getDataDomain().getEntityResolver().lookupObjEntity(SimpleLockingTestEntity.class)
+ DbEntity entity = runtime.getDataDomain().getEntityResolver().getObjEntity(SimpleLockingTestEntity.class)
.getDbEntity();
DbAdapter adapter = objectFactory.newInstance(DbAdapter.class, JdbcAdapter.class.getName());
@@ -67,7 +67,7 @@ public class InsertBatchQueryBuilderTest
}
public void testCreateSqlStringWithIdentifiersQuote() throws Exception {
- DbEntity entity = runtime.getDataDomain().getEntityResolver().lookupObjEntity(SimpleLockingTestEntity.class)
+ DbEntity entity = runtime.getDataDomain().getEntityResolver().getObjEntity(SimpleLockingTestEntity.class)
.getDbEntity();
try {
Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/trans/UpdateBatchQueryBuilderTest.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/trans/UpdateBatchQueryBuilderTest.java?rev=1495773&r1=1495772&r2=1495773&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/trans/UpdateBatchQueryBuilderTest.java (original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/trans/UpdateBatchQueryBuilderTest.java Sat Jun 22 19:36:53 2013
@@ -44,94 +44,66 @@ public class UpdateBatchQueryBuilderTest
@Inject
private DbAdapter adapter;
-
+
@Inject
private UnitDbAdapter unitAdapter;
-
+
@Inject
private AdhocObjectFactory objectFactory;
public void testConstructor() throws Exception {
- DbAdapter adapter = objectFactory.newInstance(
- DbAdapter.class,
- JdbcAdapter.class.getName());
+ DbAdapter adapter = objectFactory.newInstance(DbAdapter.class, JdbcAdapter.class.getName());
UpdateBatchQueryBuilder builder = new UpdateBatchQueryBuilder(adapter);
assertSame(adapter, builder.getAdapter());
}
public void testCreateSqlString() throws Exception {
- DbEntity entity = runtime.getDataDomain().getEntityResolver().lookupObjEntity(
- SimpleLockingTestEntity.class).getDbEntity();
+ DbEntity entity = runtime.getDataDomain().getEntityResolver().getObjEntity(SimpleLockingTestEntity.class)
+ .getDbEntity();
+
+ List idAttributes = Collections.singletonList(entity.getAttribute("LOCKING_TEST_ID"));
+ List updatedAttributes = Collections.singletonList(entity.getAttribute("DESCRIPTION"));
+
+ UpdateBatchQuery updateQuery = new UpdateBatchQuery(entity, idAttributes, updatedAttributes, null, 1);
- List idAttributes = Collections.singletonList(entity
- .getAttribute("LOCKING_TEST_ID"));
- List updatedAttributes = Collections.singletonList(entity
- .getAttribute("DESCRIPTION"));
-
- UpdateBatchQuery updateQuery = new UpdateBatchQuery(
- entity,
- idAttributes,
- updatedAttributes,
- null,
- 1);
-
DbAdapter adapter = objectFactory.newInstance(DbAdapter.class, JdbcAdapter.class.getName());
UpdateBatchQueryBuilder builder = new UpdateBatchQueryBuilder(adapter);
String generatedSql = builder.createSqlString(updateQuery);
assertNotNull(generatedSql);
- assertEquals("UPDATE "
- + entity.getName()
- + " SET DESCRIPTION = ? WHERE LOCKING_TEST_ID = ?", generatedSql);
+ assertEquals("UPDATE " + entity.getName() + " SET DESCRIPTION = ? WHERE LOCKING_TEST_ID = ?", generatedSql);
}
public void testCreateSqlStringWithNulls() throws Exception {
- DbEntity entity = runtime.getDataDomain().getEntityResolver().lookupObjEntity(
- SimpleLockingTestEntity.class).getDbEntity();
+ DbEntity entity = runtime.getDataDomain().getEntityResolver().getObjEntity(SimpleLockingTestEntity.class)
+ .getDbEntity();
- List idAttributes = Arrays.asList(entity.getAttribute("LOCKING_TEST_ID"), entity
- .getAttribute("NAME"));
+ List idAttributes = Arrays.asList(entity.getAttribute("LOCKING_TEST_ID"), entity.getAttribute("NAME"));
- List updatedAttributes = Collections.singletonList(entity
- .getAttribute("DESCRIPTION"));
+ List updatedAttributes = Collections.singletonList(entity.getAttribute("DESCRIPTION"));
Collection nullAttributes = Collections.singleton("NAME");
- UpdateBatchQuery updateQuery = new UpdateBatchQuery(
- entity,
- idAttributes,
- updatedAttributes,
- nullAttributes,
- 1);
-
+ UpdateBatchQuery updateQuery = new UpdateBatchQuery(entity, idAttributes, updatedAttributes, nullAttributes, 1);
+
DbAdapter adapter = objectFactory.newInstance(DbAdapter.class, JdbcAdapter.class.getName());
UpdateBatchQueryBuilder builder = new UpdateBatchQueryBuilder(adapter);
String generatedSql = builder.createSqlString(updateQuery);
assertNotNull(generatedSql);
- assertEquals(
- "UPDATE "
- + entity.getName()
- + " SET DESCRIPTION = ? WHERE LOCKING_TEST_ID = ? AND NAME IS NULL",
+ assertEquals("UPDATE " + entity.getName() + " SET DESCRIPTION = ? WHERE LOCKING_TEST_ID = ? AND NAME IS NULL",
generatedSql);
}
public void testCreateSqlStringWithIdentifiersQuote() throws Exception {
- DbEntity entity = runtime.getDataDomain().getEntityResolver().lookupObjEntity(
- SimpleLockingTestEntity.class).getDbEntity();
+ DbEntity entity = runtime.getDataDomain().getEntityResolver().getObjEntity(SimpleLockingTestEntity.class)
+ .getDbEntity();
try {
entity.getDataMap().setQuotingSQLIdentifiers(true);
- List idAttributes = Collections.singletonList(entity
- .getAttribute("LOCKING_TEST_ID"));
- List updatedAttributes = Collections.singletonList(entity
- .getAttribute("DESCRIPTION"));
-
- UpdateBatchQuery updateQuery = new UpdateBatchQuery(
- entity,
- idAttributes,
- updatedAttributes,
- null,
- 1);
+ List idAttributes = Collections.singletonList(entity.getAttribute("LOCKING_TEST_ID"));
+ List updatedAttributes = Collections.singletonList(entity.getAttribute("DESCRIPTION"));
+
+ UpdateBatchQuery updateQuery = new UpdateBatchQuery(entity, idAttributes, updatedAttributes, null, 1);
JdbcAdapter adapter = (JdbcAdapter) this.adapter;
UpdateBatchQueryBuilder builder = new UpdateBatchQueryBuilder(adapter);
@@ -141,47 +113,28 @@ public class UpdateBatchQueryBuilderTest
String charEnd = unitAdapter.getIdentifiersEndQuote();
assertNotNull(generatedSql);
- assertEquals("UPDATE "
- + charStart
- + entity.getName()
- + charEnd
- + " SET "
- + charStart
- + "DESCRIPTION"
- + charEnd
- + " = ? WHERE "
- + charStart
- + "LOCKING_TEST_ID"
- + charEnd
- + " = ?", generatedSql);
+ assertEquals("UPDATE " + charStart + entity.getName() + charEnd + " SET " + charStart + "DESCRIPTION"
+ + charEnd + " = ? WHERE " + charStart + "LOCKING_TEST_ID" + charEnd + " = ?", generatedSql);
- }
- finally {
+ } finally {
entity.getDataMap().setQuotingSQLIdentifiers(false);
}
}
public void testCreateSqlStringWithNullsWithIdentifiersQuote() throws Exception {
- DbEntity entity = runtime.getDataDomain().getEntityResolver().lookupObjEntity(
- SimpleLockingTestEntity.class).getDbEntity();
+ DbEntity entity = runtime.getDataDomain().getEntityResolver().getObjEntity(SimpleLockingTestEntity.class)
+ .getDbEntity();
try {
entity.getDataMap().setQuotingSQLIdentifiers(true);
- List idAttributes = Arrays.asList(
- entity.getAttribute("LOCKING_TEST_ID"),
- entity.getAttribute("NAME"));
+ List idAttributes = Arrays.asList(entity.getAttribute("LOCKING_TEST_ID"), entity.getAttribute("NAME"));
- List updatedAttributes = Collections.singletonList(entity
- .getAttribute("DESCRIPTION"));
+ List updatedAttributes = Collections.singletonList(entity.getAttribute("DESCRIPTION"));
Collection nullAttributes = Collections.singleton("NAME");
- UpdateBatchQuery updateQuery = new UpdateBatchQuery(
- entity,
- idAttributes,
- updatedAttributes,
- nullAttributes,
- 1);
+ UpdateBatchQuery updateQuery = new UpdateBatchQuery(entity, idAttributes, updatedAttributes,
+ nullAttributes, 1);
JdbcAdapter adapter = (JdbcAdapter) this.adapter;
UpdateBatchQueryBuilder builder = new UpdateBatchQueryBuilder(adapter);
@@ -190,26 +143,11 @@ public class UpdateBatchQueryBuilderTest
String charStart = unitAdapter.getIdentifiersStartQuote();
String charEnd = unitAdapter.getIdentifiersEndQuote();
- assertEquals("UPDATE "
- + charStart
- + entity.getName()
- + charEnd
- + " SET "
- + charStart
- + "DESCRIPTION"
- + charEnd
- + " = ? WHERE "
- + charStart
- + "LOCKING_TEST_ID"
- + charEnd
- + " = ? AND "
- + charStart
- + "NAME"
- + charEnd
- + " IS NULL", generatedSql);
+ assertEquals("UPDATE " + charStart + entity.getName() + charEnd + " SET " + charStart + "DESCRIPTION"
+ + charEnd + " = ? WHERE " + charStart + "LOCKING_TEST_ID" + charEnd + " = ? AND " + charStart
+ + "NAME" + charEnd + " IS NULL", generatedSql);
- }
- finally {
+ } finally {
entity.getDataMap().setQuotingSQLIdentifiers(false);
}
}
Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/ashwood/AshwoodEntitySorterTest.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/ashwood/AshwoodEntitySorterTest.java?rev=1495773&r1=1495772&r2=1495773&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/ashwood/AshwoodEntitySorterTest.java (original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/ashwood/AshwoodEntitySorterTest.java Sat Jun 22 19:36:53 2013
@@ -56,15 +56,8 @@ public class AshwoodEntitySorterTest ext
tRelationshipHelper.setColumns("RELATIONSHIP_HELPER_ID", "NAME");
tReflexiveAndToOne = new TableHelper(dbHelper, "REFLEXIVE_AND_TO_ONE");
- tReflexiveAndToOne.setColumns(
- "REFLEXIVE_AND_TO_ONE_ID",
- "PARENT_ID",
- "RELATIONSHIP_HELPER_ID",
- "NAME").setColumnTypes(
- Types.INTEGER,
- Types.INTEGER,
- Types.INTEGER,
- Types.VARCHAR);
+ tReflexiveAndToOne.setColumns("REFLEXIVE_AND_TO_ONE_ID", "PARENT_ID", "RELATIONSHIP_HELPER_ID", "NAME")
+ .setColumnTypes(Types.INTEGER, Types.INTEGER, Types.INTEGER, Types.VARCHAR);
}
public void testSortObjectsForEntityReflexiveWithFaults() throws Exception {
@@ -73,12 +66,11 @@ public class AshwoodEntitySorterTest ext
tReflexiveAndToOne.insert(1, null, 1, "r1");
tReflexiveAndToOne.insert(2, 1, 1, "r2");
tReflexiveAndToOne.insert(3, 2, 1, "r3");
-
+
AshwoodEntitySorter sorter = new AshwoodEntitySorter();
sorter.setEntityResolver(context.getEntityResolver());
- ObjEntity entity = context.getEntityResolver().lookupObjEntity(
- ReflexiveAndToOne.class);
+ ObjEntity entity = context.getEntityResolver().getObjEntity(ReflexiveAndToOne.class);
List<?> objects = context.performQuery(new SelectQuery(ReflexiveAndToOne.class));
Collections.shuffle(objects);
Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/dba/JdbcPkGeneratorTest.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/dba/JdbcPkGeneratorTest.java?rev=1495773&r1=1495772&r2=1495773&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/dba/JdbcPkGeneratorTest.java (original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/dba/JdbcPkGeneratorTest.java Sat Jun 22 19:36:53 2013
@@ -43,7 +43,7 @@ public class JdbcPkGeneratorTest extends
return;
}
- DbEntity artistEntity = node.getEntityResolver().lookupObjEntity(Artist.class).getDbEntity();
+ DbEntity artistEntity = node.getEntityResolver().getObjEntity(Artist.class).getDbEntity();
DbAttribute pkAttribute = (DbAttribute) artistEntity.getAttribute(Artist.ARTIST_ID_PK_COLUMN);