user2547836 user2547836 - 6 months ago 25
Java Question

Cannot persiest inherited Entity to Hbase using kundera

I have two entity classes and one inherited from other,

@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

}


another child class,

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


my persiestance.xml is

<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`



When I use persist call, it fails with

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 more

If I use base class directly instead of child, I was able to persist entity class.

Any idea what I am doing wrong?

Answer Source

This worked after I changed from @Table(name = "common", schema = "url_results@hbase_pu") on the entity to @Table(name = "common", schema = "url_results") however, this looks like a bug in kundera and filed a bug with them.