0

I'm using hibernate with Play! Framework. Here's my entity:

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.node.ArrayNode;
import com.fasterxml.jackson.databind.node.ObjectNode;
import models.User;
import org.hibernate.annotations.DynamicUpdate;
import play.db.jpa.JPA;
import play.db.jpa.Transactional;
import play.libs.Json;

import javax.persistence.*;
import java.util.List;

@Entity
@JsonIgnoreProperties({"hibernateLazyInitializer", "handler"})
@DynamicUpdate(value=true)
@Table(name = "trees")
public class DecisionTree implements IModel{
...
}

Here's my persistence.xml

<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>org.hibernate.jpa.HibernatePersistenceProvider</provider>
        <non-jta-data-source>DefaultDS</non-jta-data-source>
        <class>models.User</class>
        <class>models.role.Role</class>
        <class>models.role.UserRole</class>
        <class>models.role.RolePermission</class>
        <class>models.ai.DecisionTree</class>
        <class>models.ai.DecisionNode</class>
        <class>models.ai.Link</class>
        <class>models.ai.NodeContent</class>
        <properties>
            <property name="hibernate.dialect" value="org.hibernate.dialect.H2Dialect"/>
            <!--property name="hibernate.show_sql" value="false" />
            <property name="hibernate.format_sql" value="false" /-->
        </properties>
    </persistence-unit>

</persistence>

Here's the code that I'm executing:

public static List<DecisionTree>findAll(){
        TypedQuery<DecisionTree> query = JPA.em().createQuery("SELECT n FROM DecisionTree n", DecisionTree.class);
        return query.getResultList();
    }

And this is what I get:

[IllegalArgumentException: org.hibernate.hql.internal.ast.QuerySyntaxException: DecisionTree is not mapped [SELECT n FROM DecisionTree n]]
In /Users/saksham/workspace/sde/app/models/ai/DecisionTree.java:96
93    }
94
95    public static List<DecisionTree>findAll(){
96        TypedQuery<DecisionTree> query = JPA.em().createQuery("SELECT n FROM DecisionTree n", DecisionTree.class);
98        return query.getResultList();
99    }

Any clues what I may be missing here? Mysql tables are present, so are all the table columns.

Saksham Gupta
  • 223
  • 1
  • 2
  • 8

0 Answers0