Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/339.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java Hibernate@Inheritation(strategy=InheritanceType.join)使用不同的模式会导致错误(HH000099)_Java_Hibernate - Fatal编程技术网

Java Hibernate@Inheritation(strategy=InheritanceType.join)使用不同的模式会导致错误(HH000099)

Java Hibernate@Inheritation(strategy=InheritanceType.join)使用不同的模式会导致错误(HH000099),java,hibernate,Java,Hibernate,从Hibernate4.2升级到5.5.5后,我的继承不再有效。启动我的应用程序时引发以下错误: 错误AssertionFailure:33-HHH000099:发生断言失败这可能表明Hibernate中存在错误,但更可能是由于不安全地使用会话:org.Hibernate.AssertionFailure:Table BASE.ANIMAL not found 以下是我的课程: cat.java animal.java 测试类 package ormsamples; import org.or

从Hibernate4.2升级到5.5.5后,我的继承不再有效。启动我的应用程序时引发以下错误:

错误AssertionFailure:33-HHH000099:发生断言失败这可能表明Hibernate中存在错误,但更可能是由于不安全地使用会话:org.Hibernate.AssertionFailure:Table BASE.ANIMAL not found

以下是我的课程:

cat.java

animal.java

测试类

package ormsamples;

import org.orm.*;
public class CreateJoinedinheritanceData {
    public void createTestData() throws PersistentException {
        PersistentTransaction t = ext.JoinedinheritancePersistentManager.instance().getSession().beginTransaction();
        try {
            base.ANIMAL bASEANIMAL = base.ANIMALDAO.createANIMAL();
            // Initialize the properties of the persistent object here
            base.ANIMALDAO.save(bASEANIMAL);
            ext.CAT eXTCAT = ext.CATDAO.createCAT();
            // Initialize the properties of the persistent object here
            ext.CATDAO.save(eXTCAT);
            t.commit();
        }
        catch (Exception e) {
            t.rollback();
        }

    }

    public static void main(String[] args) {
        try {
            CreateJoinedinheritanceData createJoinedinheritanceData = new CreateJoinedinheritanceData();
            try {
                createJoinedinheritanceData.createTestData();
            }
            finally {
                ext.JoinedinheritancePersistentManager.instance().disposePersistentManager();
            }
        }
        catch (Exception e) {
            e.printStackTrace();
        }
    }
}
我是否错过了迁移步骤,或者在最新的hibernate 5版本中是否存在bug


期待您的建议

在做了更多的研究之后,我遇到了这个hibernate bug

它被拒绝,答案是使用目录而不是模式。不幸的是,没有给出进一步的解释,但如果我改变这一行

@Table(name="ANIMAL", schema="BASE")

一切又恢复正常了


与此类似,bug作者也对此进行了描述。

@InheritationSequestrategy=InheritanceType.JOINED仅在父类中是必需的,而在子类中不是必需的,如果我不正确,请纠正我,但错误仍然是一样的。您可以参考我的git repo,在这里我创建了JoinedStrategy继承与hibernate 5.2的链接,但是你的例子没有图式,我认为这就是我例子中的问题。
package ormsamples;

import org.orm.*;
public class CreateJoinedinheritanceData {
    public void createTestData() throws PersistentException {
        PersistentTransaction t = ext.JoinedinheritancePersistentManager.instance().getSession().beginTransaction();
        try {
            base.ANIMAL bASEANIMAL = base.ANIMALDAO.createANIMAL();
            // Initialize the properties of the persistent object here
            base.ANIMALDAO.save(bASEANIMAL);
            ext.CAT eXTCAT = ext.CATDAO.createCAT();
            // Initialize the properties of the persistent object here
            ext.CATDAO.save(eXTCAT);
            t.commit();
        }
        catch (Exception e) {
            t.rollback();
        }

    }

    public static void main(String[] args) {
        try {
            CreateJoinedinheritanceData createJoinedinheritanceData = new CreateJoinedinheritanceData();
            try {
                createJoinedinheritanceData.createTestData();
            }
            finally {
                ext.JoinedinheritancePersistentManager.instance().disposePersistentManager();
            }
        }
        catch (Exception e) {
            e.printStackTrace();
        }
    }
}
@Table(name="ANIMAL", schema="BASE")
@Table(name="ANIMAL", catalog="BASE")