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))
|
||||
return (Discriminator.NULL);
|
||||
return Discriminator.NULL;
|
||||
|
||||
// strip quotes
|
||||
if (_value.length() > 0 && _value.charAt(0) == '\'')
|
||||
|
|
|
@ -93,9 +93,8 @@ public class ValueMapDiscriminatorStrategy
|
|||
if (cls != null)
|
||||
return cls;
|
||||
throw new ClassNotFoundException(_loc.get("unknown-discrim-value",
|
||||
new Object[]{ str,
|
||||
disc.getClassMapping().getDescribedType().getName(),
|
||||
new TreeSet(_vals.keySet()) }).getMessage());
|
||||
new Object[]{ str, disc.getClassMapping().getDescribedType().
|
||||
getName(), new TreeSet(_vals.keySet()) }).getMessage());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -123,6 +122,8 @@ public class ValueMapDiscriminatorStrategy
|
|||
throw new MetaDataException(_loc.get("no-discrim-value",
|
||||
disc.getClassMapping()));
|
||||
|
||||
// we set the value before mapping to use to calculate the template
|
||||
// column's java type
|
||||
disc.setValue(val);
|
||||
super.map(adapt);
|
||||
}
|
||||
|
|
|
@ -85,8 +85,17 @@ public class OpenJPAPersistence
|
|||
public static BrokerFactory toBrokerFactory(EntityManagerFactory emf) {
|
||||
if (emf == null)
|
||||
return null;
|
||||
emf = (EntityManagerFactory)
|
||||
((OpenJPAEntityManagerFactory) emf).getUserObject(EMF_KEY);
|
||||
if (!(emf instanceof EntityManagerFactoryImpl)) {
|
||||
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();
|
||||
}
|
||||
|
||||
|
@ -122,8 +131,18 @@ public class OpenJPAPersistence
|
|||
public static Broker toBroker(EntityManager em) {
|
||||
if (em == null)
|
||||
return null;
|
||||
em = (EntityManager) ((OpenJPAEntityManager) em).getUserObject(EM_KEY);
|
||||
return (em == null) ? null : ((EntityManagerImpl) em).getBroker();
|
||||
if (!(em instanceof EntityManagerImpl)) {
|
||||
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}"
|
||||
unrecognized-provider: WARNING: Found unrecognized persistence provider "{0}" \
|
||||
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-desc: Allows extension of standard \
|
||||
org.apache.openjpa.persistence.EntityManagerFactoryImpl for custom behavior.
|
||||
|
|
Loading…
Reference in New Issue