mirror of https://github.com/apache/openjpa.git
OPENJPA-1021 allow MapKey on relation field
- add JPA2 Query support for MapKey on relation field - remove @AllowFailure in test cases git-svn-id: https://svn.apache.org/repos/asf/openjpa/trunk@764218 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
d00cf9d468
commit
8c31381f18
|
@ -139,6 +139,27 @@ public class RelationMapInverseKeyFieldStrategy
|
|||
return joins;
|
||||
}
|
||||
|
||||
public Joins joinKeyRelation(Joins joins, boolean forceOuter,
|
||||
boolean traverse) {
|
||||
ValueMapping key = field.getKeyMapping();
|
||||
if (key.isEmbedded())
|
||||
return joins;
|
||||
|
||||
ClassMapping[] clss = key.getIndependentTypeMappings();
|
||||
if (clss.length != 1) {
|
||||
if (traverse)
|
||||
throw RelationStrategies.unjoinable(key);
|
||||
return joins;
|
||||
}
|
||||
if (forceOuter)
|
||||
return joins.outerJoinRelation(field.getName(),
|
||||
key.getForeignKey(clss[0]), clss[0], key.getSelectSubclasses(),
|
||||
false, false);
|
||||
return joins.joinRelation(field.getName(),
|
||||
key.getForeignKey(clss[0]), clss[0], key.getSelectSubclasses(),
|
||||
false, false);
|
||||
}
|
||||
|
||||
public Joins joinValueRelation(Joins joins, ClassMapping val) {
|
||||
return joinElementRelation(joins, val);
|
||||
}
|
||||
|
|
|
@ -139,6 +139,27 @@ public class RelationMapTableFieldStrategy
|
|||
return joins;
|
||||
}
|
||||
|
||||
public Joins joinKeyRelation(Joins joins, boolean forceOuter,
|
||||
boolean traverse) {
|
||||
ValueMapping key = field.getKeyMapping();
|
||||
if (key.isEmbedded())
|
||||
return joins;
|
||||
|
||||
ClassMapping[] clss = key.getIndependentTypeMappings();
|
||||
if (clss.length != 1) {
|
||||
if (traverse)
|
||||
throw RelationStrategies.unjoinable(key);
|
||||
return joins;
|
||||
}
|
||||
if (forceOuter)
|
||||
return joins.outerJoinRelation(field.getName(),
|
||||
key.getForeignKey(clss[0]), clss[0], key.getSelectSubclasses(),
|
||||
false, false);
|
||||
return joins.joinRelation(field.getName(),
|
||||
key.getForeignKey(clss[0]), clss[0], key.getSelectSubclasses(),
|
||||
false, false);
|
||||
}
|
||||
|
||||
public Joins joinValueRelation(Joins joins, ClassMapping val) {
|
||||
return joinElementRelation(joins, val);
|
||||
}
|
||||
|
|
|
@ -61,8 +61,7 @@ public class TestSpec10_1_27_Ex6 extends SQLListenerTestCase {
|
|||
public void testQueryInMemoryQualifiedId() throws Exception {
|
||||
queryQualifiedId(true);
|
||||
}
|
||||
|
||||
@AllowFailure
|
||||
|
||||
public void testQueryQualifiedId() throws Exception {
|
||||
queryQualifiedId(false);
|
||||
}
|
||||
|
|
|
@ -20,6 +20,7 @@ package org.apache.openjpa.persistence.jdbc.maps.spec_10_1_27_ex7;
|
|||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.OneToOne;
|
||||
import javax.persistence.Table;
|
||||
|
||||
@Entity
|
||||
|
@ -29,6 +30,9 @@ public class Division {
|
|||
int id;
|
||||
|
||||
String name;
|
||||
|
||||
@OneToOne(mappedBy="div")
|
||||
VicePresident vp;
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
|
@ -46,6 +50,14 @@ public class Division {
|
|||
this.name = name;
|
||||
}
|
||||
|
||||
public VicePresident getVp() {
|
||||
return vp;
|
||||
}
|
||||
|
||||
public void setVp(VicePresident vp) {
|
||||
this.vp = vp;
|
||||
}
|
||||
|
||||
public boolean equals(Object o) {
|
||||
Division d = (Division) o;
|
||||
if (d.name.equals(name) &&
|
||||
|
|
|
@ -64,7 +64,6 @@ public class TestSpec10_1_27_Ex7 extends SQLListenerTestCase {
|
|||
queryQualifiedId(true);
|
||||
}
|
||||
|
||||
@AllowFailure
|
||||
public void testQueryQualifiedId() throws Exception {
|
||||
queryQualifiedId(false);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue