mirror of https://github.com/apache/openjpa.git
OPENJPA-1269: honor the table attribute in the MapKeyColumn annotation
git-svn-id: https://svn.apache.org/repos/asf/openjpa/trunk@808750 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
250186fbcb
commit
78e93abb51
|
@ -1968,6 +1968,9 @@ public class AnnotationPersistenceMappingParser
|
||||||
*/
|
*/
|
||||||
protected void parseMapKeyColumn(FieldMapping fm, MapKeyColumn anno) {
|
protected void parseMapKeyColumn(FieldMapping fm, MapKeyColumn anno) {
|
||||||
int unique = 0;
|
int unique = 0;
|
||||||
|
FieldMappingInfo info = fm.getMappingInfo();
|
||||||
|
if (anno.table() != null && anno.table().length() > 0)
|
||||||
|
info.setTableName(anno.table());
|
||||||
Column col = new Column();
|
Column col = new Column();
|
||||||
setupMapKeyColumn(fm, col, anno);
|
setupMapKeyColumn(fm, col, anno);
|
||||||
unique |= (anno.unique()) ? TRUE : FALSE;
|
unique |= (anno.unique()) ? TRUE : FALSE;
|
||||||
|
|
|
@ -29,6 +29,7 @@ public class Item2 {
|
||||||
int id;
|
int id;
|
||||||
|
|
||||||
@ElementCollection
|
@ElementCollection
|
||||||
|
@MapKeyColumn(name="IMAGE_NAME", table="ITEM2_XXX")
|
||||||
Map<String, String> images = new HashMap<String, String>();
|
Map<String, String> images = new HashMap<String, String>();
|
||||||
|
|
||||||
public int getId() {
|
public int getId() {
|
||||||
|
|
|
@ -36,9 +36,10 @@ import javax.persistence.Query;
|
||||||
|
|
||||||
import org.apache.openjpa.lib.log.Log;
|
import org.apache.openjpa.lib.log.Log;
|
||||||
import org.apache.openjpa.persistence.ArgumentException;
|
import org.apache.openjpa.persistence.ArgumentException;
|
||||||
|
import org.apache.openjpa.persistence.test.SQLListenerTestCase;
|
||||||
import org.apache.openjpa.persistence.test.SingleEMFTestCase;
|
import org.apache.openjpa.persistence.test.SingleEMFTestCase;
|
||||||
|
|
||||||
public class TestEmbeddable extends SingleEMFTestCase {
|
public class TestEmbeddable extends SQLListenerTestCase {
|
||||||
private static final Calendar cal = new GregorianCalendar();
|
private static final Calendar cal = new GregorianCalendar();
|
||||||
private static final Integer timeHash = new Integer(cal.hashCode());
|
private static final Integer timeHash = new Integer(cal.hashCode());
|
||||||
public int numEmbeddables = 1;
|
public int numEmbeddables = 1;
|
||||||
|
@ -92,6 +93,7 @@ public class TestEmbeddable extends SingleEMFTestCase {
|
||||||
EntityA_Embed_MappedToOneCascadeDelete.class, EntityB2.class,
|
EntityA_Embed_MappedToOneCascadeDelete.class, EntityB2.class,
|
||||||
Book.class, Listing.class, Seller.class,
|
Book.class, Listing.class, Seller.class,
|
||||||
EntityA_Embed_Complex.class, CLEAR_TABLES);
|
EntityA_Embed_Complex.class, CLEAR_TABLES);
|
||||||
|
sql.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testEntityA_Coll_String() {
|
public void testEntityA_Coll_String() {
|
||||||
|
@ -1964,6 +1966,20 @@ public class TestEmbeddable extends SingleEMFTestCase {
|
||||||
tran.begin();
|
tran.begin();
|
||||||
em.flush();
|
em.flush();
|
||||||
tran.commit();
|
tran.commit();
|
||||||
|
boolean found = false;
|
||||||
|
for (String sqlStr : sql) {
|
||||||
|
if (sqlStr.toUpperCase().indexOf("ITEM2_XXX") != -1) {
|
||||||
|
found = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (sqlStr.toUpperCase().indexOf("ITEM2_IMAGES") != -1) {
|
||||||
|
found = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!found) {
|
||||||
|
fail("Table name ITEM2_IMG specified in the MapKeyColumn annotation is not honored");
|
||||||
|
}
|
||||||
em.close();
|
em.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue