mirror of https://github.com/apache/openjpa.git
Test that @ContainerTable annotation is properly read.
git-svn-id: https://svn.apache.org/repos/asf/openjpa/trunk@558191 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
9ce0bed09d
commit
e2556dd6b2
|
@ -0,0 +1,38 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you 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.fields;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
|
||||
import org.apache.openjpa.persistence.PersistentMap;
|
||||
import org.apache.openjpa.persistence.jdbc.ContainerTable;
|
||||
|
||||
@Entity
|
||||
public class NonstandardMappingEntity {
|
||||
@PersistentMap
|
||||
@ContainerTable(name="NONSTD_MAPPING_MAP")
|
||||
private Map<String, String> map = new HashMap<String, String>();
|
||||
|
||||
public Map<String, String> getMap() {
|
||||
return map;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,59 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you 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.fields;
|
||||
|
||||
import javax.persistence.EntityManager;
|
||||
|
||||
import org.apache.openjpa.persistence.test.SQLListenerTestCase;
|
||||
import org.apache.openjpa.persistence.OpenJPAPersistence;
|
||||
import org.apache.openjpa.persistence.OpenJPAEntityManager;
|
||||
import org.apache.openjpa.jdbc.meta.ClassMapping;
|
||||
|
||||
public class TestPersistentMapTableConfiguration
|
||||
extends SQLListenerTestCase {
|
||||
|
||||
public void setUp() {
|
||||
setUp(NonstandardMappingEntity.class);
|
||||
}
|
||||
|
||||
public void testPersistentMapMetaData() {
|
||||
ClassMapping cm = (ClassMapping) OpenJPAPersistence.getMetaData(emf,
|
||||
NonstandardMappingEntity.class);
|
||||
assertEquals("NONSTD_MAPPING_MAP",
|
||||
cm.getFieldMapping("map").getTable().getName());
|
||||
}
|
||||
|
||||
public void testPersistentMapInsert() {
|
||||
NonstandardMappingEntity e = new NonstandardMappingEntity();
|
||||
OpenJPAEntityManager em = emf.createEntityManager();
|
||||
em.getIdGenerator(NonstandardMappingEntity.class).allocate(1);
|
||||
sql.clear();
|
||||
try {
|
||||
em.getTransaction().begin();
|
||||
em.persist(e);
|
||||
e.getMap().put("foo", "bar");
|
||||
em.flush();
|
||||
assertEquals(2, sql.size());
|
||||
assertSQL(".*NONSTD_MAPPING_MAP.*");
|
||||
} finally {
|
||||
if (em.getTransaction().isActive())
|
||||
em.getTransaction().rollback();
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue