mirror of https://github.com/apache/openjpa.git
Fix recently-introduced bugs in conversion between JPA facades and underlying
components. git-svn-id: https://svn.apache.org/repos/asf/incubator/openjpa/trunk@472193 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
05f7fac863
commit
92343313fb
|
@ -79,7 +79,7 @@ public class DiscriminatorMappingInfo
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ("null".equalsIgnoreCase(_value))
|
if ("null".equalsIgnoreCase(_value))
|
||||||
return (Discriminator.NULL);
|
return Discriminator.NULL;
|
||||||
|
|
||||||
// strip quotes
|
// strip quotes
|
||||||
if (_value.length() > 0 && _value.charAt(0) == '\'')
|
if (_value.length() > 0 && _value.charAt(0) == '\'')
|
||||||
|
|
|
@ -93,9 +93,8 @@ public class ValueMapDiscriminatorStrategy
|
||||||
if (cls != null)
|
if (cls != null)
|
||||||
return cls;
|
return cls;
|
||||||
throw new ClassNotFoundException(_loc.get("unknown-discrim-value",
|
throw new ClassNotFoundException(_loc.get("unknown-discrim-value",
|
||||||
new Object[]{ str,
|
new Object[]{ str, disc.getClassMapping().getDescribedType().
|
||||||
disc.getClassMapping().getDescribedType().getName(),
|
getName(), new TreeSet(_vals.keySet()) }).getMessage());
|
||||||
new TreeSet(_vals.keySet()) }).getMessage());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -123,6 +122,8 @@ public class ValueMapDiscriminatorStrategy
|
||||||
throw new MetaDataException(_loc.get("no-discrim-value",
|
throw new MetaDataException(_loc.get("no-discrim-value",
|
||||||
disc.getClassMapping()));
|
disc.getClassMapping()));
|
||||||
|
|
||||||
|
// we set the value before mapping to use to calculate the template
|
||||||
|
// column's java type
|
||||||
disc.setValue(val);
|
disc.setValue(val);
|
||||||
super.map(adapt);
|
super.map(adapt);
|
||||||
}
|
}
|
||||||
|
|
|
@ -85,8 +85,17 @@ public class OpenJPAPersistence
|
||||||
public static BrokerFactory toBrokerFactory(EntityManagerFactory emf) {
|
public static BrokerFactory toBrokerFactory(EntityManagerFactory emf) {
|
||||||
if (emf == null)
|
if (emf == null)
|
||||||
return null;
|
return null;
|
||||||
emf = (EntityManagerFactory)
|
if (!(emf instanceof EntityManagerFactoryImpl)) {
|
||||||
((OpenJPAEntityManagerFactory) emf).getUserObject(EMF_KEY);
|
Class c = emf.getClass();
|
||||||
|
try {
|
||||||
|
// either cast here may fail
|
||||||
|
emf = (EntityManagerFactoryImpl) ((OpenJPAEntityManagerFactory)
|
||||||
|
emf).getUserObject(EMF_KEY);
|
||||||
|
} catch (ClassCastException cce) {
|
||||||
|
throw new ArgumentException(_loc.get
|
||||||
|
("cant-convert-brokerfactory", c), null, null, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
return ((EntityManagerFactoryImpl) emf).getBrokerFactory();
|
return ((EntityManagerFactoryImpl) emf).getBrokerFactory();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -122,8 +131,18 @@ public class OpenJPAPersistence
|
||||||
public static Broker toBroker(EntityManager em) {
|
public static Broker toBroker(EntityManager em) {
|
||||||
if (em == null)
|
if (em == null)
|
||||||
return null;
|
return null;
|
||||||
em = (EntityManager) ((OpenJPAEntityManager) em).getUserObject(EM_KEY);
|
if (!(em instanceof EntityManagerImpl)) {
|
||||||
return (em == null) ? null : ((EntityManagerImpl) em).getBroker();
|
Class c = em.getClass();
|
||||||
|
try {
|
||||||
|
// either cast here may fail
|
||||||
|
em = (EntityManagerImpl) ((OpenJPAEntityManager) em).
|
||||||
|
getUserObject(EM_KEY);
|
||||||
|
} catch (ClassCastException cce) {
|
||||||
|
throw new ArgumentException(_loc.get("cant-convert-broker", c),
|
||||||
|
null, null, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ((EntityManagerImpl) em).getBroker();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -90,6 +90,10 @@ unloadable-provider: WARNING: Unable to load persistence provider "{0}" due \
|
||||||
to "{1}"
|
to "{1}"
|
||||||
unrecognized-provider: WARNING: Found unrecognized persistence provider "{0}" \
|
unrecognized-provider: WARNING: Found unrecognized persistence provider "{0}" \
|
||||||
in place of OpenJPA provider. This provider's properties will not be used.
|
in place of OpenJPA provider. This provider's properties will not be used.
|
||||||
|
cant-convert-brokerfactory: Unable to convert EntityManagerFactory of type \
|
||||||
|
"{0}" into a BrokerFactory.
|
||||||
|
cant-convert-broker: Unable to convert EntityManager of type "{0}" into a \
|
||||||
|
Broker.
|
||||||
EntityManagerFactory-name: EntityManagerFactory implementation
|
EntityManagerFactory-name: EntityManagerFactory implementation
|
||||||
EntityManagerFactory-desc: Allows extension of standard \
|
EntityManagerFactory-desc: Allows extension of standard \
|
||||||
org.apache.openjpa.persistence.EntityManagerFactoryImpl for custom behavior.
|
org.apache.openjpa.persistence.EntityManagerFactoryImpl for custom behavior.
|
||||||
|
|
Loading…
Reference in New Issue