mirror of https://github.com/apache/openjpa.git
OPENJPA-1611: fix EMBEDDED attr type. Merged in from trunk r930721 commit by Fay.
git-svn-id: https://svn.apache.org/repos/asf/openjpa/branches/2.0.x@932663 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
1dc803b9d7
commit
f43015857b
|
@ -38,6 +38,8 @@ import javax.persistence.metamodel.PluralAttribute.CollectionType;
|
|||
import javax.persistence.metamodel.Type.PersistenceType;
|
||||
|
||||
import org.apache.openjpa.meta.ClassMetaData;
|
||||
import org.apache.openjpa.persistence.embed.Address;
|
||||
import org.apache.openjpa.persistence.embed.Geocode;
|
||||
import org.apache.openjpa.persistence.enhance.identity.Book;
|
||||
import org.apache.openjpa.persistence.enhance.identity.BookId;
|
||||
import org.apache.openjpa.persistence.enhance.identity.Library;
|
||||
|
@ -71,7 +73,9 @@ public class TestMetamodel extends SingleEMFTestCase {
|
|||
OneOneChild.class,
|
||||
Book.class,
|
||||
Library.class,
|
||||
Page.class);
|
||||
Page.class,
|
||||
Address.class,
|
||||
Geocode.class);
|
||||
emf.createEntityManager();
|
||||
model = (MetamodelImpl)emf.getMetamodel();
|
||||
}
|
||||
|
@ -313,6 +317,12 @@ public class TestMetamodel extends SingleEMFTestCase {
|
|||
assertEquals(PersistentAttributeType.BASIC, pInt.getPersistentAttributeType());
|
||||
}
|
||||
|
||||
public void testEmbeddedAttributeType() {
|
||||
ManagedType<Address> type = model.entity(Address.class);
|
||||
Attribute.PersistentAttributeType attr = type.getAttribute("geocode").getPersistentAttributeType();
|
||||
assertEquals(PersistentAttributeType.EMBEDDED, attr);
|
||||
}
|
||||
|
||||
public void testNotFoundErrorMessage() {
|
||||
IdentifiableType<ImplicitFieldAccessBase> e0 = model.entity(ImplicitFieldAccessBase.class);
|
||||
String name = "unknown";
|
||||
|
|
|
@ -200,6 +200,10 @@ public class Members {
|
|||
public final PersistentAttributeType getPersistentAttributeType() {
|
||||
if (!fmd.isDeclaredTypePC())
|
||||
return super.getPersistentAttributeType();
|
||||
if (fmd.getValue().isEmbedded() && fmd.getAssociationType() == 0) {
|
||||
return PersistentAttributeType.EMBEDDED;
|
||||
}
|
||||
|
||||
return fmd.getMappedByMetaData() == null || !fmd.getType().isAssignableFrom(Collection.class)
|
||||
? PersistentAttributeType.ONE_TO_ONE
|
||||
: PersistentAttributeType.ONE_TO_MANY;
|
||||
|
|
Loading…
Reference in New Issue