question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

NullOrInvalidEntityRule - entity metadata is always null (Kundera mongo 3.12)

See original GitHub issue

NullOrInvalidEntityRule - metadata is always null

public boolean validate(E entity)
    {
        if (entity != null)
        {
            // entity metadata could be null.
            if (entityMetadata == null)
            {
                throw new IllegalArgumentException(
                        "Entity object is invalid, operation failed. Please check previous log message for details");
            }

            return false;

        }

        // will return false if entity is null.
        return true;
    }

@Data
@Entity
@Table(name = "person", schema = "testDB@defaultPersistenceUnit")
public class Person {

  @Id
  @Column(name = "id")
  private String id;

  private String name;

}

    final EntityManagerFactory defaultPersistenceUnit = Persistence.createEntityManagerFactory("defaultPersistenceUnit");
    final EntityManager entityManager = defaultPersistenceUnit.createEntityManager();
    final Person person = new Person();
    entityManager.persist(person);
    return ok(Json.toJson(person));

<persistence xmlns="http://xmlns.jcp.org/xml/ns/persistence"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd"
  version="2.1">

  <persistence-unit name="defaultPersistenceUnit" transaction-type="RESOURCE_LOCAL">
    <provider>com.impetus.kundera.KunderaPersistence</provider>
    <exclude-unlisted-classes>true</exclude-unlisted-classes>
    <properties>
      <property name="kundera.nodes" value="localhost"/>
      <property name="kundera.port" value="27017"/>
      <property name="kundera.keyspace" value="testDB"/>
      <property name="kundera.dialect" value="mongodb"/>
      <property name="kundera.annotations.scan.package" value="models"/>
      <property name="kundera.ddl.auto.prepare" value="create"/>
      <property name="kundera.client.lookup.class" value="com.impetus.client.mongodb.MongoDBClientFactory"/>
    </properties>
  </persistence-unit>

</persistence>

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:14 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
devender-yadavcommented, May 28, 2018

@limpid-kzonix Thanks for the feedback. We will update wiki accordingly.

1reaction
devender-yadavcommented, May 25, 2018

@limpid-kzonix,

Also, mention entity classes and <exclude-unlisted-classes>true</exclude-unlisted-classes> in persistence.xml

Check sample -https://github.com/Impetus/Kundera/wiki/Using-Kundera-with-Play!-Framework#write-persistencexml

And mention schema in Entity

Example:

@Table(name = "users", schema = "KunderaExamples@cassandra_pu")

Read more comments on GitHub >

github_iconTop Results From Across the Web

Kundera No Entity metadata found for the class - Stack Overflow
When I got this I checked: <class>package.name.DaoClass</class>. was defined in persistence.xml, this resolved the error. Also check
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found