From 88fad2be000f42d7d4bdada0edc93265a9009f83 Mon Sep 17 00:00:00 2001 From: Zed Date: Fri, 2 Nov 2018 09:40:22 +0800 Subject: [PATCH] fix --- .../org/hibernate/tuple/PojoInstantiator.java | 2 +- .../tuple/entity/DefaultEntityRegister.java | 21 +++++++++---------- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/fine-hibernate/src/com/fr/third/org/hibernate/tuple/PojoInstantiator.java b/fine-hibernate/src/com/fr/third/org/hibernate/tuple/PojoInstantiator.java index ac3f255f4..bc9758cd6 100755 --- a/fine-hibernate/src/com/fr/third/org/hibernate/tuple/PojoInstantiator.java +++ b/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); } diff --git a/fine-hibernate/src/com/fr/third/org/hibernate/tuple/entity/DefaultEntityRegister.java b/fine-hibernate/src/com/fr/third/org/hibernate/tuple/entity/DefaultEntityRegister.java index fe3932ea7..ec7de7b57 100644 --- a/fine-hibernate/src/com/fr/third/org/hibernate/tuple/entity/DefaultEntityRegister.java +++ b/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 MAP = new ConcurrentHashMap(); 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); } }