Browse Source

fix

research/11.0
zed 6 years ago
parent
commit
c066969f5a
  1. 2
      fine-hibernate/src/com/fr/third/org/hibernate/tuple/PojoInstantiator.java
  2. 21
      fine-hibernate/src/com/fr/third/org/hibernate/tuple/entity/DefaultEntityRegister.java

2
fine-hibernate/src/com/fr/third/org/hibernate/tuple/PojoInstantiator.java

@ -74,7 +74,7 @@ public class PojoInstantiator implements Instantiator, Serializable {
public Object instantiate() { public Object instantiate() {
if ( isAbstract ) { if ( isAbstract ) {
try { try {
return DefaultEntityRegister.getInstance().getDefaultEntityClass().newInstance(); return DefaultEntityRegister.getInstance().getDefaultEntityClass(mappedClass).newInstance();
} catch (Exception e) { } catch (Exception e) {
throw new InstantiationException("class not found: ", mappedClass); throw new InstantiationException("class not found: ", mappedClass);
} }

21
fine-hibernate/src/com/fr/third/org/hibernate/tuple/entity/DefaultEntityRegister.java

@ -1,12 +1,15 @@
package com.fr.third.org.hibernate.tuple.entity; package com.fr.third.org.hibernate.tuple.entity;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
/** /**
* Created by Zed on 2018/11/1. * Created by Zed on 2018/11/1.
*/ */
public class DefaultEntityRegister { public class DefaultEntityRegister {
private static volatile DefaultEntityRegister instance; private static volatile DefaultEntityRegister instance;
private Class defaultEntityClass = null; private static Map<Class, Class> MAP = new ConcurrentHashMap<Class, Class>();
public static DefaultEntityRegister getInstance() { public static DefaultEntityRegister getInstance() {
if (instance == null) { if (instance == null) {
@ -23,19 +26,15 @@ public class DefaultEntityRegister {
} }
public void registerDefaultClass(Class defaultEntityClass) { public void registerDefaultClass(Class abstractEntityClass, Class defaultEntityClass) {
this.defaultEntityClass = defaultEntityClass; MAP.put(abstractEntityClass, defaultEntityClass);
}
public void resetDefaultClass() {
this.defaultEntityClass = null;
} }
public Class getDefaultEntityClass() { public void removeDefaultClass(Class abstractEntityClass) {
return defaultEntityClass; MAP.remove(abstractEntityClass);
} }
public void setDefaultEntityClass(Class defaultEntityClass) { public Class getDefaultEntityClass(Class abstractEntityClass) {
this.defaultEntityClass = defaultEntityClass; return MAP.get(abstractEntityClass);
} }
} }

Loading…
Cancel
Save