mirror of https://github.com/apache/openjpa.git
OPENJPA-229
git-svn-id: https://svn.apache.org/repos/asf/incubator/openjpa/trunk@532805 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
0819749391
commit
b2beaec634
|
@ -2283,7 +2283,12 @@ public class PCEnhancer {
|
|||
code.getstatic().setField(PRE + "FieldTypes", Class[].class);
|
||||
code.getstatic().setField(PRE + "FieldFlags", byte[].class);
|
||||
code.getstatic().setField(SUPER, Class.class);
|
||||
code.constant().setValue(_meta.getTypeAlias());
|
||||
|
||||
if (_meta.isMapped())
|
||||
code.constant().setValue(_meta.getTypeAlias());
|
||||
else
|
||||
code.constant().setNull();
|
||||
|
||||
if (_pc.isAbstract())
|
||||
code.constant().setNull();
|
||||
else {
|
||||
|
|
|
@ -1396,14 +1396,16 @@ public class MetaDataRepository
|
|||
|
||||
// set alias for class
|
||||
String alias = PCRegistry.getTypeAlias(cls);
|
||||
synchronized (_aliases) {
|
||||
List classList = (List) _aliases.get(alias);
|
||||
if (classList == null) {
|
||||
classList = new ArrayList(3);
|
||||
_aliases.put(alias, classList);
|
||||
if (alias != null) {
|
||||
synchronized (_aliases) {
|
||||
List classList = (List) _aliases.get(alias);
|
||||
if (classList == null) {
|
||||
classList = new ArrayList(3);
|
||||
_aliases.put(alias, classList);
|
||||
}
|
||||
if (!classList.contains(cls))
|
||||
classList.add(cls);
|
||||
}
|
||||
if (!classList.contains(cls))
|
||||
classList.add(cls);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,59 @@
|
|||
/*
|
||||
* Copyright 2006 The Apache Software Foundation.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.openjpa.persistence.inheritance;
|
||||
|
||||
import org.apache.openjpa.persistence.test.SingleEMFTestCase;
|
||||
import org.apache.openjpa.persistence.OpenJPAPersistence;
|
||||
import org.apache.openjpa.meta.ClassMetaData;
|
||||
import org.apache.openjpa.kernel.AbstractBrokerFactory;
|
||||
|
||||
/**
|
||||
* Test that entities, mapped superclasses, and embeddables can all share
|
||||
* the same short names without any collisions.
|
||||
*/
|
||||
public class TestSharedUnqualifiedClassNames
|
||||
extends SingleEMFTestCase {
|
||||
|
||||
public void setUp() {
|
||||
setUp(org.apache.openjpa.persistence.inheritance.mappedsuperclass
|
||||
.SharedName1.class,
|
||||
org.apache.openjpa.persistence.inheritance.entity
|
||||
.SharedName1.class,
|
||||
org.apache.openjpa.persistence.inheritance.embeddable
|
||||
.SharedName2.class,
|
||||
org.apache.openjpa.persistence.inheritance.entity
|
||||
.SharedName2.class);
|
||||
emf.createEntityManager().close();
|
||||
}
|
||||
|
||||
public void testMappedSuperclass() {
|
||||
ClassMetaData meta = emf.getConfiguration()
|
||||
.getMetaDataRepositoryInstance()
|
||||
.getMetaData("SharedName1", getClass().getClassLoader(), true);
|
||||
assertEquals(
|
||||
org.apache.openjpa.persistence.inheritance.entity.SharedName1.class,
|
||||
meta.getDescribedType());
|
||||
}
|
||||
|
||||
public void testEmbeddable() {
|
||||
ClassMetaData meta = emf.getConfiguration()
|
||||
.getMetaDataRepositoryInstance()
|
||||
.getMetaData("SharedName2", getClass().getClassLoader(), true);
|
||||
assertEquals(
|
||||
org.apache.openjpa.persistence.inheritance.entity.SharedName2.class,
|
||||
meta.getDescribedType());
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue