Browse Source

fix

final/10.0.3
zed 6 years ago
parent
commit
1d378a4e5c
  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() {
if ( isAbstract ) {
try {
return DefaultEntityRegister.getInstance().getDefaultEntityClass().newInstance();
return DefaultEntityRegister.getInstance().getDefaultEntityClass(mappedClass).newInstance();
} catch (Exception e) {
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;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
/**
* Created by Zed on 2018/11/1.
*/
public class DefaultEntityRegister {
private static volatile DefaultEntityRegister instance;
private Class defaultEntityClass = null;
private static Map<Class, Class> MAP = new ConcurrentHashMap<Class, Class>();
public static DefaultEntityRegister getInstance() {
if (instance == null) {
@ -23,19 +26,15 @@ public class DefaultEntityRegister {
}
public void registerDefaultClass(Class defaultEntityClass) {
this.defaultEntityClass = defaultEntityClass;
}
public void resetDefaultClass() {
this.defaultEntityClass = null;
public void registerDefaultClass(Class abstractEntityClass, Class defaultEntityClass) {
MAP.put(abstractEntityClass, defaultEntityClass);
}
public Class getDefaultEntityClass() {
return defaultEntityClass;
public void removeDefaultClass(Class abstractEntityClass) {
MAP.remove(abstractEntityClass);
}
public void setDefaultEntityClass(Class defaultEntityClass) {
this.defaultEntityClass = defaultEntityClass;
public Class getDefaultEntityClass(Class abstractEntityClass) {
return MAP.get(abstractEntityClass);
}
}

Loading…
Cancel
Save