gpt4 book ai didi

java - 无法使用 kundera 将继承的实体持久保存到 Hbase

转载 作者:太空宇宙 更新时间:2023-11-04 11:32:12 24 4
gpt4 key购买 nike

我有两个实体类,一个是从其他实体类继承的,

@Entity
@Table(name = "common", schema = "url_results@hbase_pu")
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
@DiscriminatorColumn(name = "launcher")
public class Person implements Serializable{
@Id
@GeneratedValue(strategy = GenerationType.TABLE)
private String id;
@Column(name = "name")
private String name;
@Column(name = "path")
private String url;
-----
//getters and setters

}

另一个子类,

@Entity
@DiscriminatorValue(value = "owner")
public class Owner extends Person implements Serializable {
@Column(name = "workload_id")
protected long workloadId;
//getters and setters
}

我的persiestance.xml是

<persistence xmlns="http://java.sun.com/xml/ns/persistence" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"
version="2.0">
<persistence-unit name="hbase_pu">
<provider>com.impetus.kundera.KunderaPersistence</provider>
<class>com.abc.Owner</class>

<exclude-unlisted-classes>true</exclude-unlisted-classes>
<properties>
<property name="kundera.nodes" value="quickstart.cloudera"/>
<property name="kundera.port" value="2181"/>
<property name="kundera.keyspace" value="url_results"/>
<property name="kundera.dialect" value="hbase"/>
<property name="kundera.ddl.auto.prepare" value="create" />
<property name="kundera.client.lookup.class" value="com.impetus.client.hbase.HBaseClientFactory" />
</properties>
</persistence-unit>`enter code here`

当我使用持久调用时,它失败并显示

com.impetus.kundera.KunderaException: 
java.lang.IllegalArgumentException: Entity object is invalid, operation
failed. Please check previous log message for details
at
com.impetus.kundera.persistence.EntityManagerImpl.persist(EntityManagerImpl.java:180)
at xx..xx.xx.xx.(DatabaseConnector.java:46)
at xx.xx.xx.testDatabaseConnector(DatabaseConnectorTest.java:54)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:678)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)
Caused by: java.lang.IllegalArgumentException: Entity object is invalid, operation failed. Please check previous log message for details
at com.impetus.kundera.validation.rules.NullOrInvalidEntityRule.validate(NullOrInvalidEntityRule.java:52)
at com.impetus.kundera.graph.GraphGenerator.generate(GraphGenerator.java:125)
at com.impetus.kundera.graph.GraphGenerator.generateGraph(GraphGenerator.java:78)
at com.impetus.kundera.persistence.PersistenceDelegator.persist(PersistenceDelegator.java:130)
at com.impetus.kundera.persistence.EntityManagerImpl.persist(EntityManagerImpl.java:174)

...还有 25 个

如果我直接使用基类而不是子类,我就能够保留实体类。

知道我做错了什么吗?

最佳答案

在我将实体上的 @Table(name = "common", schema = "url_results@hbase_pu") 更改为 @Table(name = "common", schema = "url_results") 后,这才起作用,但是,这看起来像是 kundera 中的一个错误,并向他们提交了一个错误。

关于java - 无法使用 kundera 将继承的实体持久保存到 Hbase,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43670675/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com