mirror of https://github.com/apache/openjpa.git
OPENJPA-1069: orderBy on ElementCollection of basic types
git-svn-id: https://svn.apache.org/repos/asf/openjpa/trunk@772528 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
f0fb49b47c
commit
75dfd10c59
|
@ -1861,6 +1861,7 @@ public class FieldMetaData
|
|||
_mappedByIdValue = field._mappedByIdValue;
|
||||
_isElementCollection = field._isElementCollection;
|
||||
_access = field._access;
|
||||
_orderDec = field._orderDec;
|
||||
|
||||
// embedded fields can't be versions
|
||||
if (_owner.getEmbeddingMetaData() == null && _version == null)
|
||||
|
|
|
@ -18,6 +18,9 @@
|
|||
*/
|
||||
package org.apache.openjpa.persistence.embed.attrOverrides;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
|
||||
import javax.persistence.*;
|
||||
|
||||
|
||||
|
@ -30,6 +33,10 @@ public class EmergencyContactInfo {
|
|||
|
||||
@OneToOne
|
||||
PhoneNumber phoneNumber;
|
||||
|
||||
@ElementCollection
|
||||
@OrderBy
|
||||
Collection<String> nickNames = new ArrayList<String>();
|
||||
|
||||
public PhoneNumber getPhoneNumber() {
|
||||
return phoneNumber;
|
||||
|
@ -62,4 +69,16 @@ public class EmergencyContactInfo {
|
|||
public void setLName(String lName) {
|
||||
this.lName = lName;
|
||||
}
|
||||
|
||||
public Collection<String> getNickNames() {
|
||||
return nickNames;
|
||||
}
|
||||
|
||||
public void setNickNames(Collection<String> nickNames) {
|
||||
this.nickNames = nickNames;
|
||||
}
|
||||
|
||||
public void addNickName(String nickName) {
|
||||
nickNames.add(nickName);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -111,6 +111,9 @@ public class TestAssocOverrides extends SQLListenerTestCase {
|
|||
EmergencyContactInfo ecInfo = new EmergencyContactInfo();
|
||||
ecInfo.setFName("fName_" + id);
|
||||
ecInfo.setLName("lName_" + id);
|
||||
for (int i = 5; i > 0; i--) {
|
||||
ecInfo.addNickName("nickName" + i);
|
||||
}
|
||||
Address eaddr = new Address();
|
||||
eaddr.setId(addrId++);
|
||||
eaddr.setCity("city_" + eaddr.getId());
|
||||
|
@ -174,6 +177,13 @@ public class TestAssocOverrides extends SQLListenerTestCase {
|
|||
for (PhoneNumber p : phones) {
|
||||
assertPhoneNumber(p, e.getEmpId());
|
||||
}
|
||||
Collection<String> nickNames = c.getEmergencyContactInfo().
|
||||
getNickNames();
|
||||
int i = 1;
|
||||
for (String nickName : nickNames) {
|
||||
assertEquals("nickName" + i, nickName);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
public void assertPhoneNumber(PhoneNumber p, int empId) {
|
||||
|
|
Loading…
Reference in New Issue