Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/324.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 [IllegalArgumentException:org.hibernate.hql.internal.ast.QuerySyntaxException:DecisionTree未映射[SELECT n FROM DecisionTree n]]_Java_Hibernate_Jpa_Playframework_Persistence.xml - Fatal编程技术网

Java [IllegalArgumentException:org.hibernate.hql.internal.ast.QuerySyntaxException:DecisionTree未映射[SELECT n FROM DecisionTree n]]

Java [IllegalArgumentException:org.hibernate.hql.internal.ast.QuerySyntaxException:DecisionTree未映射[SELECT n FROM DecisionTree n]],java,hibernate,jpa,playframework,persistence.xml,Java,Hibernate,Jpa,Playframework,Persistence.xml,我正在使用hibernate和Play!框架这是我的实体: 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; i

我正在使用hibernate和Play!框架这是我的实体:

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{
...
}
这是我的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>

org.hibernate.jpa.HibernatePersistenceProvider
默认值
模型。用户
模范
models.role.UserRole
角色许可
决策树模型
models.ai.DecisionNode
模型.ai.Link
models.ai.NodeContent
以下是我正在执行的代码:

public static List<DecisionTree>findAll(){
        TypedQuery<DecisionTree> query = JPA.em().createQuery("SELECT n FROM DecisionTree n", DecisionTree.class);
        return query.getResultList();
    }
publicstaticlistfindall(){
TypedQuery query=JPA.em().createQuery(“从DecisionTree n中选择n”,DecisionTree.class);
返回query.getResultList();
}
这就是我得到的:

[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    }
[IllegalArgumentException:org.hibernate.hql.internal.ast.QuerySyntaxException:DecisionTree未映射[SELECT n FROM DecisionTree n]]
在/Users/saksham/workspace/sde/app/models/ai/DecisionTree.java:96中
93    }
94
95公共静态列表findall(){
96 TypedQuery query=JPA.em().createQuery(“从DecisionTree n中选择n”,DecisionTree.class);
98返回query.getResultList();
99    }

有什么线索我可能在这里遗漏了什么吗?Mysql表存在,所有表列也存在

您是否也映射了您的collumns?如果您使用Mysql,如上一条评论中所述,您可能应该使用:
org.hibernate.dialogue.mysqldialogue
,而不是h2实现。您使用的是哪个数据库?我使用的是Mysql,列已经映射@SWiggels修复对我不起作用,再次给我同样的错误